Note: With GraphQL API 1.0 migration by default Blockchain API provides account's transactions and messages for the past 7 days. For use cases where earlier data is needed make sure to use the archive: true flag in blockchain query filters. Account data itself is available in full and does not require archive flag.
Get account info
To get account info including BOC, data and code, use the following GraphQL query:
Paginate transactions to get both transactions and messages of account within the required masterchain seqno range - handy way to order data when you need to link it with seqno.
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 ;-) )
Blocks range
Use master_seq_no_range parameter to specify masterchain block sequence number range inside of which you will paginate transactions.
If you need to use time range instead of seq_no, you can convert time range to seq_no range like this:
query{ blockchain{ master_seq_no_range(time_start: 1647421084 time_end: 1647422084){ start end } }}
Filter parameters
You can filter account transactions by these parameters:
# Specify true, if you prefer minimum latency over consistency, besause # Evercloud API is eventually consistent.# In this case you need to periodically recheck the previous data within some time window# We suggest 5 minutes window to get any missed transactions.# Default is false which means the data is consistent but # latency may be over 10 seconds.allow_latest_inconsistent_data: Booleanaborted: Booleanmin_balance_delta: Stringmax_balance_delta: String
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:
query { blockchain{ account(address:"0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd"){ transactions(archive: true) { edges{ node{ hash in_message{ hash value body } out_messages{ hash value body } } } pageInfo{ endCursor hasNextPage } } } }}
Use endCursor field for further pagination and hasNextPage for identifying if more records exist.
Get transactions after/before lt
Sometimes you just need a simple pagination of transactions by logical time. This may be useful for contract developers, for debug, etc. This type of pagination can be used only for a single account transactions pagination.
query { blockchain{ account(address:"0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd"){ transactions_by_lt(after:"0x235ceea8c1", archive: true) { edges{ node{ id hash in_message{ id value body } out_messages{ id value body } lt } } pageInfo{ endCursor hasNextPage } } } }}
Here you see lt in hex was specified as after cursor.
See the result: endCursor for the page is equal to the last lt:
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.
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.
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:
You can subscribe for messages of a list of accounts.
You can even subscribe only for external outbound messages, like here:
subscription{ messages( filter:{src:{in:["-1:3333333333333333333333333333333333333333333333333333333333333333","0:557957cba74ab1dc544b4081be81f1208ad73997d74ab3b72d95864a41b779a4" ] }msg_type: {eq:2 } } ){ id msg_type src dst value }}
Get the list of account's counterparties
Returns the paginable list of accounts the account has ever interacted with, with the last message info attached, sorted by the last message time. Useful for applications that want to show a screen with dialog list sorted by the last interaction time.