Add a new API on EVM
contract to support read-only calls on a transaction context
#6800
Labels
EVM
contract to support read-only calls on a transaction context
#6800
Problem definition:
Currently, whenever a user wants to make a Solidity contract call, from within a Cadence transaction, the only available API is CadenceOwnedAccount.call.
It was observed that this API will form a new EVM transaction, even when the user's intention is to simply read the state of a Solidity contract, such as the
name
|symbol
|decimals
of an ERC20 contract.One such example of a transaction we can see here: https://evm.flowscan.io/tx/0x785738aed18cd78885f4c461d351f58543147ae00df320c482096d7eef3deea9.
Since transactions are meant for mutating state on the blockchain, having transactions as the above, is counter-intuitive and should be avoided.
Proposed solution:
To work around this, we should provide the equivalent of EVM.dryRun, but with a more user-friendly interface, as
EVM.dryRun
expects an RLP-encoded transaction.Ideally, the interface should look like the following:
And the function should be defined under the
EVM
contract itself, not under theCadenceOwnedAccount
resource, as this will enforce users to create that resource, and we should avoid this extra computation.Both
EVM.dryCall
&EVM.call
should be rather intuitive names for Ethereum developers, as theeth_call
JSON-RPC endpoint also does not make any state changes.Regardless of the addition of this new API, we need to make it explicit that
CadenceOwnedAccount.call
produces EVM transactions, and should be avoid when the intention is to simply read a contract's state.The text was updated successfully, but these errors were encountered: