24 |

TON API

25 |

Making requests

26 | 27 |

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

28 |

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'.

29 |

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

30 |

Examples

31 |

GET-request

32 |

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

33 |

POST-request

34 | 35 | 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":[]}]}}' 36 | 37 |

JsonRPC-request

38 | 39 | 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":[]}]}}}' 40 | 41 |
    42 |
43 | 44 |

getAddressInformation

45 |

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

46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
ParameterDescription
addressIdentifier of target account in TON
60 |

getExtendedAddressInformation

61 |

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.

62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
ParameterDescription
addressIdentifier of target account in TON
76 |

getWalletInformation

77 |

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.

78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |
ParameterDescription
addressIdentifier of target account in TON
92 |

getTransactions

93 |

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.

94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 |
ParameterRequiredDescription
addressYesIdentifier of target account in TON
limitOptional
ltOptionalLogical time of transaction to start with, must be sent with hash
hashOptionalHash of transaction to start with, must be sent with lt
to_ltOptionalLogical time of transaction to finish with (that way it is possible to get tx from lt to to_lt)
130 |

getAddressBalance

131 |

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

132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 |
ParameterDescription
addressIdentifier of target account in TON
146 |

getAddressState

147 |

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

148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 |
ParameterDescription
addressIdentifier of target account in TON
162 |

unpackAddress

163 |

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

164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |
ParameterDescription
addressIdentifier of target account in TON in human-readable format
178 |

packAddress

179 |

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

180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 |
ParameterDescription
addressIdentifier of target account in TON in raw format
194 | 195 |

detectAddress

196 |

Use this method to get all possible address forms

197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 |
ParameterDescription
addressIdentifier of target account in TON in raw format
211 | 212 |

sendBoc

213 |

POST method

214 |

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

215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 |
ParameterDescription
bocb64 encoded bag of cells
229 | 230 |

sendCellSimple

231 |

POST method

232 |

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

233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 |
ParameterDescription
cellCell serialized as object
247 | 248 |

sendQuery

249 |

POST method

250 |

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.

251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 |
ParameterDescription
addressAddress in any format
bodyb64-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
277 | 278 |

sendQuerySimple

279 |

POST method

280 |

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.

281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 |
ParameterDescription
addressAddress in any format
bodyBody 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...]}
307 | 308 |

estimateFee

309 |

POST method

310 |

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

311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 |
ParameterDescription
addressAddress in any format
bodyb64-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
341 | 342 | 343 |

estimateFeeSimple

344 |

POST method

345 |

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

346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 |
ParameterDescription
addressAddress in any format
bodyBody 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
376 | 377 | 378 |

runGetMethod

379 |

POST method

380 |

Use this method run getMethod

381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 |
ParameterDescription
addresscontract address
methodmethod name or method id
stackArray of stack elements: [['num',3], ['cell', cell_object], ['slice', slice_object]]
403 | 418 |