near / core-contracts

Core contracts: reference staking pool, lockup, voting, whitelist, multisig.
327 stars 131 forks source link

Query for Near staked and locked balance. #233

Open shassal opened 1 month ago

shassal commented 1 month ago

Hi @nearprotocol-ci ,

I am using one API to get the balance and staked balance at a blockheight. But seems like on some other explorer it's different.

Query that i used:

curl --location 'https://archival-rpc.mainnet.near.org' \ --header 'Content-Type: application/json' \ --data '{ "jsonrpc": "2.0", "id": "dontcare", "method": "query", "params": { "request_type": "view_account", "block_id": 109422153, "account_id": "35b2e85e2e7add13abcd8ae62998cbfad9bad5bf.lockup.near" } }'

Here, i am passing the block_id as a param.

In the response, i can see the locked balance as 0.

{ "jsonrpc": "2.0", "result": { "amount": "3500361012273079800000000", "locked": "0", "code_hash": "4Pfw2RU6e35dUsHQQoFYfwX8KFFvSRNwMSNLXuSFHXrC", "storage_usage": 344792, "storage_paid_at": 0, "block_height": 109422153, "block_hash": "716ws7djkZtvseBLDUdvjPFND1y1NTbTr8EWEFP4bcbf" }, "id": "dontcare" }

Query 1: What is the difference between locked balance and staked balance.

Query 2: On the explorer, it shows https://near-staking.com/user/35b2e85e2e7add13abcd8ae62998cbfad9bad5bf.lockup.near, some staked balance.

Thanks, Saloni.

telezhnaya commented 1 month ago

Hey @shassal , Please have a look at https://github.com/near/core-contracts/tree/master/lockup

If you are the owner of the lockup, and you've never touched it before, consider calling this command https://github.com/near/core-contracts/tree/master/lockup#check-transfers-vote