LogoLogo
  • What is QPQ?
  • Quickstart
    • Creating your network and node
    • Setup Metamask and get Tokens
    • Create a Metamask account
    • Send tokens between accounts
  • Smart Contracts
    • Ethereum API
      • eth_blockNumber
      • eth_getBlockByHash
      • eth_getBlockByNumber
      • eth_getTransactionByHash
      • eth_getTransactionCount
      • eth_getTransactionReceipt
      • eth_sendRawTransaction
      • eth_getBalance
      • eth_getCode
      • eth_call
      • eth_getLogs
      • eth_estimateGas
      • eth_chainId
      • net_version
    • Deploy and interact with a smart contract
      • Hardhat
        • Interaction - Greeter
      • Remix IDE
  • Tutorials
    • NFT deploy
  • Bridge
    • Setup the bridge
  • Resources
    • 1DLT Frequently asked Questions (FAQ)
    • Support
Powered by GitBook
On this page
  • Parameters
  • Returns
  • Request
  • Returns
  1. Smart Contracts
  2. Ethereum API

eth_getBlockByNumber

Returns information about a block by block number.

Previouseth_getBlockByHashNexteth_getTransactionByHash

Last updated 2 years ago

Parameters

  • QUANTITY|TAG - integer of a block number, or the string "earliest", "latest" or "pending", as in the .

  • Boolean - If true it returns the full transaction objects, if false only the hashes of the transactions.

params: [
    '0x1b4', 
    true
]

Returns

See

Request

const Web3 = require("web3");

async function main() {
    const Web3 = require('web3')
    const rpcURL = '1DLT-IP-ADDRESS' // Your RPC URL goes here
    const web3 = new Web3(rpcURL)
	
	// Query the blockchain (replace example parameters)
	const blockByNumber = await web3.eth.getBlock('latest', true);

	// Print the output to console
	console.log(blockByNumber);
   }

main();
const ethers = require("ethers");
(async () => {
  const provider = new ethers.providers.JsonRpcProvider("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/");
  const blockData = await provider.getBlock(
    "0xc5043f"
  );
  console.log(blockData);
})();
curl 1DLT-IP-ADDRESS \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":0}'

Returns

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "number": "0x1b4",
    "difficulty": "0x4ea3f27bc",
    "extraData": "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32",
    "gasLimit": "0x1388",
    "gasUsed": "0x0",
    "hash": "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0xbb7b8287f3f0a933474a79eae42cbca977791171",
    "mixHash": "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843",
    "nonce": "0x689056015818adbe",
    "parentHash": "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54",
    "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0x220",
    "stateRoot": "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d",
    "timestamp": "0x55ba467c",
    "totalDifficulty": "0x78ed983323d",
    "transactions": [],
    "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
    "uncles": []
  }
}
default block parameter
get_BlockByHash