Network access.
query – Performs DAppServer GraphQL query.
batch_query – Performs multiple queries per single fetch.
query_collection – Queries collection data
aggregate_collection – Aggregates collection data.
wait_for_collection – Returns an object that fulfills the conditions or waits for its appearance
unsubscribe – Cancels a subscription
subscribe_collection – Creates a subscription
suspend – Suspends network module to stop any network activity
resume – Resumes network module to enable network activity
find_last_shard_block – Returns ID of the last block in a specified account shard
fetch_endpoints – Requests the list of alternative endpoints from server
set_endpoints – Sets the list of endpoints to use on reinit
get_endpoints – Requests the list of alternative endpoints from server
query_counterparties – Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts
query_transaction_tree – Returns a tree of transactions triggered by a specific message.
create_block_iterator – Creates block iterator.
resume_block_iterator – Resumes block iterator.
create_transaction_iterator – Creates transaction iterator.
resume_transaction_iterator – Resumes transaction iterator.
iterator_next – Returns next available items.
remove_iterator – Removes an iterator
ParamsOfCreateTransactionIterator
ParamsOfResumeTransactionIterator
Performs DAppServer GraphQL query.
type ParamsOfQuery = {
query: string,
variables?: any
}
type ResultOfQuery = {
result: any
}
function query(
params: ParamsOfQuery,
): Promise<ResultOfQuery>;
query
: string – GraphQL query text.variables
?: any – Variables used in query.
Must be a map with named values that can be used in query.
result
: any – Result provided by DAppServer.
Performs multiple queries per single fetch.
type ParamsOfBatchQuery = {
operations: ParamsOfQueryOperation[]
}
type ResultOfBatchQuery = {
results: any[]
}
function batch_query(
params: ParamsOfBatchQuery,
): Promise<ResultOfBatchQuery>;
operations
: ParamsOfQueryOperation[] – List of query operations that must be performed per single fetch.
results
: any[] – Result values for batched queries.
Returns an array of values. Each value corresponds toqueries
item.
Queries collection data
Queries data that satisfies the filter
conditions,
limits the number of returned records and orders them.
The projection fields are limited to result
fields
type ParamsOfQueryCollection = {
collection: string,
filter?: any,
result: string,
order?: OrderBy[],
limit?: number
}
type ResultOfQueryCollection = {
result: any[]
}
function query_collection(
params: ParamsOfQueryCollection,
): Promise<ResultOfQueryCollection>;
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringorder
?: OrderBy[] – Sorting orderlimit
?: number – Number of documents to return
result
: any[] – Objects that match the provided criteria
Aggregates collection data.
Aggregates values from the specified fields
for records
that satisfies the filter
conditions,
type ParamsOfAggregateCollection = {
collection: string,
filter?: any,
fields?: FieldAggregation[]
}
type ResultOfAggregateCollection = {
values: any
}
function aggregate_collection(
params: ParamsOfAggregateCollection,
): Promise<ResultOfAggregateCollection>;
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterfields
?: FieldAggregation[] – Projection (result) string
values
: any – Values for requested fields.
Returns an array of strings. Each string refers to the correspondingfields
item.
Numeric value is returned as a decimal string representations.
Returns an object that fulfills the conditions or waits for its appearance
Triggers only once.
If object that satisfies the filter
conditions
already exists - returns it immediately.
If not - waits for insert/update of data within the specified timeout
,
and returns it.
The projection fields are limited to result
fields
type ParamsOfWaitForCollection = {
collection: string,
filter?: any,
result: string,
timeout?: number
}
type ResultOfWaitForCollection = {
result: any
}
function wait_for_collection(
params: ParamsOfWaitForCollection,
): Promise<ResultOfWaitForCollection>;
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringtimeout
?: number – Query timeout
result
: any – First found object that matches the provided criteria
Cancels a subscription
Cancels a subscription specified by its handle.
type ResultOfSubscribeCollection = {
handle: number
}
function unsubscribe(
params: ResultOfSubscribeCollection,
): Promise<void>;
handle
: number – Subscription handle.
Must be closed withunsubscribe
Creates a subscription
Triggers for each insert/update of data that satisfies
the filter
conditions.
The projection fields are limited to result
fields.
The subscription is a persistent communication channel between client and Free TON Network. All changes in the blockchain will be reflected in realtime. Changes means inserts and updates of the blockchain entities.
Unfortunately sometimes the connection with the network brakes down. In this situation the library attempts to reconnect to the network. This reconnection sequence can take significant time. All of this time the client is disconnected from the network.
Bad news is that all blockchain changes that happened while the client was disconnected are lost.
Good news is that the client report errors to the callback when it loses and resumes connection.
So, if the lost changes are important to the application then the application must handle these error reports.
Library reports errors with responseType
== 101
and the error object passed via params
.
When the library has successfully reconnected
the application receives callback with
responseType
== 101 and params.code
== 614 (NetworkModuleResumed).
Application can use several ways to handle this situation:
- If application monitors changes for the single blockchain object (for example specific account): application can perform a query for this object and handle actual data as a regular data from the subscription.
- If application monitors sequence of some blockchain objects (for example transactions of the specific account): application must refresh all cached (or visible to user) lists where this sequences presents.
type ParamsOfSubscribeCollection = {
collection: string,
filter?: any,
result: string
}
type ResultOfSubscribeCollection = {
handle: number
}
function subscribe_collection(
params: ParamsOfSubscribeCollection,
responseHandler?: ResponseHandler,
): Promise<ResultOfSubscribeCollection>;
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringresponseHandler
?: ResponseHandler – additional responses handler.
handle
: number – Subscription handle.
Must be closed withunsubscribe
Suspends network module to stop any network activity
function suspend(): Promise<void>;
Resumes network module to enable network activity
function resume(): Promise<void>;
Returns ID of the last block in a specified account shard
type ParamsOfFindLastShardBlock = {
address: string
}
type ResultOfFindLastShardBlock = {
block_id: string
}
function find_last_shard_block(
params: ParamsOfFindLastShardBlock,
): Promise<ResultOfFindLastShardBlock>;
address
: string – Account address
block_id
: string – Account shard last block ID
Requests the list of alternative endpoints from server
type EndpointsSet = {
endpoints: string[]
}
function fetch_endpoints(): Promise<EndpointsSet>;
endpoints
: string[] – List of endpoints provided by server
Sets the list of endpoints to use on reinit
type EndpointsSet = {
endpoints: string[]
}
function set_endpoints(
params: EndpointsSet,
): Promise<void>;
endpoints
: string[] – List of endpoints provided by server
Requests the list of alternative endpoints from server
type ResultOfGetEndpoints = {
query: string,
endpoints: string[]
}
function get_endpoints(): Promise<ResultOfGetEndpoints>;
query
: string – Current query endpointendpoints
: string[] – List of all endpoints used by client
Allows to query and paginate through the list of accounts that the specified account has interacted with, sorted by the time of the last internal message between accounts
Attention this query retrieves data from 'Counterparties' service which is not supported in the opensource version of DApp Server (and will not be supported) as well as in TON OS SE (will be supported in SE in future), but is always accessible via TON OS Devnet/Mainnet Clouds
type ParamsOfQueryCounterparties = {
account: string,
result: string,
first?: number,
after?: string
}
type ResultOfQueryCollection = {
result: any[]
}
function query_counterparties(
params: ParamsOfQueryCounterparties,
): Promise<ResultOfQueryCollection>;
account
: string – Account addressresult
: string – Projection (result) stringfirst
?: number – Number of counterparties to returnafter
?: string –cursor
field of the last received result
result
: any[] – Objects that match the provided criteria
Returns a tree of transactions triggered by a specific message.
Performs recursive retrieval of a transactions tree produced by a specific message: in_msg -> dst_transaction -> out_messages -> dst_transaction -> ... If the chain of transactions execution is in progress while the function is running, it will wait for the next transactions to appear until the full tree or more than 50 transactions are received.
All the retrieved messages and transactions are included
into result.messages
and result.transactions
respectively.
Function reads transactions layer by layer, by pages of 20 transactions.
The retrieval prosess goes like this: Let's assume we have an infinite chain of transactions and each transaction generates 5 messages.
- Retrieve 1st message (input parameter) and corresponding transaction - put it into result. It is the first level of the tree of transactions - its root. Retrieve 5 out message ids from the transaction for next steps.
- Retrieve 5 messages and corresponding transactions on the 2nd layer. Put them into result. Retrieve 5*5 out message ids from these transactions for next steps
- Retrieve 20 (size of the page) messages and transactions (3rd layer) and 20*5=100 message ids (4th layer).
- Retrieve the last 5 messages and 5 transactions on the 3rd layer + 15 messages and transactions (of 100) from the 4th layer
- 25 message ids of the 4th layer + 75 message ids of the 5th layer.
- Retrieve 20 more messages and 20 more transactions of the 4th layer + 100 more message ids of the 5th layer.
- Now we have 1+5+20+20+20 = 66 transactions, which is more than 50. Function exits with the tree of 1m->1t->5m->5t->25m->25t->35m->35t. If we see any message ids in the last transactions out_msgs, which don't have corresponding messages in the function result, it means that the full tree was not received and we need to continue iteration.
To summarize, it is guaranteed that each message in result.messages
has the corresponding transaction
in the result.transactions
.
But there is no guarantee that all messages from transactions out_msgs
are
presented in result.messages
.
So the application has to continue retrieval for missing messages if it requires.
type ParamsOfQueryTransactionTree = {
in_msg: string,
abi_registry?: Abi[],
timeout?: number
}
type ResultOfQueryTransactionTree = {
messages: MessageNode[],
transactions: TransactionNode[]
}
function query_transaction_tree(
params: ParamsOfQueryTransactionTree,
): Promise<ResultOfQueryTransactionTree>;
in_msg
: string – Input message id.abi_registry
?: Abi[] – List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry.timeout
?: number – Timeout used to limit waiting time for the missing messages and transaction.
If some of the following messages and transactions are missing yet
The maximum waiting time is regulated by this option.
Default value is 60000 (1 min).
messages
: MessageNode[] – Messages.transactions
: TransactionNode[] – Transactions.
Creates block iterator.
Block iterator uses robust iteration methods that guaranties that every block in the specified range isn't missed or iterated twice.
Iterated range can be reduced with some filters:
start_time
– the bottom time range. Only blocks withgen_utime
more or equal to this value is iterated. If this parameter is omitted then there is no bottom time edge, so all blocks since zero state is iterated.end_time
– the upper time range. Only blocks withgen_utime
less then this value is iterated. If this parameter is omitted then there is no upper time edge, so iterator never finishes.shard_filter
– workchains and shard prefixes that reduce the set of interesting blocks. Block conforms to the shard filter if it belongs to the filter workchain and the first bits of block'sshard
fields matches to the shard prefix. Only blocks with suitable shard are iterated.
Items iterated is a JSON objects with block data. The minimal set of returned fields is:
id
gen_utime
workchain_id
shard
after_split
after_merge
prev_ref {
root_hash
}
prev_alt_ref {
root_hash
}
Application can request additional fields in the result
parameter.
Application should call the remove_iterator
when iterator is no longer required.
type ParamsOfCreateBlockIterator = {
start_time?: number,
end_time?: number,
shard_filter?: string[],
result?: string
}
type RegisteredIterator = {
handle: number
}
function create_block_iterator(
params: ParamsOfCreateBlockIterator,
): Promise<RegisteredIterator>;
start_time
?: number – Starting time to iterate from.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
>=start_time
.
Otherwise the iteration starts from zero state.
Must be specified in seconds.end_time
?: number – Optional end time to iterate for.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
<end_time
.
Otherwise the iteration never stops.
Must be specified in seconds.shard_filter
?: string[] – Shard prefix filter.
If the application specifies this parameter and it is not the empty array
then the iteration will include items related to accounts that belongs to
the specified shard prefixes.
Shard prefix must be represented as a string "workchain:prefix".
Whereworkchain
is a signed integer and theprefix
if a hexadecimal
representation if the 64-bit unsigned integer with tagged shard prefix.
For example: "0:3800000000000000".result
?: string – Projection (result) string.
List of the fields that must be returned for iterated items.
This field is the same as theresult
parameter of
thequery_collection
function.
Note that iterated items can contains additional fields that are
not requested in theresult
.
handle
: number – Iterator handle.
Must be removed usingremove_iterator
when it is no more needed for the application.
Resumes block iterator.
The iterator stays exactly at the same position where the resume_state
was catched.
Application should call the remove_iterator
when iterator is no longer required.
type ParamsOfResumeBlockIterator = {
resume_state: any
}
type RegisteredIterator = {
handle: number
}
function resume_block_iterator(
params: ParamsOfResumeBlockIterator,
): Promise<RegisteredIterator>;
resume_state
: any – Iterator state from which to resume.
Same as value returned fromiterator_next
.
handle
: number – Iterator handle.
Must be removed usingremove_iterator
when it is no more needed for the application.
Creates transaction iterator.
Transaction iterator uses robust iteration methods that guaranty that every transaction in the specified range isn't missed or iterated twice.
Iterated range can be reduced with some filters:
start_time
– the bottom time range. Only transactions withnow
more or equal to this value are iterated. If this parameter is omitted then there is no bottom time edge, so all the transactions since zero state are iterated.end_time
– the upper time range. Only transactions withnow
less then this value are iterated. If this parameter is omitted then there is no upper time edge, so iterator never finishes.shard_filter
– workchains and shard prefixes that reduce the set of interesting accounts. Account address conforms to the shard filter if it belongs to the filter workchain and the first bits of address match to the shard prefix. Only transactions with suitable account addresses are iterated.accounts_filter
– set of account addresses whose transactions must be iterated. Note that accounts filter can conflict with shard filter so application must combine these filters carefully.
Iterated item is a JSON objects with transaction data. The minimal set of returned fields is:
id
account_addr
now
balance_delta(format:DEC)
bounce { bounce_type }
in_message {
id
value(format:DEC)
msg_type
src
}
out_messages {
id
value(format:DEC)
msg_type
dst
}
Application can request an additional fields in the result
parameter.
Another parameter that affects on the returned fields is the include_transfers
.
When this parameter is true
the iterator computes and adds transfer
field containing
list of the useful TransactionTransfer
objects.
Each transfer is calculated from the particular message related to the transaction
and has the following structure:
- message – source message identifier.
- isBounced – indicates that the transaction is bounced, which means the value will be returned back to the sender.
- isDeposit – indicates that this transfer is the deposit (true) or withdraw (false).
- counterparty – account address of the transfer source or destination depending on
isDeposit
. - value – amount of nano tokens transferred. The value is represented as a decimal string because the actual value can be more precise than the JSON number can represent. Application must use this string carefully – conversion to number can follow to loose of precision.
Application should call the remove_iterator
when iterator is no longer required.
type ParamsOfCreateTransactionIterator = {
start_time?: number,
end_time?: number,
shard_filter?: string[],
accounts_filter?: string[],
result?: string,
include_transfers?: boolean
}
type RegisteredIterator = {
handle: number
}
function create_transaction_iterator(
params: ParamsOfCreateTransactionIterator,
): Promise<RegisteredIterator>;
start_time
?: number – Starting time to iterate from.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
>=start_time
.
Otherwise the iteration starts from zero state.
Must be specified in seconds.end_time
?: number – Optional end time to iterate for.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
<end_time
.
Otherwise the iteration never stops.
Must be specified in seconds.shard_filter
?: string[] – Shard prefix filters.
If the application specifies this parameter and it is not an empty array
then the iteration will include items related to accounts that belongs to
the specified shard prefixes.
Shard prefix must be represented as a string "workchain:prefix".
Whereworkchain
is a signed integer and theprefix
if a hexadecimal
representation if the 64-bit unsigned integer with tagged shard prefix.
For example: "0:3800000000000000".
Account address conforms to the shard filter if
it belongs to the filter workchain and the first bits of address match to
the shard prefix. Only transactions with suitable account addresses are iterated.accounts_filter
?: string[] – Account address filter.
Application can specify the list of accounts for which
it wants to iterate transactions.
If this parameter is missing or an empty list then the library iterates
transactions for all accounts that pass the shard filter.
Note that the library doesn't detect conflicts between the account filter and the shard filter
if both are specified.
So it is an application responsibility to specify the correct filter combination.result
?: string – Projection (result) string.
List of the fields that must be returned for iterated items.
This field is the same as theresult
parameter of
thequery_collection
function.
Note that iterated items can contain additional fields that are
not requested in theresult
.include_transfers
?: boolean – Includetransfers
field in iterated transactions.
If this parameter istrue
then each transaction contains fieldtransfers
with list of transfer. See more about this structure in function description.
handle
: number – Iterator handle.
Must be removed usingremove_iterator
when it is no more needed for the application.
Resumes transaction iterator.
The iterator stays exactly at the same position where the resume_state
was caught.
Note that resume_state
doesn't store the account filter. If the application requires
to use the same account filter as it was when the iterator was created then the application
must pass the account filter again in accounts_filter
parameter.
Application should call the remove_iterator
when iterator is no longer required.
type ParamsOfResumeTransactionIterator = {
resume_state: any,
accounts_filter?: string[]
}
type RegisteredIterator = {
handle: number
}
function resume_transaction_iterator(
params: ParamsOfResumeTransactionIterator,
): Promise<RegisteredIterator>;
resume_state
: any – Iterator state from which to resume.
Same as value returned fromiterator_next
.accounts_filter
?: string[] – Account address filter.
Application can specify the list of accounts for which
it wants to iterate transactions.
If this parameter is missing or an empty list then the library iterates
transactions for all accounts that passes the shard filter.
Note that the library doesn't detect conflicts between the account filter and the shard filter
if both are specified.
So it is the application's responsibility to specify the correct filter combination.
handle
: number – Iterator handle.
Must be removed usingremove_iterator
when it is no more needed for the application.
Returns next available items.
In addition to available items this function returns the has_more
flag
indicating that the iterator isn't reach the end of the iterated range yet.
This function can return the empty list of available items but indicates that there are more items is available. This situation appears when the iterator doesn't reach iterated range but database doesn't contains available items yet.
If application requests resume state in return_resume_state
parameter
then this function returns resume_state
that can be used later to
resume the iteration from the position after returned items.
The structure of the items returned depends on the iterator used. See the description to the appropriated iterator creation function.
type ParamsOfIteratorNext = {
iterator: number,
limit?: number,
return_resume_state?: boolean
}
type ResultOfIteratorNext = {
items: any[],
has_more: boolean,
resume_state?: any
}
function iterator_next(
params: ParamsOfIteratorNext,
): Promise<ResultOfIteratorNext>;
iterator
: number – Iterator handlelimit
?: number – Maximum count of the returned items.
If value is missing or is less than 1 the library uses 1.return_resume_state
?: boolean – Indicates that function must return the iterator state that can be used for resuming iteration.
items
: any[] – Next available items.
Note thatiterator_next
can return an empty items andhas_more
equals totrue
.
In this case the application have to continue iteration.
Such situation can take place when there is no data yet but
the requestedend_time
is not reached.has_more
: boolean – Indicates that there are more available items in iterated range.resume_state
?: any – Optional iterator state that can be used for resuming iteration.
This field is returned only if thereturn_resume_state
parameter
is specified.
Note thatresume_state
corresponds to the iteration position
after the returned items.
Removes an iterator
Frees all resources allocated in library to serve iterator.
Application always should call the remove_iterator
when iterator
is no longer required.
type RegisteredIterator = {
handle: number
}
function remove_iterator(
params: RegisteredIterator,
): Promise<void>;
handle
: number – Iterator handle.
Must be removed usingremove_iterator
when it is no more needed for the application.
enum NetErrorCode {
QueryFailed = 601,
SubscribeFailed = 602,
WaitForFailed = 603,
GetSubscriptionResultFailed = 604,
InvalidServerResponse = 605,
ClockOutOfSync = 606,
WaitForTimeout = 607,
GraphqlError = 608,
NetworkModuleSuspended = 609,
WebsocketDisconnected = 610,
NotSupported = 611,
NoEndpointsProvided = 612,
GraphqlWebsocketInitError = 613,
NetworkModuleResumed = 614
}
One of the following value:
QueryFailed = 601
SubscribeFailed = 602
WaitForFailed = 603
GetSubscriptionResultFailed = 604
InvalidServerResponse = 605
ClockOutOfSync = 606
WaitForTimeout = 607
GraphqlError = 608
NetworkModuleSuspended = 609
WebsocketDisconnected = 610
NotSupported = 611
NoEndpointsProvided = 612
GraphqlWebsocketInitError = 613
NetworkModuleResumed = 614
type OrderBy = {
path: string,
direction: SortDirection
}
path
: stringdirection
: SortDirection
enum SortDirection {
ASC = "ASC",
DESC = "DESC"
}
One of the following value:
ASC = "ASC"
DESC = "DESC"
type ParamsOfQueryOperation = ({
type: 'QueryCollection'
} & ParamsOfQueryCollection) | ({
type: 'WaitForCollection'
} & ParamsOfWaitForCollection) | ({
type: 'AggregateCollection'
} & ParamsOfAggregateCollection) | ({
type: 'QueryCounterparties'
} & ParamsOfQueryCounterparties)
Depends on value of the type
field.
When type is 'QueryCollection'
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringorder
?: OrderBy[] – Sorting orderlimit
?: number – Number of documents to return
When type is 'WaitForCollection'
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringtimeout
?: number – Query timeout
When type is 'AggregateCollection'
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterfields
?: FieldAggregation[] – Projection (result) string
When type is 'QueryCounterparties'
account
: string – Account addressresult
: string – Projection (result) stringfirst
?: number – Number of counterparties to returnafter
?: string –cursor
field of the last received result
Variant constructors:
function paramsOfQueryOperationQueryCollection(params: ParamsOfQueryCollection): ParamsOfQueryOperation;
function paramsOfQueryOperationWaitForCollection(params: ParamsOfWaitForCollection): ParamsOfQueryOperation;
function paramsOfQueryOperationAggregateCollection(params: ParamsOfAggregateCollection): ParamsOfQueryOperation;
function paramsOfQueryOperationQueryCounterparties(params: ParamsOfQueryCounterparties): ParamsOfQueryOperation;
type FieldAggregation = {
field: string,
fn: AggregationFn
}
field
: string – Dot separated path to the fieldfn
: AggregationFn – Aggregation function that must be applied to field values
enum AggregationFn {
COUNT = "COUNT",
MIN = "MIN",
MAX = "MAX",
SUM = "SUM",
AVERAGE = "AVERAGE"
}
One of the following value:
COUNT = "COUNT"
– Returns count of filtered recordMIN = "MIN"
– Returns the minimal value for a field in filtered recordsMAX = "MAX"
– Returns the maximal value for a field in filtered recordsSUM = "SUM"
– Returns a sum of values for a field in filtered recordsAVERAGE = "AVERAGE"
– Returns an average value for a field in filtered records
type TransactionNode = {
id: string,
in_msg: string,
out_msgs: string[],
account_addr: string,
total_fees: string,
aborted: boolean,
exit_code?: number
}
id
: string – Transaction id.in_msg
: string – In message id.out_msgs
: string[] – Out message ids.account_addr
: string – Account address.total_fees
: string – Transactions total fees.aborted
: boolean – Aborted flag.exit_code
?: number – Compute phase exit code.
type MessageNode = {
id: string,
src_transaction_id?: string,
dst_transaction_id?: string,
src?: string,
dst?: string,
value?: string,
bounce: boolean,
decoded_body?: DecodedMessageBody
}
id
: string – Message id.src_transaction_id
?: string – Source transaction id.
This field is missing for an external inbound messages.dst_transaction_id
?: string – Destination transaction id.
This field is missing for an external outbound messages.src
?: string – Source address.dst
?: string – Destination address.value
?: string – Transferred tokens value.bounce
: boolean – Bounce flag.decoded_body
?: DecodedMessageBody – Decoded body.
Library tries to decode message body using providedparams.abi_registry
.
This field will be missing if none of the provided abi can be used to decode.
type ParamsOfQuery = {
query: string,
variables?: any
}
query
: string – GraphQL query text.variables
?: any – Variables used in query.
Must be a map with named values that can be used in query.
type ResultOfQuery = {
result: any
}
result
: any – Result provided by DAppServer.
type ParamsOfBatchQuery = {
operations: ParamsOfQueryOperation[]
}
operations
: ParamsOfQueryOperation[] – List of query operations that must be performed per single fetch.
type ResultOfBatchQuery = {
results: any[]
}
results
: any[] – Result values for batched queries.
Returns an array of values. Each value corresponds toqueries
item.
type ParamsOfQueryCollection = {
collection: string,
filter?: any,
result: string,
order?: OrderBy[],
limit?: number
}
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringorder
?: OrderBy[] – Sorting orderlimit
?: number – Number of documents to return
type ResultOfQueryCollection = {
result: any[]
}
result
: any[] – Objects that match the provided criteria
type ParamsOfAggregateCollection = {
collection: string,
filter?: any,
fields?: FieldAggregation[]
}
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterfields
?: FieldAggregation[] – Projection (result) string
type ResultOfAggregateCollection = {
values: any
}
values
: any – Values for requested fields.
Returns an array of strings. Each string refers to the correspondingfields
item.
Numeric value is returned as a decimal string representations.
type ParamsOfWaitForCollection = {
collection: string,
filter?: any,
result: string,
timeout?: number
}
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) stringtimeout
?: number – Query timeout
type ResultOfWaitForCollection = {
result: any
}
result
: any – First found object that matches the provided criteria
type ResultOfSubscribeCollection = {
handle: number
}
handle
: number – Subscription handle.
Must be closed withunsubscribe
type ParamsOfSubscribeCollection = {
collection: string,
filter?: any,
result: string
}
collection
: string – Collection name (accounts, blocks, transactions, messages, block_signatures)filter
?: any – Collection filterresult
: string – Projection (result) string
type ParamsOfFindLastShardBlock = {
address: string
}
address
: string – Account address
type ResultOfFindLastShardBlock = {
block_id: string
}
block_id
: string – Account shard last block ID
type EndpointsSet = {
endpoints: string[]
}
endpoints
: string[] – List of endpoints provided by server
type ResultOfGetEndpoints = {
query: string,
endpoints: string[]
}
query
: string – Current query endpointendpoints
: string[] – List of all endpoints used by client
type ParamsOfQueryCounterparties = {
account: string,
result: string,
first?: number,
after?: string
}
account
: string – Account addressresult
: string – Projection (result) stringfirst
?: number – Number of counterparties to returnafter
?: string –cursor
field of the last received result
type ParamsOfQueryTransactionTree = {
in_msg: string,
abi_registry?: Abi[],
timeout?: number
}
in_msg
: string – Input message id.abi_registry
?: Abi[] – List of contract ABIs that will be used to decode message bodies. Library will try to decode each returned message body using any ABI from the registry.timeout
?: number – Timeout used to limit waiting time for the missing messages and transaction.
If some of the following messages and transactions are missing yet
The maximum waiting time is regulated by this option.
Default value is 60000 (1 min).
type ResultOfQueryTransactionTree = {
messages: MessageNode[],
transactions: TransactionNode[]
}
messages
: MessageNode[] – Messages.transactions
: TransactionNode[] – Transactions.
type ParamsOfCreateBlockIterator = {
start_time?: number,
end_time?: number,
shard_filter?: string[],
result?: string
}
start_time
?: number – Starting time to iterate from.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
>=start_time
.
Otherwise the iteration starts from zero state.
Must be specified in seconds.end_time
?: number – Optional end time to iterate for.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
<end_time
.
Otherwise the iteration never stops.
Must be specified in seconds.shard_filter
?: string[] – Shard prefix filter.
If the application specifies this parameter and it is not the empty array
then the iteration will include items related to accounts that belongs to
the specified shard prefixes.
Shard prefix must be represented as a string "workchain:prefix".
Whereworkchain
is a signed integer and theprefix
if a hexadecimal
representation if the 64-bit unsigned integer with tagged shard prefix.
For example: "0:3800000000000000".result
?: string – Projection (result) string.
List of the fields that must be returned for iterated items.
This field is the same as theresult
parameter of
thequery_collection
function.
Note that iterated items can contains additional fields that are
not requested in theresult
.
type RegisteredIterator = {
handle: number
}
handle
: number – Iterator handle.
Must be removed usingremove_iterator
when it is no more needed for the application.
type ParamsOfResumeBlockIterator = {
resume_state: any
}
resume_state
: any – Iterator state from which to resume.
Same as value returned fromiterator_next
.
type ParamsOfCreateTransactionIterator = {
start_time?: number,
end_time?: number,
shard_filter?: string[],
accounts_filter?: string[],
result?: string,
include_transfers?: boolean
}
start_time
?: number – Starting time to iterate from.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
>=start_time
.
Otherwise the iteration starts from zero state.
Must be specified in seconds.end_time
?: number – Optional end time to iterate for.
If the application specifies this parameter then the iteration
includes blocks withgen_utime
<end_time
.
Otherwise the iteration never stops.
Must be specified in seconds.shard_filter
?: string[] – Shard prefix filters.
If the application specifies this parameter and it is not an empty array
then the iteration will include items related to accounts that belongs to
the specified shard prefixes.
Shard prefix must be represented as a string "workchain:prefix".
Whereworkchain
is a signed integer and theprefix
if a hexadecimal
representation if the 64-bit unsigned integer with tagged shard prefix.
For example: "0:3800000000000000".
Account address conforms to the shard filter if
it belongs to the filter workchain and the first bits of address match to
the shard prefix. Only transactions with suitable account addresses are iterated.accounts_filter
?: string[] – Account address filter.
Application can specify the list of accounts for which
it wants to iterate transactions.
If this parameter is missing or an empty list then the library iterates
transactions for all accounts that pass the shard filter.
Note that the library doesn't detect conflicts between the account filter and the shard filter
if both are specified.
So it is an application responsibility to specify the correct filter combination.result
?: string – Projection (result) string.
List of the fields that must be returned for iterated items.
This field is the same as theresult
parameter of
thequery_collection
function.
Note that iterated items can contain additional fields that are
not requested in theresult
.include_transfers
?: boolean – Includetransfers
field in iterated transactions.
If this parameter istrue
then each transaction contains fieldtransfers
with list of transfer. See more about this structure in function description.
type ParamsOfResumeTransactionIterator = {
resume_state: any,
accounts_filter?: string[]
}
resume_state
: any – Iterator state from which to resume.
Same as value returned fromiterator_next
.accounts_filter
?: string[] – Account address filter.
Application can specify the list of accounts for which
it wants to iterate transactions.
If this parameter is missing or an empty list then the library iterates
transactions for all accounts that passes the shard filter.
Note that the library doesn't detect conflicts between the account filter and the shard filter
if both are specified.
So it is the application's responsibility to specify the correct filter combination.
type ParamsOfIteratorNext = {
iterator: number,
limit?: number,
return_resume_state?: boolean
}
iterator
: number – Iterator handlelimit
?: number – Maximum count of the returned items.
If value is missing or is less than 1 the library uses 1.return_resume_state
?: boolean – Indicates that function must return the iterator state that can be used for resuming iteration.
type ResultOfIteratorNext = {
items: any[],
has_more: boolean,
resume_state?: any
}
items
: any[] – Next available items.
Note thatiterator_next
can return an empty items andhas_more
equals totrue
.
In this case the application have to continue iteration.
Such situation can take place when there is no data yet but
the requestedend_time
is not reached.has_more
: boolean – Indicates that there are more available items in iterated range.resume_state
?: any – Optional iterator state that can be used for resuming iteration.
This field is returned only if thereturn_resume_state
parameter
is specified.
Note thatresume_state
corresponds to the iteration position
after the returned items.