Polygon
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Polygon
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_estimateGas simulates a transaction against current Polygon state and returns the amount of gas it would consume — without ever broadcasting it. On Polygon PoS gas is paid in MATIC, and while fees are very low, an undersized gas limit still fails with out-of-gas, so estimating first is the safe path. Send the transaction object to https://polygon.therpc.io/YOUR_API_KEY (chain ID 137, 0x89) and the node runs the EVM, returning a hex gas figure that already includes a small safety buffer.
0xc2132D05D31c914a87C6611C10748AEb04B58e8F.to and passing the bytecode in data.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 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 Polygon 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 or -32000), not a gas number — handle that path instead of expecting a figure.المعاملات
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