Get a block by number
curl --request POST \
--url https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getBlockByNumber",
"params": [
"latest",
false
]
}
'import requests
url = "https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getBlockByNumber",
"params": ["latest", False]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'eth_getBlockByNumber',
params: ['latest', false]
})
};
fetch('https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 1,
'method' => 'eth_getBlockByNumber',
'params' => [
'latest',
false
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"eth_getBlockByNumber\",\n \"params\": [\n \"latest\",\n false\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"eth_getBlockByNumber\",\n \"params\": [\n \"latest\",\n false\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"eth_getBlockByNumber\",\n \"params\": [\n \"latest\",\n false\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0xd4ddea8815732fae7af5b907c5d3db50475ed180510e8035789640fb144b1722",
"number": "0x1cf6b4",
"timestamp": "0x6a87ac45",
"timestampMillisPart": "0x9f",
"proposer": "0x8f59f57db707e439c261f878e88170c6848d8a3493b272c21308d879068e67da19efde55f5bf4c2eb61439232e3cae76",
"interopMessageRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"ethereumUpdate": "0x",
"validatorSetRoot": "0x1111111111111111111111111111111111111111111111111111111111111111",
"nextValidatorSetRoot": "0x1111111111111111111111111111111111111111111111111111111111111111",
"gasUsed": "0x0",
"gasLimit": "0x1dcd6500",
"transactions": []
}
}Blocks
Get a block by number
Returns the block for the given selector, or null if unknown. The standard Ethereum fields are extended with timestampMillisPart, proposer, interopMessageRoot, ethereumUpdate, validatorSetRoot, nextValidatorSetRoot, and optional subblockMetadataRoot. Full timestamp in milliseconds = timestamp * 1000 + timestampMillisPart.
POST
/
eth_getBlockByNumber
Get a block by number
curl --request POST \
--url https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getBlockByNumber",
"params": [
"latest",
false
]
}
'import requests
url = "https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getBlockByNumber",
"params": ["latest", False]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'eth_getBlockByNumber',
params: ['latest', false]
})
};
fetch('https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 1,
'method' => 'eth_getBlockByNumber',
'params' => [
'latest',
false
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"eth_getBlockByNumber\",\n \"params\": [\n \"latest\",\n false\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"eth_getBlockByNumber\",\n \"params\": [\n \"latest\",\n false\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rpc-testnet.metalntwx.com/v1/{endpointId}/eth_getBlockByNumber")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"eth_getBlockByNumber\",\n \"params\": [\n \"latest\",\n false\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0xd4ddea8815732fae7af5b907c5d3db50475ed180510e8035789640fb144b1722",
"number": "0x1cf6b4",
"timestamp": "0x6a87ac45",
"timestampMillisPart": "0x9f",
"proposer": "0x8f59f57db707e439c261f878e88170c6848d8a3493b272c21308d879068e67da19efde55f5bf4c2eb61439232e3cae76",
"interopMessageRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"ethereumUpdate": "0x",
"validatorSetRoot": "0x1111111111111111111111111111111111111111111111111111111111111111",
"nextValidatorSetRoot": "0x1111111111111111111111111111111111111111111111111111111111111111",
"gasUsed": "0x0",
"gasLimit": "0x1dcd6500",
"transactions": []
}
}Body
application/json
Response
200 - application/json
JSON-RPC 2.0 response. Errors are reported in-band via an error object with code and message in place of result.