address is full account address that consists of workchainID:address
acc_type
0 – uninit (Account has balance but no code)
1 – active (Account has balance and code)
2 – frozen(Account has been frozen for some reasons)
3 - nonExist (Account was deleted)
last_paid - unixtime of the most recent storage payment (happens each transaction execution)
balance - tokens on account (Note: to deploy smart contract code you need to have non-zero balance)
last_trans_lt - logical time of last account transaction
boc - Bag of cells with the account struct encoded as base64 (contains code, data, library and other header information).
data - bag of cells with the account's data
code - bag of cells with the account's code
library - If present, contains library code used in smart-contract.
data_hash - hash of account data
code_hash - hash of account code
library_hash - library field hash
Filter accounts
If you need to filter accounts by some condition and paginate them, use accounts collection.
Use id(account address) as cursor for pagination.
Paginate accounts having same code_hash:
Paginate accounts having same code_hash, updated after timestamp
Get a list of accounts
You can enumerate a list of account addresses to get their balances and other metadata.
You can not get the list of BOCs of accounts. Retrieve each account's BOC individually with this query.
Get transactions within timestamp range
Use-cases
Paginate transactions to get both transactions and messages of account within the required timestamp range
Collect account transactions with detailed fees information
Collect account balance history by pre-processing balance_delta changes on your side
Query new account transactions to trigger some logic on your side
Optionally filter transactions by Aborted type or balance_delta value
Pull transactions for a period if your websocket subscription failed (use lastTransaction.chain_order field as after cursor ;-) )
Filter parameters
You can filter account transactions by these parameters:
Pagination parameters
Use cursor, {first, after} or {last, before} filters for pagination.
We followed GraphQL best practices and implemented Relay Cursor Connections Specification for pagination for all list types. You can read more here https://relay.dev/graphql/connections.htm
Let's paginate some account transactions from the very first one:
Result
Use endCursor field for further pagination and hasNextPage for identifying if more records exist.
Get messages within timestamp range
Use-cases:
get transfers that some account sent or received
get account's events
get external calls of an account
get transfers between an account and some counterparty account
get account events to an external address
optionally filter messages by value amount
Pull messages for a period if your websocket subscription failed (use Message.chain_order field as after cursor ;-) )
In all these cases you need to paginate account messages with some filters applied. Lets see how to do it.
Filter parameters
You can filter messages by these parameters:
Pagination parameters
Use cursor, {first, after} or {last, before} filters for pagination.
We followed GraphQL best practices and implemented Relay Cursor Connections Specification for pagination for all list types. You can read more here https://relay.dev/graphql/connections.htm
Account transfers
Lets get first 2 transfers some account received or sent. So we need to get incoming and outcoming internal messages. We separated internal message type into 2 types: IntIn and IntOut for search convenience. This way it is possible also to get only deposits, and only withdrawals.
Result. We see that the next page exists, we can continue pagination.
Account events
To get account events, we need to get Account's external outbound message. Their type is ExtOut.Body field contains ABI-encoded information with Event data. You can parse it with SDK function abi.decode_message_body.
Result
Account external calls
If you want to collect external calls of an account, filter by msg_type = ExtIn. Body field contains ABI-encoded information with Event data. You can parse it with SDK function abi.decode_message_body. Lets get the last external call:
Result
Transfers between 2 accounts
In this example we retrieve last 30 messages between elector contract and some validator wallet with value more than some number:
Result:
We see that previous page exists and can continue pagination.
Subscribe for accounts state updates (soon)
You can subscribe for accounts metadata updates: balances or/and last_trans_lt, for example Whenever account is updated, you will receive its data:
Subscribe for accounts transactions (soon)
You can subscribe for transactions of a list of accounts
Subscribe for accounts messages (soon)
You can subscribe for messages of a list of accounts.
You can even subscribe only for external outbound messages, like here: