eth_estimateGas

Network: Ethereum · Mainnet · Chain ID 1 (0x1)

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain.

Parameters

  1. Object — Transaction call object (same as eth_call):

    FieldTypeRequiredDescription
    fromDATANoSender address
    toDATANoRecipient address
    gasQUANTITYNoGas limit
    gasPriceQUANTITYNoGas price
    valueQUANTITYNoValue in wei
    dataDATANoCall data
  2. QUANTITY|TAG — (Optional) Block number, or "latest".

Returns

QUANTITY — The estimated amount of gas.

Request

{ "jsonrpc": "2.0", "method": "eth_estimateGas", "params": [ { "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "value": "0x0", "data": "0xa9059cbb0000000000000000000000001234567890abcdef1234567890abcdef1234567800000000000000000000000000000000000000000000000000000000000f4240" } ], "id": 1 }

Response

{ "jsonrpc": "2.0", "id": 1, "result": "0xc350" }

Code Examples

curl -X POST https://ethereum-rpc.blockreq.com/v1/rpc/public \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","to":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","value":"0x0","data":"0xa9059cbb0000000000000000000000001234567890abcdef1234567890abcdef1234567800000000000000000000000000000000000000000000000000000000000f4240"}],"id":1}'

Try It