api_block and transaction - UCHAIN-WORLD/uchain-fullnode GitHub Wiki
title: block
-
help
show command usage.
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method": "{COMMAND}", "params": [ "test", "123456"], "id": 7 }, json: true };
-
Response (Example for shutdown)
{ "id": 7, "jsonrpc": "3.0", "result": "\nUsage: uc-cli shutdown [-h] [ADMINNAME] [ADMINAUTH] \n\n Info: stop ucd. \n\n Options (named):\n\n-h [--help] Get a description and instructions for this command.\n\n Arguments (positional):\n\n ADMINNAME admin name. \n ADMINAUTH admin password/authorization. \n"
}
-
Get last height. Alias asshowblockheight
fetch-height
.- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showblockheight", "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : 456270 }
-
Get sepcified block header from wallet. * JS Parametersshowblock
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showblock", "params":["99"], "id": 7 }, json: true };
- Response
get raw data of a block{ "id" : 7, "jsonrpc" : "3.0", "result" : { "hash" : "61c5cacf8e3ca8dbbf18c9e779b20f6d531154270b0270d8e9647f541f8a5685", "merkle_tree_hash" : "e330aa3442d4bcc52f29c3bf4b25b964d18bd9f20f786364ff6adad4ab7bc9c2", "number" : 99, "previous_block_hash" : "f3a6331b6dd210f7979b2e987f1212d63bbf597563164d36be46f1471809ec71", "timestamp" : 1543834006, "transaction_count" : 1, "transactions" : [ { "hash" : "e330aa3442d4bcc52f29c3bf4b25b964d18bd9f20f786364ff6adad4ab7bc9c2", "inputs" : [ { "address" : "URaJN6xB2vmFGQcXDkLkrDjaSxu9qJN4Zr", "previous_output" : { "hash" : "8f235e19bbdc87c36f207c0384e4306f2f8e2b3a357d4cb09b67bced6f2e01e3", "index" : 0 }, "script" : "[ 3045022100fa935e9e4ff0db6eb4603d73598d81071d6250780a803ff414ccbb35202a7d3002202cc34daad5dc2e041b620bf9b15060dfb43e054b443d6d5d1740efe17db7ea2001 ] [ 02220f1c27736410c7a8ee7688696ac4584c0f8159c06586bd2eece71c289367de ]", "sequence" : 4294967295 } ], "lock_time" : "0", "outputs" : [ { "address" : "URaJN6xB2vmFGQcXDkLkrDjaSxu9qJN4Zr", "asset" : { "quantity" : 33, "symbol" : "BLOCK", "type" : "token-transfer" }, "index" : 0, "locked_height_range" : 0, "script" : "dup hash160 [ 276437b131fe76fd6ba9b4fdc9b995bc4a7e5932 ] equalverify checksig", "value" : 0 } ], "version" : "2" } ], "version" : 1 } }
- JS Parameters
{ "jsonrpc": "3.0", "method": "showblock", "params": [ "20",{"json":false}], "id": 7 };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : "010000009e25217bd73077824f0dbdd942f65bb37dbc7b4341196e2d3fc96243ab7852b2142e19f3e3b9f7817ec11fa3763101fe9aa67d374617ee6be50d25643357b446846a1b5c1400000001020000000135599d6fda6a193d82c1b4cba9f3741e0459f92d274ea1efc8d8e4fff4aab359000000006a4730440220641c009fe86e36a920d48fac332d0fa23a15a4503edfde2661b3af2b960c76b20220021b0e32b165323ac7bc59c83973cd82f336fdc4f6144a734381668982c9f8f80121035c482d4076fc4fc9cf2edc9f0bc5953bb9f0c36e87c33ec7bb8b251c86dab95cffffffff0100000000000000001976a914b1b798d0c2ce491ed9905c9ed5a73ce03c5c9ed288ac01000000020000000200000005424c4f434b080000000000000000000000" }
-
get best blockheader alias as fetch-header/getbestblockhash/getbestblockheadershowblockheader
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showblockheader", "params":[{"height":"99"}], "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : { "hash" : "61c5cacf8e3ca8dbbf18c9e779b20f6d531154270b0270d8e9647f541f8a5685", "merkle_tree_hash" : "e330aa3442d4bcc52f29c3bf4b25b964d18bd9f20f786364ff6adad4ab7bc9c2", "number" : 99, "previous_block_hash" : "f3a6331b6dd210f7979b2e987f1212d63bbf597563164d36be46f1471809ec71", "timestamp" : 1543834006, "transaction_count" : 1, "version" : 1 } }
-
showblockheaders
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method": "showblockheaders", "params": [ {"height":"1:2"} ], "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : [ { "hash" : "94f00e35fa3777326f2e678bdeb4d060894dc602b1b5ce96e3709d36a66c90bb", "merkle_tree_hash" : "21919ae6e118dca40781fe06d2b81f20448f74cf1ecd106bb0fbe4452a343136", "number" : 1, "previous_block_hash" : "e3b1dbc8aa72ba41585c2b2910c7870a91f9abbd0298a9a06be2c736c929ded5", "timestamp" : 1545810065, "transaction_count" : 1, "version" : 1 }, { "hash" : "406f8f12841133a778826258a991c51585504d4a65cd9c848cde9e9dd461b382", "merkle_tree_hash" : "11237543819acfbd0219881f5dfe66e61abdb3e2474589cebc5e5394cf301b70", "number" : 2, "previous_block_hash" : "94f00e35fa3777326f2e678bdeb4d060894dc602b1b5ce96e3709d36a66c90bb", "timestamp" : 1545810065, "transaction_count" : 1, "version" : 1 } ] }
-
similar to showblockheadershowheaderext
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showheaderext", "params":[ "yang", "123456", "99" ], "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : { "hash" : "61c5cacf8e3ca8dbbf18c9e779b20f6d531154270b0270d8e9647f541f8a5685", "merkle_tree_hash" : "e330aa3442d4bcc52f29c3bf4b25b964d18bd9f20f786364ff6adad4ab7bc9c2", "number" : 99, "previous_block_hash" : "f3a6331b6dd210f7979b2e987f1212d63bbf597563164d36be46f1471809ec71", "timestamp" : 1543834006, "transaction_count" : 0, "version" : 1 } }
- JS Parameters
-
Returns all transactions in memory pool.showmemorypool
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showmemorypool", "params":[ "yang", "123456" ], "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : [ { "hash" : "21e9a5f0aedad912e5b1721244fa5d2ea2df6830a19ad257f9e875aeee99ddb9", "inputs" : [ { "address" : "UQudmH5pc3BuBebzVrdhVeXR8P8JXGUwCZ", "previous_output" : { "hash" : "f5175f89882c2dd51e25228af9288b400c2f0cbc8f878649e69b0be16d11d1f4", "index" : 0 }, "script" : "[ 3045022100db8cadbc5180b02deba70e5518a815c2f9ef4524094b49a052d9b3123cd2b32a022028965d8aa9c2015a08beda748df09cede75bea11936d576d0b40ac433df7650901 ] [ 03e37efd1fd6788d1f4814bfadf63ee670bea3c6d35a3faed71f8f075e0dbd86ec ]", "sequence" : 4294967295 } ], "lock_time" : "0", "outputs" : [ { "address" : "UQudmH5pc3BuBebzVrdhVeXR8P8JXGUwCZ", "asset" : { "address" : "UQudmH5pc3BuBebzVrdhVeXR8P8JXGUwCZ", "symbol" : "developers", "type" : "uid-register" }, "index" : 0, "locked_height_range" : 0, "script" : "dup hash160 [ 20143060db1a710b2759207a4bc0cb36b8d95afe ] equalverify checksig", "value" : 0 }, { "address" : "UPqVLpaoDceFvEuTiwijaqXiZCiqHvjZ3C", "asset" : { "from_uid" : "", "to_uid" : "", "type" : "ucn" }, "index" : 1, "locked_height_range" : 0, "script" : "dup hash160 [ 14535e89ce61c1f955c3e59f66932bba3f0e49d2 ] equalverify checksig", "value" : 80000000 } ], "version" : "4" } ] }
- JS Parameters
-
Get the information of specified transaction.showtx
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showtx", "params":[ "4489704f9d9b814a4f36ffe2bc75ac7e7618ff023176bea96068523a23d1e1fe" ], "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : { "hash" : "4489704f9d9b814a4f36ffe2bc75ac7e7618ff023176bea96068523a23d1e1fe", "height" : 29, "inputs" : [ { "address" : "URaJN6xB2vmFGQcXDkLkrDjaSxu9qJN4Zr", "previous_output" : { "hash" : "cd9582566bfb9e7dcc7f429198d537e5ea059b28d2c8c1e9429e834d7101d357", "index" : 0 }, "script" : "[ 304402201b7ce86f7dffacecda115801fe82ed7d5dc49052626faaac7cf53d829ee975e502206633f6fef7f79258e27c68eb669571ab7e68b3667992cf26bb06b334470b31eb01 ] [ 02220f1c27736410c7a8ee7688696ac4584c0f8159c06586bd2eece71c289367de ]", "sequence" : 4294967295 } ], "lock_time" : "0", "outputs" : [ { "address" : "URaJN6xB2vmFGQcXDkLkrDjaSxu9qJN4Zr", "asset" : { "quantity" : 11, "symbol" : "BLOCK", "type" : "token-transfer" }, "index" : 0, "locked_height_range" : 0, "script" : "dup hash160 [ 276437b131fe76fd6ba9b4fdc9b995bc4a7e5932 ] equalverify checksig", "value" : 0 } ], "version" : "2" } }
-
List transactions details of this wallet.showtxs
- JS Parameters
{ method: 'POST', url: 'http://127.0.0.1:8707/rpc/v3', headers: { 'Content-Type': 'application/json' }, body: { "jsonrpc": "3.0", "method":"showtxs", "params":[ "snake02", "123456", {"height":"456769:456770"} ], "id": 7 }, json: true };
- Response
{ "id" : 7, "jsonrpc" : "3.0", "result" : { "current_page" : 1, "total_page" : 1, "transaction_count" : 1, "transactions" : [ { "direction" : "send", "hash" : "a1277a5ed8608dbaca715f43118e655bc8c3d827350ca231b670e5e0f0cf1c19", "height" : 456769, "inputs" : [ { "address" : "UcuW7wVu198Nuzok8eeMDUNEZQoGqQRRz5", "script" : "[ 304502210083c75de535f51564ad61d61b9f07e69a086cc58cba3d08f12f85d2fdec00842b022000a65867cffa6f29135a1c49be0ab17f09c39245485008632c892929b620dbc101 ] [ 02719293264aebc6a987763c89980ef12783491b8dd532fa6db4fe2fc2b23de045 ]" } ], "outputs" : [ { "address" : "UcuW7wVu198Nuzok8eeMDUNEZQoGqQRRz5", "asset" : { "decimal_number" : 1, "quantity" : 103, "symbol" : "BLOCK", "type" : "token-transfer" }, "locked_height_range" : 0, "own" : true, "script" : "dup hash160 [ a3af5154c2ee7f294f00e285cdb9489d8cfc8305 ] equalverify checksig", "ucn_value" : 0 } ], "timestamp" : 1544681775 } ] } }
- JS Parameters