Querying Accumulate token account with Json RPC API
Getting the balance of a token account
Accumulate maintains the current state of all accounts. So querying an account, you receive the current state. Therefore, you can query the account for the current balance along with a receipt that you can use to prove the balance is authentic and current. Token accounts take two forms:
A Lite account, where you have one private key that manages an account similar to a bitcoin or Ethereum private key controlling the BTC or eth address.
An ADI token account, where you have a token account part of a user's Accumulate Digital Identifier domain. You can think of an ADI as an analogy to a traditional internet domain, e.g.,
example.com
The owner of an ADI can have sub-accounts within it, for example,acc://dennyb.acme/acmetokens
, whereacmetokens
is designated as the ACME token account.
Query a user's token account
For this example, the user's domain (ADI) is dennyb.acme
with a token account acme
, so the user's token account URL is acc://dennyb.acme/acme
. We also want to "prove" the balance state's validity, including the prove true parameter.
Example Query:
Example Response:
In the response, there is a lot of information; however, the key things to note are
the data parameter
the receipt.
The data parameter
The data field contains the details of the account state. For example, because acc://dennyb.acme/acme
is configured as an acme token account, it will show the token account state information, which includes the token balance, token type, and controlling key authorities of the account.
The parameters of the token are broken down in the following table:
Parameter
Value
Description
type
tokenAccount
Specifies the type of account this is. If you are only interested in tokens, then the types will be “tokenAccount” or “liteTokenAccount”
keyBook
acc://dennyb.acme/book
This is the url in the adi that manages the authroized keys
url
acc://dennyb.acme/acme
Url of this account
authorities
acc://dennyb.acme/book
The list of key books authorized to manage the account
tokenUrl
acc://acme
identifies what type of account this is, which for ACME tokens is the URL acc://acme
balance
100000000000
The acc://acme account contains the parameters of the token, which include the precision, which for acme is 8 decimal places. So this balance represents 1000.00000000 acme tokens
The receipt parameter
The receipt field contains the details needed to prove the state is genuine against a separate anchor. The general concept is the directory node publishes the anchor at predetermined intervals. These anchors contain the status of the entire state of the network up to that point. Given an anchor, one can prove the state of the account is valid by executing algorithms over the receipt. There is currently no endpoint API to facilitate this, so implementation is up to the user.
An example use case for this and implementation detail is outlined here.
Last updated