Ethereum
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Ethereum
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
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.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 1 | transaction | object | نعم | Transaction object. `to` is required for calls; omit `to` for contract deployments. Optional: `from`, `gas`, `gasPrice`/`maxFeePerGas`/`maxPriorityFeePerGas`, `value`, `data`. |
| 2 | blockTag | string | لا | Block state to simulate against. Defaults to `latest`.الافتراضي: latest |
| النوع | الوصف |
|---|---|
| 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.
| الكود | الرسالة | السبب |
|---|---|---|
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.المعاملات
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