TON API

Making requests

Default query type is GET if otherwise was not specified. POST query should pass arguments as json objects.

The response contains a JSON object, which always has a boolean field 'ok' and may have an optional string field 'description' with a human-readable description of the result. If 'ok' equals true, the request was successful and the result of the query can be found in the 'result' field. In case of an unsuccessful request, 'ok' equals false and the error is explained in the 'description'.

All methods are available through jsonrpc endpoint localhost:8000/jsonRPC with `method` equal to method name and params passed as dictionary.

Examples

GET-request

localhost:8000/getAddressInformation?address=0QCyt4ltzak71h6XkyK4ePfZCzJQDSVUNuvZ3VE7hP_Q-GTE

POST-request

curl 'localhost:8000/estimateFeeCell' -H 'content-type: application/json' -d '{"address":"UQBPNn30w7DMPQmcJLPDltSSqu28MzHeV6_CvhjQdDDF64XH","body":{"data":{"b64":"+wnCxYB9Rfe4ooUtCq9hzpjqgSLHM4mdQR2YxENI4FHFAJ2wmz944/DOI/bc/YA2eFBPfmRK8rZnh3unf+1DBQAAAAkDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","len":552},"refs":[{"data":{"b64":"YgBrvXT8H560LJTGPY0wmQSJB2Lr7IzIIhfS155VEZaobJgknwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","len":408},"refs":[]}]}}'

JsonRPC-request

curl 'localhost:8000/jsonRPC' -H 'content-type: application/json' -d '{"id":1,"jsonrpc":"2.0","method":"estimateFeeCell","params":{"address":"UQBPNn30w7DMPQmcJLPDltSSqu28MzHeV6_CvhjQdDDF64XH","body":{"data":{"b64":"+wnCxYB9Rfe4ooUtCq9hzpjqgSLHM4mdQR2YxENI4FHFAJ2wmz944/DOI/bc/YA2eFBPfmRK8rZnh3unf+1DBQAAAAkDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","len":552},"refs":[{"data":{"b64":"YgBrvXT8H560LJTGPY0wmQSJB2Lr7IzIIhfS155VEZaobJgknwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","len":408},"refs":[]}]}}}'

getAddressInformation

Use this method to get information about address: balance, code, data, last_transaction_id.

Parameter Description
address Identifier of target account in TON

getExtendedAddressInformation

Similar to previous one but tries to parse additional information for known contract types. This method is based on generic.getAccountState thus number of recognizable contracts may grow. For wallets we recommend to use getWalletInformation.

Parameter Description
address Identifier of target account in TON

getWalletInformation

Use this method to retrieve wallet information, this method parse contract state and currently supports more wallet types than getExtendedAddressInformation: simple wallet, stadart wallet and v3 wallet.

Parameter Description
address Identifier of target account in TON

getTransactions

Use this method to get transaction history of a given address. Along with 'result', API may return 'previous_transaction' with 'lt' and 'hash' fields, if there are more transactions to see. Use them to get more transactions.

Parameter Required Description
address Yes Identifier of target account in TON
limit Optional
lt Optional Logical time of transaction to start with, must be sent with hash
hash Optional Hash of transaction to start with, must be sent with lt
to_lt Optional Logical time of transaction to finish with (that way it is possible to get tx from lt to to_lt)
archival Optional By default getTransaction request is processed by any available liteserver. If archival=1 only liteservers with full history are used

getAddressBalance

Use this method to get balance (in nanograms) of a given address.

Parameter Description
address Identifier of target account in TON

getAddressState

Use this method to get state of a given address. State can be either "unitialized", "active" or "frozen".

Parameter Description
address Identifier of target account in TON

unpackAddress

Use this method to convert an address from human-readable to raw format.

Parameter Description
address Identifier of target account in TON in human-readable format

packAddress

Use this method to convert an address from raw to human-readable format.

Parameter Description
address Identifier of target account in TON in raw format

detectAddress

Use this method to get all possible address forms

Parameter Description
address Identifier of target account in TON in raw format

sendBoc

POST method

Use this method to send serialized boc file: fully packed and serialized external message.

Parameter Description
boc b64 encoded bag of cells

sendCellSimple

POST method

Use this method to send cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}, that is fully packed but not serialized external message.

Parameter Description
cell Cell serialized as object

sendQuery

POST method

Use this method to send query: that is unpacked external message. This method get address, body and init-params(if any), pack it to external message and send to network. All params should be boc-serialized.

Parameter Description
address Address in any format
body b64-encoded boc-serialized cell with message body
init-code (optional) b64-encoded boc-serialized cell with init-code
init-data (optional) b64-encoded boc-serialized cell with init-data

sendQuerySimple

POST method

Use this method to send query: that is unpacked external message. This method get address, body and init-params(if any), pack it to external message and send to network. Body, init-code and init-data should be passed as objects.

Parameter Description
address Address in any format
body Body cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}
init-code (optional) init-code cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}
init-data (optional) init-data cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}

estimateFee

POST method

Use this method to to estimate fees required for query processing.

Parameter Description
address Address in any format
body b64-encoded cell with message body
init-code (optional) b64-encoded cell with init-code
init-data (optional) b64-encoded cell with init-data
ignore_chksig (optional, default True) Bool, if true during test query processing assume that all chksig operations return True

estimateFeeSimple

POST method

Use this method to estimate fees required for query processing (unserialized body, init-code and init-data)

Parameter Description
address Address in any format
body Body cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}
init-code (optional) init-code cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}
init-data (optional) init-data cell as object: {"data": {"b64": "...", "len": int }, "refs": [...subcells...]}
ignore_chksig (optional, default True) Bool, if true during test query processing assume that all chksig operations return True

runGetMethod

POST method

Use this method run getMethod

Parameter Description
address contract address
method method name or method id
stack Array of stack elements: [['num',3], ['cell', cell_object], ['slice', slice_object]]