curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": []
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": []
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
none
quantity
— the integer value of the current gas base fee, returned in Weieth_gasPrice
code examplesconst { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);
async function getGasPrice() {
const baseFee = await web3.eth.getGasPrice();
const feeInGwei = web3.utils.fromWei(baseFee, "gwei")
console.log(`The base gas fee is: ${baseFee} Wei`);
console.log(`The base gas fee is: ${feeInGwei} Gwei`);
}
getGasPrice()
eth_gasPrice
to calculate the total gas value to send with a transaction based on the base and priority fee system. Ethereum’s London hard fork implemented This concept with EIP-1559.
EIP-1559 aimed to solve the problem of network congestion by implementing a dynamic fee market mechanism, which adjusts the fee required to process a transaction based on network demand. With the current system, the total gas price comprises a base fee determined by the network’s load and a priority fee added by the user.
eth_gasPrice
method returns the base fee.The value of the current gas base fee in Wei.
The response is of type object
.
Was this page helpful?