Optimism
Bereit, das in der Produktion aufzurufen?
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
Optimism
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
eth_estimateGas simulates a transaction against current OP Mainnet state and returns the estimated amount of L2 execution gas required to run it, priced in ETH. On this OP Stack rollup the figure it returns covers L2 execution only — the separate L1 data fee for posting the transaction to Ethereum is added at submission time and is not part of this estimate. Send the request to https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa) to size a gas limit before signing.
to and passing the deploy bytecode as data.| # | Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|---|
| 1 | transaction | object | Ja | Transaction object. `to` is required for calls; omit `to` for contract deployments. Optional: `from`, `gas`, `gasPrice`/`maxFeePerGas`/`maxPriorityFeePerGas`, `value`, `data`. |
| 2 | blockTag | string | Nein | Block state to simulate against. Defaults to `latest`.Standard: latest |
| Typ | Beschreibung |
|---|---|
| string | Hex-encoded gas estimate. The node typically adds a small safety buffer above the raw simulation result. |
Try it live in the Optimism playground.
| Code | Meldung | Ursache |
|---|---|---|
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 or -32000), not a gas number — handle that path and surface the revert reason instead of assuming success.Parameter
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