eth_blockNumber - Ethereum
Returns the number of the most recent block.

Parameters

none

Returns

QUANTITY - integer of the current block number the client is on.

Example

Try out an example request using the Alchemy Composer tool!
Or check out the example below:

Request

alchemyweb3.js
ethers.js
web3.py
Curl
Postman
1
// Installation instructions: https://github.com/alchemyplatform/alchemy-web3
2
3
async function main() {
4
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
5
const web3 = createAlchemyWeb3("https://eth-mainnet.alchemyapi.io/v2/your-api-key");
6
const blockNumber = await web3.eth.getBlockNumber();
7
console.log(blockNumber);
8
}
9
main();
Copied!
1
// Installation instructions: https://docs.ethers.io/v5/getting-started/#installing
2
3
async function main() {
4
const { ethers } = require("ethers");
5
const provider = new ethers.providers.JsonRpcProvider("https://eth-mainnet.alchemyapi.io/v2/your-api-key");
6
const blockNumber = await provider.getBlockNumber();
7
console.log(blockNumber);
8
main()
Copied!
1
# Installation Instructions: https://web3py.readthedocs.io/en/latest/quickstart.html#installation
2
3
from web3 import Web3, HTTPProvider
4
5
web3 = Web3(Web3.HTTPProvider('https://eth-mainnet.alchemyapi.io/v2/your-api-key'))
6
blockNumber = web3.eth.blockNumber
7
print(blockNumber)
Copied!
1
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
2
-X POST \
3
-H "Content-Type: application/json" \
4
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":0}'
Copied!
1
URL: https://eth-mainnet.alchemyapi.io/v2/your-api-key
2
RequestType: POST
3
Body:
4
{
5
"jsonrpc":"2.0",
6
"method":"eth_blockNumber",
7
"params":[],
8
"id":0
9
}
Copied!

Result

1
{
2
"jsonrpc": "2.0",
3
"id": 0,
4
"result": "0xa1c054"
5
}
Copied!