eth_gasPrice - Somnia
Example code for the eth_gasPrice JSON-RPC method. Complete guide on how to use eth_gasPrice JSON-RPC in GetBlock Web3 documentation.
This method returns the current gas price on the Somnia network in wei. Somnia features dynamic gas pricing with sub-cent transaction fees, making it highly economical for high-throughput applications. This method is essential for estimating transaction costs and setting appropriate gas prices.
Parameters
None
Returns
result
string
Current gas price in wei as hexadecimal
Request Example
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "getblock.io",
"method": "eth_gasPrice",
"params": []
}'const axios = require('axios');
const url = 'https://go.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
id: 'getblock.io',
method: 'eth_gasPrice',
params: []
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));Response Example
Response Parameters
result
string
Gas price in wei (0x3b9aca00 = 1 Gwei)
Use Cases
Estimate transaction costs
Set appropriate gas prices for transactions
Monitor network congestion
Calculate fee budgets for dApps
Implement gas price strategies
Error Handling
-32603
Internal error - node processing issues
-32000
Server error - RPC endpoint unavailable
SDK Integration
Last updated
Was this helpful?