Is there a way to access read-only functions across chains?

I am wondering if there are oracles (for example on polygon) or alike that allows to call smart-contracts read-only functions (therefore gasless) on another chain (for example ethereum main chain)?

Has anybody done this?

you could implement something like that if you want, I don’t know if something like this already exists

That would have to be some kind of bridge. I know chainlink has be looking into cross-chain calls but I just wondered if that would simpler to implement for read-only (as it does not requires any gas). That would still be valuable for proof of ownership or existence.

you may have to use gas for the oracle when it sends that information on chain

Ah yeah, essentially to pay for the syncing servers.

Oracles like Chainlink are the main go to for cross-chain. What is an example of your use case?

Checking that an NFT exists and getting its owner across chains.

I’m not sure how that would work unless the contract address is guaranteed the same across each chain. Or are you using other details for checking the NFT?

Oh, good question. I would know the other chain contract address and token number before hand. The smart contract could call a “bridge” contract that would trigger the read only call on the other chain.

Is it a must that it all happens on-chain? Because with oracles you’ll probably have to pay fees. Not too sure how bridge contracts work.

Mmmm. I am trying to connect NFTs somehow and that works very well within chains. But it seems like the current state of the field for multi-chains is not there yet/

I have worked on a cross-chain solution for sharing EVM account states. Since account states are stored on the EVM, it is easy to access and visualize the data within the same network (thus, gasless). However, cross-chain solutions are very dependent on EVENTS to filter out relevant transactions, and unfortunately, emitting events on any EVM compatible network costs gas.

You can create very cheap methods that emit events on Solidity tho. Of course, you’ll need some back-end to handle events (Node JS + Ethers.js can solve that), call a view or pure function on the target secondary chain, and get the data back to your smart contract on the primary chain. But again, to store that data on the EVM address storage will cost you some gas.

1 Like

thanks for these thoughts and for sharing. I might look onto this.

I was thinking a solution if willing to pay fees could be to make an oracle with Chainlink that queries an API (could be Node/Express/ethers) that has a separate provider that calls a read function on a contract and returns it, maybe on the one endpoint or one for each chain. There’d be some other implementation details that are missing like where the other contract addresses would be pulled from or stored. If it’s just to check ownership to be used in some function logic it probably doesn’t need to be stored.

Say for example, if you want to pay copyrights fee for using someone else NFT. Could such a system allow to do everything on Polygon?
For example, you get the NFT owner of Cryptopunks on Ethereum main net and pay the copyright fee on the same wallet on Polygon.

All ethereum networks shares the same public/private key system so the owner of the NFT would have access to the funds.

Is that any practical in your opinion?

Calling the methods that check an NFT owner on a different network needs off-chain computation. Having acknowledged that, everything else you mentioned is possible.

1 Like