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
- Simulate contract function execution without blockchain state change
- Retrieve return values from smart contract functions
- Estimate gas usage for contract function calls
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.
Unlock Access to 50+ chains
Boost your app's speed and reliability with dRPC - get your access API key
Language
Request
Examples
curl --request POST \
--url https://optimism.drpc.org \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
"0x61A80",
{
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x0",
"gasPrice": "0x9184e72a000",
"value": "0x0",
"data": "0x"
}
]
}
'
Response
200
{
"jsonrpc": "2.0",
"id": 1,
"result": "0xb1770efb14906e509893b6190359658208ae64d0c56e22f748a1b0869885559e"
}
Request params
idinteger
jsonrpcstring
methodstring
array of objects
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.
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.
Response
200
The result of the call.Response params
object
idinteger
jsonrpcstring
resultstring