Ethereum
Prêt à utiliser cela en production ?
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
Ethereum
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
eth_estimateGas dry-runs a transaction through the EVM on Ethereum mainnet and tells you how much gas it would consume, without ever broadcasting it or spending ETH. The node executes your transaction object against current state, measures the gas the execution path actually touched, and returns that figure (usually with a small safety margin baked in). You use it to fill the gas limit field before signing — a transfer is famously 21,000, but a Uniswap swap or an NFT mint can run an order of magnitude higher, and only a simulation tells you the real number. Send the request to https://ethereum.therpc.io/YOUR_API_KEY (chain ID 1); the gas limit you set determines your worst-case cost in ETH, even though the actual charge reflects gas used.
to and pass deployment bytecode in data to learn the gas a new contract's constructor will burn before you commit ETH to it.eth_feeHistory to show users an ETH cost before they approve.| # | Nom | Type | Obligatoire | Description |
|---|---|---|---|---|
| 1 | transaction | object | Oui | Transaction object. `to` is required for calls; omit `to` for contract deployments. Optional: `from`, `gas`, `gasPrice`/`maxFeePerGas`/`maxPriorityFeePerGas`, `value`, `data`. |
| 2 | blockTag | string | Non | Block state to simulate against. Defaults to `latest`.Défaut : latest |
| Type | Description |
|---|---|
| string | Hex-encoded gas estimate. The node typically adds a small safety buffer above the raw simulation result. |
Try it live in the Ethereum playground.
| Code | Message | Cause |
|---|---|---|
3 | execution reverted | The simulated transaction reverted; the estimate cannot be produced. |
-32000 | gas required exceeds allowance | Estimated gas exceeded the block gas limit or the supplied gas cap. |
-32602 | invalid argument | Malformed transaction object. |
3, "execution reverted") instead of a number. Treat that as "this would fail," not as a transient glitch to retry.Paramètres
Transaction object. `to` is required for calls; omit `to` for contract deployments. Optional: `from`, `gas`, `gasPrice`/`maxFeePerGas`/`maxPriorityFeePerGas`, `value`, `data`.
"latest" | "pending" | hex block number