eth_gasPrice - BSC
Example code for the eth_gasPrice JSON RPC method. Сomplete guide on how to use eth_gasPrice JSON RPC in GetBlock Web3 documentation.
This method returns the current gas price on the BNB Smart Chain in wei. BSC is known for its low transaction fees, typically around $0.10 or less per transaction. This method is essential for calculating transaction costs and setting appropriate gas prices.
Parameters
None
Request Example
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": "getblock.io"
}'const axios = require('axios');
const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
method: 'eth_gasPrice',
params: [],
id: 'getblock.io'
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => {
const gasPriceWei = parseInt(response.data.result, 16);
const gasPriceGwei = gasPriceWei / 1e9;
console.log('Gas Price:', gasPriceGwei, 'Gwei');
})
.catch(error => console.error(error));Response Example
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x12a05f200"
}Response Parameters
jsonrpc
string
JSON-RPC version (2.0)
id
string
Request identifier
result
string
Gas price in wei (0x12a05f200 = 5 Gwei)
Use Cases
Estimate transaction costs on BSC
Set appropriate gas prices for transactions
Monitor network congestion
Calculate fee budgets for DeFi applications
Compare costs across different networks
Error Handling
-32603
Internal error - node processing issues
-32000
Server error - RPC endpoint unavailable
SDK Integration
Last updated
Was this helpful?