bashcurl --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"
}'
javascriptconst axios = require('axios');
const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
jsonrpc: '2.0',
method: 'eth_gasPrice',
params: [],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
const gasPriceWei = parseInt(response.data.result, 16);
const gasPriceGwei = gasPriceWei / 1e9;
console.log('Gas Price:', gasPriceGwei, 'gwei');
pythonimport requests
response = requests.post(
'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'eth_gasPrice',
'params': [],
'id': 'getblock.io'
}
)
result = response.json()
gas_price_wei = int(result['result'], 16)
gas_price_gwei = gas_price_wei / 1e9
print(f'Gas Price: {gas_price_gwei} gwei')
rustuse reqwest::Client;
use serde_json::{json, Value};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let response = client
.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
.header("Content-Type", "application/json")
.json(&json!({
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": "getblock.io"
}))
.send()
.await?
.json::<Value>()
.await?;
println!("Gas Price: {}", response["result"]);
Ok(())
}
javascriptconst { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
async function getGasPrice() {
const feeData = await provider.getFeeData();
console.log('Gas Price:', ethers.formatUnits(feeData.gasPrice, 'gwei'), 'gwei');
console.log('Max Fee Per Gas:', ethers.formatUnits(feeData.maxFeePerGas, 'gwei'), 'gwei');
console.log('Max Priority Fee:', ethers.formatUnits(feeData.maxPriorityFeePerGas, 'gwei'), 'gwei');
return feeData;
}
getGasPrice();
javascriptimport { createPublicClient, http, formatGwei } from 'viem';
import { base } from 'viem/chains';
const client = createPublicClient({
chain: base,
transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});
async function getGasPrice() {
const gasPrice = await client.getGasPrice();
console.log('Gas Price:', formatGwei(gasPrice), 'gwei');
return gasPrice;
}
getGasPrice();