eth_estimateGas

zkLink Nova chain RPC Methods & API Documentation


eth_estimateGas RPC Method

The eth_estimateGas method is used to estimate the gas that would be used by a transaction if it were to be executed on the zkLink Nova chain. This transaction will not appear on blockchain

⚠️

eth_estimateGas verifies the balance of the sender to ensure that the sender has sufficient gas to fulfill the request. While the call does not consume any gas, the from address must have enough gas to execute the transaction.

Parameters

1.TRANSACTION CALL OBJECT [required]

  • from [optional] - The address are you sending transactions from.
  • to - The address where the transaction is sent to.
  • gas [optional] - Integer of the gas provided for the transaction execution. Although eth_estimateGas does not require gas, this parameter may still be needed by some executions.
  • gasPrice [optional] - The price to be paid per gas (hexadecimal format).
  • maxPriorityFeePerGas [optional] - Maximum fee, in Wei, the sender is ready to pay per gas above the base fee.
  • maxFeePerGas [optional] - Maximum total fee (base fee + priority fee), in Wei, the sender is ready to pay per gas. maxPriorityFeePerGas and maxFeePerGas are used in the new type of Ethereum transactions called EIP 1559. Read more info here (opens in a new tab)
💎

maxPriorityFeePerGas and maxFeePerGas can not be used with gasPrice in one transacion

💎

You can convert WEI to ETH on this page (opens in a new tab). MATIC has 18 decimals, so 1 MATIC equals 1 * 10^18

  • value [optional] - Interger of the value transferred in the transaction. (How much do you send)
  • data [optional] - Hash of the method signature and encoded parameters. More info 👉 Ethereum Contract ABI (opens in a new tab)

Returns

Gas used - the amount of gas used.

Request

POST https://<network>.chainnodes.org/YOUR-API-KEY

Need RPC API keys?

Get 12.5M archival requests for free today.

Example

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your CHAINNODES.ORG Dashboard
  • You can use a different supported network by replacing zklink-nova-mainnet
curl https://zklink-nova-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_estimateGas","params": [{"from": "0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503","to": "0xdAC17F958D2ee523a2206206994597C13D831ec7","gas": "0x30D40","gasPrice": "0x2E90EDD000","value": "0x0","data": "0xa9059cbb000000000000000000000000d6216fc19db775df9774a6e33526131da7d19a2c0000000000000000000000000000000000000000000000000000000005f5e100"}],"id":1}'

Body

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

💡 Confusing?

Ask our experienced blockchain developers in Telegram