eth_gasPrice
Returns the current price per gas in wei on Optimism Layer 2.
Parameters
None. This method takes no parameters.
Implementation Examples
- cURL
- JavaScript
curl -X POST https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 1
}'
// Get Optimism L2 gas price
const response = await fetch('https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_gasPrice',
params: [],
id: 1
})
});
const data = await response.json();
const gasPriceWei = BigInt(data.result);
const gasPriceGwei = Number(gasPriceWei) / 1e9;
console.log('Optimism L2 Gas Price:', gasPriceGwei, 'gwei');
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1dcd6500"
}
This represents approximately 0.5 gwei, much lower than Ethereum mainnet.
Need help? Contact our support team or check the Optimism documentation.