1

How to query NEAR node block height by near-cli? I didn't find it on https://docs.near.org/docs/tools/near-cli

Jonkrua wu
  • 11
  • 1

1 Answers1

0

You can use near repl which launches interactive Node.js shell with NEAR connection available to use. The repl's initial context contains nearAPI, near and account (source: near-cli --help)

shell:

$> near repl
> let response = await near.connection.provider.block({finality: "final"})
> response

the response will give you a bunch of info, height among other things. Or you can go with

> response.header.height

and you'll get only the value of the height field

Cheslab
  • 1,896
  • 2
  • 17
  • 27