How do I can get the current block number in EOS? (in ethereum, I can use block.number).

  • Are you trying to get the block number from inside a contract? Or from outside the EOS system? Jul 17 '18 at 18:19
  • From inside a contract
    – Wayne
    Jul 18 '18 at 18:55
  • did you find the way to get current block id in the contract ?
    – Qiang Fang
    Sep 20 '18 at 16:27

In cleos you would do:

cleos get info

This returns the head_block_num and the last_irreversible_block_num. To receive addition information on the blocks returned.

cleos get block [number or ID of the block to retrieve]


get_info Returns an object containing various details about the blockchain.

    "server_version": "d9ad8eec",
    "head_block_num": 8592,
    "last_irreversible_block_num": 8591,
    "head_block_id": "00002190e805475db152be7d3f4f1a075efaed42827cd551b0e23c7feabbedac",
    "head_block_time": "2018-04-27T17:40:34",
    "head_block_producer": "eosio"

The response shows the head_block_num, the last_irreversible_block_num, the head_block_time, and the block producer.


get_block Returns an object containing various details about a specific block on the blockchain.

    "previous": "00000004471d48fe40706e73ce27f9cf7bac1704ae55279c7a58c0173718a711",
    "timestamp": "2018-04-18T16:24:23.500",
    "transaction_mroot": "e366c0cc3519bb0f2ddaec20928fa4d6aae546194bb1c4205c67be429147ed4a",
    "action_mroot": "77e5e91b594ab4ebc44ebc8c7ecdc9d26409c5a07452d3b20a4840562fdeb658",
    "block_mroot": "4ef85b0d212f3fffabdd65680d32dd7dded3461d9df226a6e3dc232e42978f8b",
    "producer": "eosio",
    "schedule_version": 0,
    "new_producers": null,
    "producer_signature": "EOSJzEdFDsueKCerL7a6AdxMxiT851cEiugFB7ux1PAGn5eMmco8j32NsaKupxibheQGVFEqyEdjMub67VZjKmsLzuNxxKtUA",
    "regions": [{
        "region": 0,
        "cycles_summary": [
                "read_locks": [],
                "write_locks": [],
                "transactions": [{
                    "status": "executed",
                    "kcpu_usage": 2,
                    "net_usage_words": 38,
                    "id": "9880c128683e24845ccd282ebe026bd522f7fa9c6278d885f6ed35164c680669"
    "input_transactions": [],
    "id": "000000056d75b0581b4fbb96affa36669a37173d21f46f8cb974f760e94bbe14",
    "block_num": 5,
    "ref_block_prefix": 2528857883



I found a function tapos_block_num() in eosiolib/transaction.hpp. It looks return the block number in smart contract.

  • I think it returns the last block prior the current block, did you confirm? Jun 12 '18 at 0:47
  • 2
    Actually, it returns the block referenced by the transaction, which could be pretty old. tapos = Transaction As Proof Of Stake. Jun 17 '18 at 2:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.