Skip to main content
Ethereum API
Multichain API

eth_estimateGas

Summary: Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.

Parameters

Transaction object

Transaction object generic to all types

type string

type

Pattern: ^0x([0-9a-fA-F]?){1,2}$

nonce string

nonce

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

to oneOf

to address

Contract Creation (null) null

Contract Creation (null)

hex encoded address string

hex encoded address

Pattern: ^0x[0-9a-fA-F]{40}$

from string

hex encoded address

Pattern: ^0x[0-9a-fA-F]{40}$

gas string

gas limit

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

value string

value

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

input string

hex encoded bytes

Pattern: ^0x[0-9a-f]*$

gasPrice string

The gas price willing to be paid by the sender in wei

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

maxPriorityFeePerGas string

Maximum fee per gas the sender is willing to pay to miners in wei

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

maxFeePerGas string

The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

maxFeePerBlobGas string

The maximum total fee per gas the sender is willing to pay for blob gas in wei

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

accessList array

EIP-2930 access list

Access list entry object

Access list entry

address string

hex encoded address

Pattern: ^0x[0-9a-fA-F]{40}$

storageKeys array

32 byte hex value string

32 byte hex value

Pattern: ^0x[0-9a-f]{64}$

blobVersionedHashes array

List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.

32 byte hex value string

32 byte hex value

Pattern: ^0x[0-9a-f]{64}$

blobs array

Raw blob data.

hex encoded bytes string

hex encoded bytes

Pattern: ^0x[0-9a-f]*$

chainId string

Chain ID that this transaction is valid on.

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$


Block oneOf

Block number or tag

Block number string

Block number

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Block tag enum

earliest: The lowest numbered block the client has available; finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination; safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions; latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions; pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool. Before the merge transition is finalized, any call querying for finalized or safe block MUST be responded to with -39001: Unknown block error

Enum:
"earliest"
"finalized"
"safe"
"latest"
"pending"

Returns

Gas used string

hex encoded unsigned integer

Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Customize request
Parameter
Value
string
string
0x44aa93095d6749a706051658b970b941c72c1d53
oneOf
string
string
string
string
string
string
string
string
[]
array
[]
array
[]
array
string
oneOf
Connect your MetaMask wallet to run requests successfully.
Request
await window.ethereum.request({
"method": "eth_estimateGas",
"params": [
{
from: "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
to: "0x44aa93095d6749a706051658b970b941c72c1d53",
value: "0x1"
}
],
});
Example response
"0x5208"