Search code examples
nearprotocol

How to get near balance of an account using cli?


Is it possible to get near balance of an account using near cli.?


Solution

  • Running:

    near state <account.near>
    

    should do the trick:

    Account account.near
    {
      amount: 'XXXXXX',
      locked: '0',
      code_hash: 'XXXX',
      storage_usage: XX,
      storage_paid_at: 0,
      block_height: XXX,
      block_hash: 'XXXX',
      formattedAmount: 'XXXX'
    }
    

    or even:

    near state account.near |  sed -n "s/.*formattedAmount: '\([^\\]*\).*'/\1/p"
    

    if you just need the formattedAmount:

    XYZ.39429240342