eth
Last updated
Was this helpful?
Last updated
Was this helpful?
Documentation for the API methods in the eth namespace can be found on . Etn-sc provides several extensions to the standard "eth" JSON-RPC namespace that are defined below.
These methods are used for real-time events through subscriptions. See the for more information.
Executes a new message call immediately, without creating a transaction on the block chain. The method can be used to query internal contract state, to execute validations coded into a contract or even to test what the effect of a transaction would be without running it live.
The method takes 3 parameters: an unsigned transaction object to execute in read-only mode; the block number to execute the call against; and an optional state override-set to allow executing the call against a modified chain state.
The transaction call object is mandatory.
The block number is mandatory and defines the context (state) against which the specified transaction should be executed. It is not possible to execute calls against reorged blocks; or blocks older than 128 (unless the node is an archive node).
The state override set is an optional address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing the call. Each address maps to an object containing:
balance
Quantity
<32
Yes
Fake balance to set for the account before executing the call.
nonce
Quantity
<8
Yes
Fake nonce to set for the account before executing the call.
code
Binary
any
Yes
Fake EVM bytecode to inject into the account before executing the call.
state
Object
any
Yes
Fake key-value mapping to override all slots in the account storage before executing the call.
stateDiff
Object
any
Yes
Fake key-value mapping to override individual slots in the account storage before executing the call.
The goal of the state override set is manyfold:
It can be used by DApps to reduce the amount of contract code needed to be deployed on chain. Code that simply returns internal state or does pre-defined validations can be kept off chain and fed to the node on-demand.
It can be used for smart contract analysis by extending the code deployed on chain with custom methods and invoking them. This avoids having to download and reconstruct the entire state in a sandbox to run custom code against.
It can be used to debug smart contracts in an already deployed large suite of contracts by selectively overriding some code or state and seeing how execution changes. Specialized tooling will probably be necessary.
Example:
Return Values
The method returns a single Binary consisting the return value of the executed contract call.
Parameters
transaction
Object
TransactionCall object
blockNumberOrTag
Object
Optional, blocknumber or latest or pending
Usage
Response
That is, it gives the list of addresses and storage keys that will be used by that transaction, plus the gas consumed if the access list is included. Like eth_estimateGas, this is an estimation; the list could change when the transaction is actually mined. Adding an accessList to a transaction does not necessary result in lower gas usage compared to a transaction without an access list.
Example:
Returns a block header.
Parameters
blockNumber
Quantity
Block number
Usage
curl localhost:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getHeaderByNumber","params":["0x10823a8"],"id":0}'
Response
Returns a block header.
Parameters
blockHash
string
Block hash
Usage
Response
This method creates an type accessList based on a given Transaction. The accessList contains all storage slots and addresses read and written by the transaction, except for the sender account and the precompiles. This method uses the same transaction call object and blockNumberOrTag object as . An accessList can be used to unstuck contracts that became inaccessible due to gas cost increases.
The method returns list of addresses and storage keys used by the transaction, plus the gas consumed when the access list is added.