eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.
This method only estimates gas, the transaction will not be added to the blockchain.
Example
curl https://bsc-mainnet.web3api.com/v1/JDJJU1F4K956DP9A6ZQFHGTF1NHXEIPPDI
-X POST
-H "Content-Type: application/json"
-d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateGas\",\"params\": [{\"from\": \"0x71C7656EC7ab88b098defB751B7401B5f6d8976F\",\"to\": \"0xd46e8dd67c5d32be8058bb8eb970870f07244567\",\"gas\": \"0x30D40\",\"gasPrice\": \"0x9184e72a000\",\"value\": \"0x9184e72a\",\"data\": \"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675\"}],\"id\":1}"
curl -X POST 'https://bsc-<network>.web3api.com/v1/YOUR-API-KEY' \
-H 'Content-Type: application/json' \
--data-raw '{"jsonrpc":"2.0","method":"eth_estimateGas","params": [{"from": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F","to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas": "0x30D40","gasPrice": "0x9184e72a000","value": "0x9184e72a","data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}],"id":1}'
TRANSACTION CALL OBJECT
- A complete model transaction you intend to send, with the following information.
from
: 20 Bytes - The address the transaction is sent from.
to
: 20 Bytes - The address the transaction is directed to.
gas
: Integer of the gas provided for the transaction execution.
gasPrice
: Integer of the gasPrice used for each unit of gas paid.
value
: Integer of the value sent with this transaction
data
: Hash of the method signature and encoded parameters. For details see Ethereum Contract ABIs.