eth_call - Optimism

eth_call. Allows to execute message calls and retrieve data from smart contracts instantly without generating a transaction

eth_call - optimism [Value: 21CU]
Performs a message call instantly without recording it as a transaction on the blockchain
Use cases

Use cases

  • Simulate contract function execution without blockchain state change
  • Retrieve return values from smart contract functions
  • Estimate gas usage for contract function calls
Constraints

Constraints

  • Starting from Geth 1.9.13, eth_call checks the sender's balance to ensure sufficient gas for execution if either: The gas_price parameter is populated, the contract function modifies the blockchain state.
  • In these cases, the from address must have enough gas as ifexecuting a write transaction, even though eth_call itself doesn't consume gas.
Get started
Unlock Access to 50+ chains
Boost your app's speed and reliability with dRPC - get your access API key

Language

Request
Examples
curl https://optimism.drpc.org \
--request POST \
--header "Content-Type: application/json" \
--data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    "0x10F558C",
    {
      "from": "0x4B275BDea1cA622256ebb8B15B51861b52703d16",
      "to": "0xa62894D5196bC44e4C3978400Ad07E7b30352372",
      "gas": "0x13880",
      "gasPrice": "0x4B3ECF6D4",
      "data": "0xa9059cbb0000000000000000000000007422172afc6ea4da9c011e87b7cb002d55b754430000000000000000000000000000000000000000000000000c7d713b0e3f3600"
    },
    {"0x4B275BDea1cA622256ebb8B15B51861b52703d16":{
      "balance": "0x277BFC44534B0000"
    }}
  ]
}
'
Copy
Response
200
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0xb1770efb14906e509893b6190359658208ae64d0c56e22f748a1b0869885559e"
}
Copy

Request params

idinteger
jsonrpcstring
methodstring
Parametersarray of objects
array of objects
blockNumberstring
(optional) Block number as an integer, or string
  • latest [default] - The most recent block in the blockchain (default).
  • earliest - The first block, also known as the genesis block.
  • pending - Transactions that have been broadcast but not yet included in a block.
transactionobject
The transaction call object which contains the following fields.
array of objects
fromstring
(optional) Sender's address.
tostring
Recipient's address.
gasinteger
(optional) Gas limit for the transaction.
gasPriceinteger
(optional) Gas price in wei.
valueinteger
(optional) Amount of wei to send.
datastring
(optional) Encoded method signature and parameters.
State Overrideobject
Tenables temporary modifications to a contract’s state for a specific call without altering the actual contract. Each address maps to an object containing:
array of objects
balancestring
Specifies a temporary balance for the account before executing the call.
noncestring
Sets a temporary nonce for the account before executing the call.
codestring
(Injects temporary EVM bytecode into the account before executing the call.
stateobject
Replaces all storage slots of the account with specified key-value pairs before executing the call.
stateDiffinteger
Modifies specific storage slots in the account while keeping the rest unchanged before executing the call.

Response

200
The result of the call.

Response params

object
idinteger
jsonrpcstring
resultstring