Skip to content
ChMarina edited this page Aug 5, 2019 · 18 revisions

API List

API Reference

status

Method returns the current state of the torrent node.

Parameters

none

Returns

result - ok/error

version - torrent_node version

git_hash - torrent_node git_hash

Example

// Request
curl -X POST --data '{"id":1,"method":"status"}' IP_torrent:5795/status

// Result
{
	"result": "ok",
	"version": "0.92",
	"git_hash": "0c2e3659f2057148e4ac65f35cce655dcb6ef420"
}

getinfo

Method returns wallet address.

Parameters

none

Returns

version - torrent_node version

mh_addr - wallet address

Example

// Request
curl IP_torrent:5795/getinfo

// Result
{
  "result":
  {
    "version":"0.80",
    "mh_addr":"0x00ffd4a1bae4e39b1bc5d8d35beaba51d0207ff9ee1b88ac7c"
  }
}

get-count-blocks

Method returns the number of blocks in the blockchain.

Parameters

none

Returns

count_blocks - count blocks

Example

// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-count-blocks"}' IP_torrent:5795

// Result
{
	"id": 1,
	"result": {
		"count_blocks": 929351
	}
}

get-block-by-hash

View info on a specified blockchain block by its hash.

Parameters

hash - block hash

type - type of requested info: full - full dump, hashes - only hashes, small - min info on the block title, simple or there is not - only block title. InfrastructureTorrent supports only such types as: small, simple or empty type(unspecified)

countTxs - the number of transactions in the block (works with type hashes and full)

beginTx - starting from transaction (works with type hashes and full)

Returns

type - block type, there are the following types: block, state, forging. For more details read MetaHash-Wiki

sign - signature

hash - block hash

prev_hash - hash of the previous block

tx_hash - transaction hash

number - block number

timestamp - time the block was created in timestamp format

count_txs - number of transactions in the block

size - block size

signatures - array of signatures

Example

// Request
curl -X POST --data '{"id":1,"params":{"hash": "06ba62e00406ab06a069b37b99f7d8788dc1cec11a181571876be61fd1d661a8", "type":"simple"},"method":"get-block-by-hash"}' IP_torrent:5795

// Result
{"result":
 {
  "type":"block",
  "sign":"890025c6317eb...20c5697ad854f1edf8679f",
  "hash":"06ba62e00406ab06a069b37b99f7d8788dc1cec11a181571876be61fd1d661a8",
  "prev_hash":"c439e81a5430273a7b0846f76f9f8886d110775745849a7a9e3e0fd94975389c",
  "tx_hash":"2d638f5d514b214ffa9d6cacdf4a3387facf5e54075fe4515240433f339aedf2",
  "number":23,
  "timestamp":1519810266,
  "size": 1900,
  "count_txs": 6324,
  "signatures": [
            {
                "from": "0x0028dd1ca2951fe554ef526d60ff55a64776ee5e033120ca91",
                "to": "0x0028dd1ca2951fe554ef526d60ff55a64776ee5e033120ca91",
                "value": 0,
                "transaction": "7f577af0ee57002d074b8d1c66dd396ddcf956d34db270ace570a3eec67cd690",
                "data": "4645cff68038971a3016058e8d0256c7b7affea10fc653cc687720723b888ea0",
                "timestamp": 1541589842,
                "type": "block",
                "blockNumber": 0,
                "signature": "304502203c36d28a2685f90861b52acd0a15f5c7db9715...06e86acb5f",
                "publickey": "3059301306072a8648ce3d020106082a8...8d5a133e7a1233cccc",
                "fee": 0,
                "nonce": 1152,
                "intStatus": 1,
                "status": "ok"
            }]
 }
}

get-block-by-number

View info on a specified blockchain block by its number.

Parameters

number - block number

type - type of requested info: full - full dump, hashes - only hashes, small - min info on the block title, simple or there is not - only block title. InfrastructureTorrent supports only such types as: small, simple or empty type (unspecified).

countTxs - the number of transactions in the block (works with type hashes and full)

beginTx - starting from transaction (works with type hashes and full)

Returns

type - block type, there are the following types: block, state, forging. For more details read MetaHash-Wiki

sign - signature

hash - block hash

prev_hash - hash of the previous block

tx_hash - transaction hash

number - block number

timestamp - time the block was created in timestamp format

Example

// Request
curl -X POST --data '{"id":1,"params":{"number": 23, "type":0}}' IP_torrent:5795/get-block-by-number

// Result
{"result": 
 {
  "type":"block",
  "sign":"890025c6317eb812548d7085acf13e2c12dfb3e11520c5697ad854f1edf8679f",
  "hash":"06ba62e00406ab06a069b37b99f7d8788dc1cec11a181571876be61fd1d661a8",
  "prev_hash":"c439e81a5430273a7b0846f76f9f8886d110775745849a7a9e3e0fd94975389c",
  "tx_hash":"2d638f5d514b214ffa9d6cacdf4a3387facf5e54075fe4515240433f339aedf2",
  "number":23,
  "timestamp":1519810266
 }
}

get-blocks

View info the sequence of blocks in the blockchain.

Parameters

type - detail level: small - min info on the block title, simple or there is not - only block title.

direction - block bypass direction: "forward", "backward". "backward" by default.

countBlocks - the number of blocks.

beginBlock - starting from block.

Returns

List of blocks with the following params for each one:

type - block type, there are the following types: block, state, forging. For more details read MetaHash-Wiki

sign - signature

hash - block hash

prev_hash - hash of the previous block

tx_hash - transaction hash

number - block number

timestamp - time the block was created in timestamp format

count_txs - number of transactions in the block

size - block size

signatures - array of signatures

fileName - name of the file containing info on the block.

Example

// Request
curl -X POST --data '{"id":1,"params":{"beginBlock": 322, "countBlocks": 10},"method":"get-blocks", "pretty": false}' IP_torrent:5795

// Result
{
  "id":1,
  "result":
  [
    {
      "hash":"736ebb7ef7983a55c653c0dd8e65c3770ff2a8221421cb37775626755779fe6c",
      "prev_hash":"e2f4dd915425a85356bba3f96af47aaff835bbf96a3ef9e55fa53fc098fc9e08",
      "tx_hash":"819e8b1241d45a00c77ff19a430f1cd83dc014f0991764c8cf4455bb838293ee",
      "number":322,
      "timestamp":1519823663,
      "count_txs":217173,
      "size":43216419,
      "fileName":"./folder/20180228.blk"
    },
    {
      "hash":"68bd7ccb71e1e31ce07443fb332ecff62d006ee384b0896d0ac54836a75217f2",
      "prev_hash":"736ebb7ef7983a55c653c0dd8e65c3770ff2a8221421cb37775626755779fe6c",
      "tx_hash":"d6d2b5b8f3fd605d7183d6dce79cdfab26798b288b7b3322f44d1cf027fb8d20",
      "number":323,
      "timestamp":1519823669,
      "count_txs":212309,
      "size":42248952,
      "fileName":"./folder/20180228.blk"
    }, ...
  ]
}

get-dump-block-by-hash

Getting block dump by its hash.

Parameters

hash - block hash

Returns

dump - block dump

Example

// Request
curl -X POST --data '{"id":1,"params":{"hash": "1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82"},"method":"get-dump-block-by-hash"}' IP_torrent:5795

// Result
{"jsonrpc":"2.0","id":1,"result":{"dump":"0123456789abcdefcead1a5c000000005d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba152164645df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6c1001e954698a8d7d32d491866c19e4ceaab3458696492e96d670100fa6c0900483046022100f443ae752e606fa162dfffc66e7a03788deb38d9c5ba56111bb6a93665de46440221008afa421023f9d93e3037ca3dced2288ba89c62c67875e832a79925e82ab46bb2583056301006072a8648ce3d020106052b8104000a034200047f2c35bdb88d6a1d778322c0604d3dd96eaf83e624f4bd4bbe0aa0d5d84f955e88023886c49294fa6eb080043755e5f895746c1afa3f47e277c30bb9ba013a6d00"}}

get-dump-block-by-number

Getting block dump by its number.

Parameters

number - block number

Returns

dump - block dump

Example

// Request
curl -X POST --data '{"id":1,"params":{"number":7907},"method":"get-dump-block-by-number"}' IP_torrent:5795

// Result
{"jsonrpc":"2.0","id":1,"result":{"dump":"0123456789abcdefcead1a5c000000005d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba152164645df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6c1001e954698a8d7d32d491866c19e4ceaab3458696492e96d670100fa6c0900483046022100f443ae752e606fa162dfffc66e7a03788deb38d9c5ba56111bb6a93665de46440221008afa421023f9d93e3037ca3dced2288ba89c62c67875e832a79925e82ab46bb2583056301006072a8648ce3d020106052b8104000a034200047f2c35bdb88d6a1d778322c0604d3dd96eaf83e624f4bd4bbe0aa0d5d84f955e88023886c49294fa6eb080043755e5f895746c1afa3f47e277c30bb9ba013a6d00"}}

fetch-balance

Supported on version 0.110
It returns current balance for the specified in the request address in the network where MHC client runs.

Parameters

address - wallet address in HEX format

Returns

address - wallet address in HEX format

received - amount received

spent - amount spent

delegate - amount delegated from this address

undelegate - amount undelegated from this address (returned to this address)

Calculated fields

currentDelegate - delegate minus undelegate (in this example 159150000000 - 158150000000 = 1000000000, in macro units 1000 MHC)

Example

// Request
curl -X POST --data '{"id":1,"params":{"address": "0x00198d5800883f696e6ddbcd2a299b47e65f2ae468eaee8717"}}' 0.0.0.0:5795/fetch-balance
// Result
{
	"id": 1,
	"result": {
		"address": "0x00198d5800883f696e6ddbcd2a299b47e65f2ae468eaee8717",
		"received": 2532089229273,
		"spent": 2519135727137,
		"count_received": 3872,
		"count_spent": 190,
		"count_txs": 4052,
		"block_number": 872075,
		"currentBlock": 872090,
		"hash": "416981862921602939",
		"countDelegatedOps": 3589,
		"delegate": 159150000000,
		"undelegate": 158150000000,
		"delegated": 48314170016191,
		"undelegated": 38315345668988,
		"reserved": 0,
		"countForgedOps": 140,
		"forged": 2029524028861
	}
}