github.com/lino-network/lino@v0.6.11/docs/cli/json_rpc.md (about) 1 * [JSON RPC API](#JSON-RPC-API) 2 * [JavaScript API](#JavaScript-API) 3 * [JSON-RPC Endpoint](#JSON-RPC-Endpoint) 4 * [JSON-RPC API Reference](#JSON-RPC-API-Reference) 5 * [Blockchain Status](#Blockchain-Status) 6 * [Block Info](#Block-Info) 7 * [Tx Info](#Tx-Info) 8 * [Account Info](#Account-Info) 9 * [Account Bank](#Account-Bank) 10 * [Post Info](#Post-Info) 11 * [Stake Info](#Stake-Info) 12 * [Validator Info](#Validator-Info) 13 14 # JSON RPC API 15 ## JavaScript API 16 To talk to an Lino node from inside a JavaScript application use the [lino-js](https://github.com/lino-network/lino-js) library, which gives a convenient interface for the RPC methods. See the [lino-js](https://github.com/lino-network/lino-js) library for more. 17 18 ## JSON-RPC Endpoint 19 Default JSON-RPC endpoints: https://fullnode.lino.network/ 20 21 ## JSON-RPC API Reference 22 ### Blockchain Status 23 Returns current blockchain status. Including fullnode information and sync info. 24 25 #### Parameters 26 none 27 28 #### Returns 29 String - Current blockchain status. 30 31 #### Example 32 ``` 33 // Request 34 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"status"}' "https://fullnode.lino.network" 35 36 // Result 37 { 38 "jsonrpc": "2.0", 39 "id": "", 40 "result": { 41 "node_info": { 42 "protocol_version": { 43 "p2p": "7", 44 "block": "10", 45 "app": "0" 46 }, 47 "id": "58f7c3e342647155a3c2b3635807f6890be33af2", 48 "listen_addr": "tcp://0.0.0.0:26656", 49 "network": "lino-testnet-upgrade2", 50 "version": "0.32.2", 51 "channels": "40202122233038", 52 "moniker": "73pEAeSPBCAD", 53 "other": { 54 "tx_index": "on", 55 "rpc_address": "tcp://0.0.0.0:26657" 56 } 57 }, 58 "sync_info": { 59 "latest_block_hash": "C4B541D9019E87CCAB7A643BC9802BA249404776D234874FC33A3CD6862234B2", 60 "latest_app_hash": "562CC637AF432F540C5215AEFCC12E9294CDF99E3988D708E14CA0601321302C", 61 "latest_block_height": "237594", 62 "latest_block_time": "2019-09-29T23:53:57.207992926Z", 63 "catching_up": false 64 }, 65 "validator_info": { 66 "address": "852FB8F81F013BC350C8EDF34AFAAFFE8F6F77BC", 67 "pub_key": { 68 "type": "tendermint/PubKeyEd25519", 69 "value": "E5sXbFq7VgoECX99ZecDETkBeTlDzGyAmAXyl8yb50M=" 70 }, 71 "voting_power": "0" 72 } 73 } 74 } 75 ``` 76 77 ### Block Info 78 Returns block information for a specific block. Including block meta and all transactions in the block. 79 80 #### Parameters 81 1. height - the height of the block. 82 83 #### Returns 84 String - Block information. 85 86 #### Example 87 ``` 88 // Request 89 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"block", "params":{"height":"1"}}' "https://fullnode.lino.network" -s 'https://fullnode.lino.network/status' 90 91 // Result 92 { 93 "jsonrpc": "2.0", 94 "id": "jsonrpc-client", 95 "result": { 96 "block_meta": { 97 "block_id": { 98 "hash": "AA1D14CA41F7DE01BC47D9E8443779F212B5CCE959CEB930F5DED26AC12223D9", 99 "parts": { 100 "total": "1", 101 "hash": "9DDF48A11FBAFDD2FE61C65C4A10D10D40F1B13A1FFE8604CBC34D5035E0AD9E" 102 } 103 }, 104 "header": { 105 "version": { 106 "block": "10", 107 "app": "0" 108 }, 109 "chain_id": "lino-testnet-upgrade2", 110 "height": "1", 111 "time": "2019-09-19T19:12:05.141699565Z", 112 "num_txs": "0", 113 "total_txs": "0", 114 "last_block_id": { 115 "hash": "", 116 "parts": { 117 "total": "0", 118 "hash": "" 119 } 120 }, 121 "last_commit_hash": "", 122 "data_hash": "", 123 "validators_hash": "F29730F7417C82A26FE3FA55D07E2D5F771FC2B0EA2E387E2E2A3CF10B1B571F", 124 "next_validators_hash": "F29730F7417C82A26FE3FA55D07E2D5F771FC2B0EA2E387E2E2A3CF10B1B571F", 125 "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", 126 "app_hash": "", 127 "last_results_hash": "", 128 "evidence_hash": "", 129 "proposer_address": "1E1B60F12C837BB35218E1F370B935FEBC17B8A0" 130 } 131 }, 132 "block": { 133 "header": { 134 "version": { 135 "block": "10", 136 "app": "0" 137 }, 138 "chain_id": "lino-testnet-upgrade2", 139 "height": "1", 140 "time": "2019-09-19T19:12:05.141699565Z", 141 "num_txs": "0", 142 "total_txs": "0", 143 "last_block_id": { 144 "hash": "", 145 "parts": { 146 "total": "0", 147 "hash": "" 148 } 149 }, 150 "last_commit_hash": "", 151 "data_hash": "", 152 "validators_hash": "F29730F7417C82A26FE3FA55D07E2D5F771FC2B0EA2E387E2E2A3CF10B1B571F", 153 "next_validators_hash": "F29730F7417C82A26FE3FA55D07E2D5F771FC2B0EA2E387E2E2A3CF10B1B571F", 154 "consensus_hash": "048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F", 155 "app_hash": "", 156 "last_results_hash": "", 157 "evidence_hash": "", 158 "proposer_address": "1E1B60F12C837BB35218E1F370B935FEBC17B8A0" 159 }, 160 "data": { 161 "txs": null 162 }, 163 "evidence": { 164 "evidence": null 165 }, 166 "last_commit": { 167 "block_id": { 168 "hash": "", 169 "parts": { 170 "total": "0", 171 "hash": "" 172 } 173 }, 174 "precommits": null 175 } 176 } 177 } 178 } 179 ``` 180 To parse a transaction in the block: 181 ``` 182 // Request 183 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"block", "params":{"height":"20000"}}' "https://fullnode.lino.network" | jq -r .result.block.data.txs[0] | base64 -d 184 185 // Result 186 { 187 "type": "auth/StdTx", 188 "value": { 189 "msg": [ 190 { 191 "type": "lino/register", 192 "value": { 193 "referrer": "dlivetv-50", 194 "register_fee": "5.05", 195 "new_username": "rizqienb1", 196 "new_reset_public_key": { 197 "type": "tendermint/PubKeySecp256k1", 198 "value": "A4hcZmY4TTMMLWu1Vbid6atcgZQmra9xx/cSfsL1wiqw" 199 }, 200 "new_transaction_public_key": { 201 "type": "tendermint/PubKeySecp256k1", 202 "value": "A/xXr5+3aKxqRMkf8c+2VsXgrdMvc3hbE4lmz49YwBne" 203 }, 204 "new_app_public_key": { 205 "type": "tendermint/PubKeySecp256k1", 206 "value": "AoeI2TmhEpoCeySUQDkCzcFSqzUEmBhvRwMJg3U91REW" 207 } 208 } 209 } 210 ], 211 "fee": { 212 "amount": [ 213 { 214 "denom": "linocoin", 215 "amount": "100000" 216 } 217 ], 218 "gas": "0" 219 }, 220 "signatures": [ 221 { 222 "pub_key": { 223 "type": "tendermint/PubKeySecp256k1", 224 "value": "AilEeb1MEK2EIObumdHHvVl6Qtert1OxRYVuZvRFMnj2" 225 }, 226 "signature": "zFJymbFOFZZ8GpzQHQhU/vAwyDYv7kwMuxzWlJvXv3VxKcJzgxdYH1Riw9fLF64kx0m9mPthnJdabx7S5cM2mQ==" 227 } 228 ], 229 "memo": "" 230 } 231 } 232 ``` 233 234 ### Tx Info 235 Returns a specific transaction status and execution result. 236 237 #### Parameters 238 1. hash - the hash of a transaction. 239 240 #### Returns 241 String - Tx information. 242 243 #### Example 244 ``` 245 // Request 246 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"tx", "params":{"hash":"3fTjLeArr8uLbRYxL6zJiRRhvpp+NX9FSqLAgdAY+9A="}}' "https://fullnode.lino.network" 247 248 // Result 249 { 250 "jsonrpc": "2.0", 251 "id": "jsonrpc-client", 252 "result": { 253 "hash": "DDF4E32DE02BAFCB8B6D16312FACC9891461BE9A7E357F454AA2C081D018FBD0", 254 "height": "237788", 255 "index": 0, 256 "tx_result": { 257 "log": "[{\"msg_index\":0,\"success\":true,\"log\":\"\"}]", 258 "gasUsed": "215100", 259 "events": [ 260 { 261 "type": "message", 262 "attributes": [ 263 { 264 "key": "YWN0aW9u", 265 "value": "VHJhbnNmZXJNc2c=" 266 } 267 ] 268 } 269 ] 270 }, 271 "tx": "eyJ0eXBlIjoiYXV0aC9TdGRUeCIsInZhbHVlIjp7Im1zZyI6W3sidHlwZSI6Imxpbm8vdHJhbnNmZXIiLCJ2YWx1ZSI6eyJzZW5kZXIiOiJkbGl2ZXR2IiwicmVjZWl2ZXIiOiJkbGl2ZXR2LTEzIiwiYW1vdW50IjoiMy40NSIsIm1lbW8iOiIifX1dLCJmZWUiOnsiYW1vdW50IjpbeyJkZW5vbSI6Imxpbm9jb2luIiwiYW1vdW50IjoiMTAwMDAwIn1dLCJnYXMiOiIwIn0sInNpZ25hdHVyZXMiOlt7InB1Yl9rZXkiOnsidHlwZSI6InRlbmRlcm1pbnQvUHViS2V5U2VjcDI1NmsxIiwidmFsdWUiOiJBM2hzYkErUGVHVUZMazNmcFVvSDdVVXFvU1Iwc2pDVUNOU2IvR3B0WjVzRSJ9LCJzaWduYXR1cmUiOiJhOTVRU1lnN1l4QzNOamdnWEVCSitiQ2VTM3EzUEhEWGRqeFlRT2wwZDZ3Q0pMTk1yQjhhUGJ1MDJBRmtSdXpreHFLSnlTUFU4Z2I3V2NmeEw4OTI2QT09In1dLCJtZW1vIjoiIn19" 272 } 273 } 274 ``` 275 276 Transaction hash can be parsed by following steps 277 ``` 278 // Request 279 $ curl -X POST --data-binary '{"jsonrpc":"2.0","id":"jsonrpc-client","method":"block", "params":{"height":"237788"}}' "https://fullnode.lino.network" | jq -r .result.block.data.txs[0] | base64 -d | sha256sum | xxd -r -p | base64 280 281 // Result 282 3fTjLeArr8uLbRYxL6zJiRRhvpp+NX9FSqLAgdAY+9A= 283 ``` 284 285 286 ### Account Info 287 Returns a specific user's account information. 288 289 #### Parameters 290 1. username - the username of a Lino Blockchain user. 291 292 #### Returns 293 String - Account information, which includes username, create time in unix, public keys and address. Address can be derived from transaction public key. 294 295 #### Example 296 ``` 297 // Request, username is `ytu` 298 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"abci_query","params":{"height":"0","trusted":false,"path":"/custom/account/info/ytu","data":""}}' "https://fullnode.lino.network" | jq -r .result.response.value | base64 -d | jq . 299 300 // Result 301 { 302 "username": "ytu", 303 "created_at": "1537817595", 304 "signing_key": { 305 "type": "tendermint/PubKeySecp256k1", 306 "value": "AoxfvcigEx+LtU2t0aAanloux5CA5kjORVvBgKVt/Hip" 307 }, 308 "transaction_key": { 309 "type": "tendermint/PubKeySecp256k1", 310 "value": "Awa7WFs9Oeyl5skmqmlV+eaN95ajWkQNbL8wzRdkx9+j" 311 }, 312 "address": "lino1722lj3a89nnmt8teadp98h5rkvrcsc4e2ulm9s" 313 } 314 ``` 315 316 ### Account Bank 317 Returns a specific user's bank information. 318 319 #### Parameters 320 1. username - the username of a Lino Blockchain user. 321 322 #### Returns 323 String - Bank information, which includes bank balance (in Lino Coin, 1 LINO = 100000 Lino Coin), frozen money list (pending Lino), public key (same as transaction public key above), sequence number and username. 324 325 #### Example 326 ``` 327 // Request, username is `ytu` 328 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"abci_query","params":{"height":"0","trusted":false,"path":"/custom/account/bank/ytu","data":""}}' "https://fullnode.lino.network" | jq -r .result.response.value | base64 -d | jq . 329 330 // Result 331 { 332 "saving": { 333 "amount": "117057339" 334 }, 335 "frozen_money_list": [ 336 { 337 "amount": { 338 "amount": "1000000" 339 }, 340 "start_at": "1539034248", 341 "times": "12", 342 "interval": "604800" 343 }, 344 345 ], 346 "public_key": { 347 "type": "tendermint/PubKeySecp256k1", 348 "value": "Awa7WFs9Oeyl5skmqmlV+eaN95ajWkQNbL8wzRdkx9+j" 349 }, 350 "sequence": "1865", 351 "username": "ytu" 352 } 353 ``` 354 355 356 ### Post Info 357 Returns a specific post's information. 358 359 #### Parameters 360 1. permlink - the permlink of the post. Permlink = username + "#" + postID. 361 362 #### Returns 363 String - Post information, which includes author, post id, title, content, create time, etc. 364 365 #### Example 366 ``` 367 // Request, permlink is `pika35#VxWqSm2Wg` 368 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"abci_query","params":{"height":"0","trusted":false,"path":"/custom/post/info/pika35#VxWqSm2Wg","data":""}}' "https://fullnode.lino.network" | jq -r .result.response.value | base64 -d | jq . 369 370 // Result 371 { 372 "post_id": "VxWqSm2Wg", 373 "title": "💛 ⚡UYKUSUZ VE DENGESİZ", 374 "content": "", 375 "author": "pika35", 376 "created_by": "dlivetv", 377 "created_at": "1569793433", 378 "updated_at": "1569793433", 379 "is_deleted": false 380 } 381 ``` 382 383 384 ### Stake Info 385 Returns a user's stake information. 386 387 #### Parameters 388 1. username - the username of a Lino Blockchain user. 389 390 #### Returns 391 String - Stake information, which includes total Lino stake (in Lino Coin, 1 LINO = 100000 Lino Coin), delegation info (ytu 09/29/2019: deprecated in next update), duty and frozen amount (ytu 09/29/2019: enable in next update). 392 393 #### Example 394 ``` 395 // Request, username is `dlivetv` 396 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"abci_query","params":{"height":"0","trusted":false,"path":"/custom/vote/voter/dlivetv","data":""}}' "https://fullnode.lino.network" | jq -r .result.response.value | base64 -d | jq . 397 398 // Result 399 { 400 "username": "dlivetv", 401 "lino_stake": { 402 "amount": "100000000000" 403 }, 404 "delegated_power": { 405 "amount": "0" 406 }, 407 "delegate_to_others": { 408 "amount": "0" 409 }, 410 "last_power_change_at": "1568322539", 411 "interest": { 412 "amount": "0" 413 }, 414 "duty": "0", 415 "frozen_amount": { 416 "amount": "0" 417 } 418 } 419 ``` 420 421 ### Stake Info 422 Returns a user's stake information. 423 424 #### Parameters 425 1. username - the username of a Lino Blockchain user. 426 427 #### Returns 428 String - Stake information, which includes total Lino stake (in Lino Coin, 1 LINO = 100000 Lino Coin), delegation info (ytu 09/29/2019: deprecated in next update), duty and frozen amount (ytu 09/29/2019: enable in next update). 429 430 #### Example 431 ``` 432 // Request, username is `dlivetv` 433 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"abci_query","params":{"height":"0","trusted":false,"path":"/custom/vote/voter/dlivetv","data":""}}' "https://fullnode.lino.network" | jq -r .result.response.value | base64 -d | jq . 434 435 // Result 436 { 437 "username": "dlivetv", 438 "lino_stake": { 439 "amount": "100000000000" 440 }, 441 "delegated_power": { 442 "amount": "0" 443 }, 444 "delegate_to_others": { 445 "amount": "0" 446 }, 447 "last_power_change_at": "1568322539", 448 "interest": { 449 "amount": "0" 450 }, 451 "duty": "0", 452 "frozen_amount": { 453 "amount": "0" 454 } 455 } 456 ``` 457 458 ### Validator Info 459 Returns a validator's information. 460 461 #### Parameters 462 1. username - the username of a Lino Blockchain user. 463 464 #### Returns 465 String - Validator information, which number of poduced blocks, deposit (ytu 09/29/2019: deprecated in next update), public key, commit power, etc. 466 467 #### Example 468 ``` 469 // Request, username is `validator1` 470 $ curl -X POST --data-binary '{"jsonrpc":"2.0","method":"abci_query","params":{"height":"0","trusted":false,"path":"/custom/validator/validator/validator1","data":""}}' "https://fullnode.lino.network" | jq -r .result.response.value | base64 -d | jq . 471 472 // Result 473 { 474 "ABCIValidator": { 475 "address": "Hhtg8SyDe7NSGOHzcLk1/rwXuKA=", 476 "power": "1000" 477 }, 478 "pubkey": { 479 "type": "tendermint/PubKeyEd25519", 480 "value": "4rgh/IbevTzo/2s3YJip1F/ih0gm153mLrIkKZTrNhI=" 481 }, 482 "username": "validator1", 483 "deposit": { 484 "amount": "29340000000" 485 }, 486 "absent_commit": "0", 487 "byzantine_commit": "0", 488 "produced_blocks": "9267485", 489 "link": "" 490 } 491 ```