eth_getBlockByNumber
Returns information about a block by block number.
Parameters
- Block Parameter - Block number or "latest", "earliest", "pending"
- Boolean - If
true
returns full transaction objects, iffalse
only hashes
{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["0x1b4", true],
"id": 1
}
Returns
Block object or null
if no block found.
Implementation Examples
- cURL
- JavaScript
curl -X POST https://api-tron-jsonrpc.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", false],
"id": 1
}'
// Using ethers.js
const block = await provider.getBlock('latest');
console.log('Latest block:', block);