eth_getBlockByNumber - Mantle

This method returns information about a block on Mantle by block number.

Parameters

ParameterTypeDescription
blockNumberstringBlock number in hex, or "latest", "earliest", "pending"
fullTransactionsbooleanIf true, returns full transaction objects; if false, returns transaction hashes

Request

curl

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_getBlockByNumber",
    "params": ["0x3F6777", false],
    "id": "getblock.io"
}'

axios example

javascriptimport axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "eth_getBlockByNumber",
    "params": ["0x3F6777", false],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data)))
    .catch(error => console.log(error));

python example

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = json.dumps({
    "jsonrpc": "2.0",
    "method": "eth_getBlockByNumber",
    "params": ["0x3F6777", False],
    "id": "getblock.io"
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)

rust example

rustuse reqwest::header;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header(header::CONTENT_TYPE, "application/json")
        .body(r#"{
            "jsonrpc": "2.0",
            "method": "eth_getBlockByNumber",
            "params": ["0x3F6777", false],
            "id": "getblock.io"
        }"#)
        .send()
        .await?;
    
    println!("{}", response.text().await?);
    Ok(())
}

Response

Response (JSON)

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "difficulty": "0x2",
        "extraData": "0xd98301090a846765746889676f312e31352e3133856c696e7578",
        "gasLimit": "0xe4e1c0",
        "gasUsed": "0x5208",
        "hash": "0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e",
        "logsBloom": "0x00000000...",
        "miner": "0x0000000000000000000000000000000000000000",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0000000000000000",
        "number": "0x3f6777",
        "parentHash": "0xd9505c7d82fbbad090d3ab4b4ecd20bca0f3700ce0c0c5ad2563a4100f86a004",
        "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "size": "0x2d1",
        "stateRoot": "0x6ac1007f49aecaa29deff133703b287eb166ed12826bb685520f4b7a1aace96a",
        "timestamp": "0x643fc8a5",
        "totalDifficulty": "0x7eceef",
        "transactions": [
            "0x6dfef681e0a83a40b05d40877e53a88459e8829240a6d6d5ec6fe816e435f8d8"
        ],
        "transactionsRoot": "0x...",
        "uncles": []
    }
}

Response Parameters

FieldTypeDescription
numberstringBlock number (hex)
hashstringBlock hash (32 bytes)
parentHashstringParent block hash
timestampstringUnix timestamp of block creation
gasLimitstringMaximum gas allowed in block
gasUsedstringTotal gas used by transactions
transactionsarrayArray of transaction hashes or objects
minerstringAddress of block producer

Use Case

The eth_getBlockByNumber method is essential for:

  • Block explorer functionality
  • Transaction confirmation tracking
  • Historical data analysis
  • Chain synchronization verification
  • DeFi protocol state tracking
  • Event indexing by block range

Error Handling

Status CodeError MessageCause
403ForbiddenMissing or invalid ACCESS-TOKEN
-32602Invalid paramsInvalid block number format

Web3 Integration

ethers.js example

javascriptimport { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

const block = await provider.getBlock(4155255);
console.log('Block:', block);

viem example

javascriptimport { createPublicClient, http } from 'viem';
import { mantle } from 'viem/chains';

const client = createPublicClient({
    chain: mantle,
    transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});

const block = await client.getBlock({
    blockNumber: 4155255n
});
console.log('Block:', block);