API Reference

eth_estimateGas - zkSync Era

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

  • Object - The transaction call object
    • from: DATA, 20 Bytes - (optional) The address the transaction is sent from.
    • to: DATA, 20 Bytes - The address the transaction is directed to.
    • gas: QUANTITY - (optional) Integer of the gas provided for the transaction execution. eth_estimateGas consumes zero gas, but this parameter may be needed by some executions. NOTE: this parameter has a cap of 550 Million gas per request.
    • gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas.
    • value: QUANTITY - (optional) Integer of the value sent with this transaction
    • data: DATA - (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI
  • QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter.

NOTE

  • eth_estimateGas** **will check the balance of the sender (to make sure that the sender has enough gas to complete the request). This means that even though the call doesn't consume any gas, the from address must have enough gas to execute the transaction.
  • If no gas is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of actual gas needed is higher than the pending block gas limit.

Returns

QUANTITY - The amount of gas used.


Example

Request

curl --request POST \
     --url https://zksync-era-mainnet.unifra.io/v1/{your-api-key} \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "jsonrpc": "2.0",
  "method": "eth_estimateGas",
  "params": [
    {
      "from": "0x68f3c80abd25a7d60060d29a44be31528480f21c",
      "to": "0x7754aa6310ae6f682855e3ddcbefcda885acacea",
      "gas": "0x111111111",
      "gasPrice": "0x1000",
      "value": "0x0",
      "data": "0x6930fd2a0000000000000000000000000000000000000000000000000000000000000014"
    },
    "0x5d1b97"
  ],
  "id": 1
}
'

Result

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x575a8"
}
Language
Click Try It! to start a request and see the response here!