When checking the balance of a wallet on the casper network, the wallet’s public_key_hex is the value used to identify the wallet (the network converts this to an account-hash and searches the account hash). If the wallet key provided is not the hex format of the public key, you may receive the following error:
{“code”:32003,”message”:”state query failed: ValueNotFound("Failed to find base key at path: Key::Account(…)")”}
This error can occur in a couple of different scenarios:
1) the wallet provided was not the public key in hex format
2) the wallet in question is not yet funded on the network (technically does not exist yet).
You can create a balance-checking shell script containing the commands:
PUBLIC_KEY_HEX=$(sudo -u casper cat /etc/casper/validator_keys/public_key_hex)
STATE_ROOT_HASH=$(casper-client get-state-root-hash --node-address http://127.0.0.1:7777 | jq -r '.result | .state_root_hash')
PURSE_UREF=$(sudo -u casper casper-client query-state --node-address http://127.0.0.1:7777 --key "$PUBLIC_KEY_HEX" --state-root-hash "$STATE_ROOT_HASH" | jq -r '.result | .stored_value | .Account | .main_purse')
casper-client get-balance --node-address http://127.0.0.1:7777 --purse-uref "$PURSE_UREF" --state-root-hash "$STATE_ROOT_HASH" | jq -r '.result | .balance_value'
A complete balance query command would be:
casper-client get-balance -n http://<NODE_IP_HERE>:7777 --purse-uref $PURSE_UREF --state-root-hash $STATE_ROOT_HASH | jq -r '.result.balance_value'
If you have any concerns, questions, or issues, please submit a request to our support team here:
https://support.casperlabs.io/hc/en-gb/requests/new
Comments
0 comments
Please sign in to leave a comment.