How can I view all data stored by a NEAR account?

478 views Asked by At

I know from https://github.com/near/near-cli#overview that I can call near state to view general details of an account, like this:

NEAR_ENV=mainnet near state root.near            
Account root.near
{
  amount: '517981340092537993206924239',
  block_hash: '6A4vsQqTjdQgKnWrHVURycSmehBMgtgg4GNemmjZUB6S',
  block_height: 64959783,
  code_hash: '11111111111111111111111111111111',
  locked: '0',
  storage_paid_at: 0,
  storage_usage: 13899,
  formattedAmount: '517.981340092537993206924239'
}

And I know that I can browse on the web at https://explorer.near.org/accounts/root.near

But how can I explore (either via a website or CLI) the contents of all of the on-chain data in an account's storage?

1

There are 1 answers

3
Benjamin Kurrek On BEST ANSWER

You can use the CLI's view-state command. An example of this could be:

  1. export NEAR_ENV=mainnet
  2. near view-state nft.nearvember-challenge.near --finality final

This will return key value pairs that are base64 encoded. You can loop through and decode these as you wish. For example, one of the key value pairs returned from this call is:

{
    key: 'A3YkAAAAAAAAAA==',
    value: 'ARgAAABORUFSdmVtYmVyIENoYWxsZW5nZSBORlQBNwAAAHRoYW5rIHlvdSBmb3IgcGFydGljaXBhdGluZyBpbiB0aGUgbmVhcnZlbWJlciBjaGFsbGVuZ2UBTwAAAGh0dHBzOi8vY2xvdWRmbGFyZS1pcGZzLmNvbS9pcGZzL1FtUEt6WnFIdnY1c2VCQ3hIdW5nNFpLRFlHS2QxOFozSzRmWWtHeTJTMjFOQVoAAWQAAAAAAAAAAAAAAAAAAA=='
  },

which, if base64 decoded, has a value of

NEARvember Challenge NFT7thank you for participating in the nearvember challengeOhttps://cloudflare-ipfs.com/ipfs/QmPKzZqHvv5seBCxHung4ZKDYGKd18Z3K4fYkGy2S21NAZd

Keep in mind that the CLI will only return state that's below a certain threshold. If the account's state is too large, it won't be viewable unless you configure and run your own node.