Account queries

Get account info

To get account info including its state (BOC), data and code, use the following GraphQL query:

query {
  blockchain{
   account(address:"0:653b9a6452c7a982c6dc92b2da9eba832ade1c467699ebb3b43dca6d77b780dd"){
    info{
      address
      acc_type
      balance
      last_paid
      last_trans_lt
      boc
      data
      code
      library
      data_hash
      code_hash
      library_hash
    }
  }
  }
}

Result:

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.

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.

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 run this query.

Result

Then, by decoding the `body` of that message you can obtain the data attached to the event. You can parse it with SDK function abi.decode_message_body or use tvm-cli comand: For example:

As a result, you will get something approximately like this:

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

Last updated