-
Notifications
You must be signed in to change notification settings - Fork 8
Usage
- generate
- fetch-balance
- fetch-history
- create-tx
- send-tx
- get-block-by-hash
- get-block-by-number
- get-count-blocks
- get-dump-block-by-hash
- get-dump-block-by-number
- get-tx
- fetch-transaction
It generates wallet in the network where MHC client runs.
none
address
- wallet
pub_key
- wallet public key
prv_key
- wallet private key
Besides, 2 files are created in the folder: /opt/mhp/wallet.main/ (main means that the network runs in the main network. There are several types of networks: main|dev|v8) with the name of a created wallet and prv and pub extensions for private and public keys, respectively.
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"generate"}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"address":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c",
"pub_key":"30563...d0af",
"prv_key":"307402...ed0af"
}
}
// And files:
/opt/mhp/wallet.main/0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.prv
/opt/mhp/wallet.main/0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c.raw.pub
It returns current balance for the specified in the request address in the network where MHC client runs.
address
- wallet address in HEX format.
address
- wallet
received
- amount received
spent
- amount spent
count_received
- number of receipts
count_spent":0
- number of sendings
block_number
- number of block where the last balance change was made
currentBlock
- number of blocks in the blockchain currently
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"fetch-balance", "params": {"address":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c"}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"address":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c",
"received":1000000,
"spent":0,
"count_received":1,
"count_spent":0,
"block_number":7969,
"currentBlock":7970
}
}
It returns all transaction history for the specified in the request address in the network where the MHC client runs.
address
- wallet address in HEX format.
from
- address amount was transferred from
to
- address amount was transferred to
value
- amount of transfer
transaction
- transaction hash
timestamp
- date and time of the transaction in timestamp format
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"fetch-history", "params": {"address":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c"}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
[
{
"from":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c",
"to":"0x0004cd0ecb06e091efd2fc486d13c94eafd422486d0d3fc80c",
"value":1,
"transaction":"27857e9bf3e00c35cbfb0d09870250af7585dfdf7b946265e97c8c5f244beaa5",
"timestamp":1545308555
},
{
"from":"0x0059147ce71de3f3e74c74b6f8e4135cbec80ee3ec2f52914a",
"to":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c",
"value":1000000,
"transaction":"4ccac941fc83edced9514969ed86925f60d618d2cd773789b01790935e2a08b5",
"timestamp":1545306639
}
]
}
Method for creating transactions.
address
- sender wallet address in HEX format
to
- recipient wallet address in HEX format
value
- amount of transfer
nonce
- number of outgoing transactions from the address at the time of this transaction, i.e. = count_spent + 1
transaction
- transaction hash
to
- recipient wallet address in HEX format
value
- amount of transfer
fee
- fee rate
nonce
- number of outgoing transactions from the address at the time of this transaction
data
- transaction-related data in HEX format
pubkey
- sender public key
sign
- generated transaction signature
To find out more about creating and sending transactions read the article.
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"create-tx", "params":{"address":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c", "to":"0x0004cd0ecb06e091efd2fc486d13c94eafd422486d0d3fc80c","value":1, "nonce":1}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"method":"mhc_send",
"params":
{
"transaction":"0004cd0ecb06e091efd2fc486d13c94eafd422486d0d3fc80c01000100",
"to":"0x0004cd0ecb06e091efd2fc486d13c94eafd422486d0d3fc80c",
"value":"1",
"fee":"",
"nonce":"1",
"data":"",
"pubkey":"30563...1ed0af",
"sign":"304502...adf804"
}
}
Method for sending transactions.
address
- sender wallet address in HEX format
to
- recipient wallet address in HEX format
value
- amount of transfer
nonce
- (optional) number of outgoing transactions from the address at the time of this transaction, i.e. = count_spent + 1
result
- transaction hash
To find out more about creating and sending transactions read the article.
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"send-tx", "params":{"address":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c", "to":"0x0004cd0ecb06e091efd2fc486d13c94eafd422486d0d3fc80c","value":1, "nonce":1}}' 0.0.0.0:9999
// Result
{"jsonrpc":"2.0","id":1,"result":"27857e9bf3e00c35cbfb0d09870250af7585dfdf7b946265e97c8c5f244beaa5"}
View info on a specified blockchain block by its hash.
hash
- block hash
type
- type of requested info: 2 - full block dump, 1 - only hashes, 0 or there isn’t - only block name.
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
size
- block size
fileName
- name of the file containing info on the block.
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-block-by-hash", "params":{"hash":"1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82", "type":0}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"hash":"1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82",
"prev_hash":"5d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba1521646",
"tx_hash":"45df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6",
"number":7907,
"timestamp":1545252302,
"size":275,
"fileName":"/data/metahash/20181219.blk"
}
}
View info on a specified blockchain block by its number.
number
- block number
type
- type of requested info:
- 2 - full block dump,
- 1 - only hashes,
- 0 or there isn’t - only block name.
Ниже расписаны примеры запросов и ответов для всех значений type.
type
- block type, there are the following types: block, state, forging. For more details read MetaHash-Wiki
hash
- block hash
prev_hash
- hash of the previous block
tx_hash
- transaction hash
number
- block number
timestamp
- time the block that created in timestamp format
count_txs
- количество транзакций в блоке
sign
- подпись
size
- block size
fileName
- name of the file containing info on the block
signatures
- массив подписей
txs
- массив описаний транзакций в соответствии с запрошенным типом.
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-block-by-number", "params":{"number":7907, "type":0}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"type":"block",
"hash":"1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82",
"prev_hash":"5d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba1521646",
"tx_hash":"45df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6",
"number":7907,
"timestamp":1545252302,
"count_txs":1,
"sign":"",
"size":275,
"fileName":"/data/metahash/20181219.blk",
"signatures":[]
}
}
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-block-by-number", "params":{"number":7907, "type":1}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"type":"block",
"hash":"1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82",
"prev_hash":"5d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba1521646",
"tx_hash":"45df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6",
"number":7907,
"timestamp":1545252302,
"count_txs":1,
"sign":"",
"size":275,
"fileName":"/data/metahash/20181219.blk",
"signatures":[],
"txs":["0130eb721450f48e7fcb41b084ac170546422e83b59c0b7c88657ad797e08c83"]
}
}
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-block-by-number", "params":{"number":7907, "type":2}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"type":"block",
"hash":"1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82",
"prev_hash":"5d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba1521646",
"tx_hash":"45df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6",
"number":7907,
"timestamp":1545252302,
"count_txs":1,
"sign":"",
"size":275,
"fileName":"/data/metahash/20181219.blk",
"signatures":[],
"txs":
[
{
"from":"0x004dd5169c91f8f67de32a9a8c3a6b7e037fd636ac4d4b3207",
"to":"0x001e954698a8d7d32d491866c19e4ceaab3458696492e96d67",
"value":1,
"transaction":"0130eb721450f48e7fcb41b084ac170546422e83b59c0b7c88657ad797e08c83",
"data":"",
"timestamp":1545252302,
"type":"block",
"blockNumber":7907,
"signature":"3046022100f443ae...6bb2",
"publickey":"30563010060795746c1...a6d",
"fee":0,
"realFee":0,
"nonce":2412,
"status":"ok"
}
]
}
}
Getting info on the total number of blocks in the blockchain (the length of the chain of blocks)
none
count_blocks
- number of blocks in the blockchain
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-count-blocks"}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"count_blocks":7907
}
}
Getting block dump by its hash.
hash
- block hash
dump
- block dump
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-dump-block-by-hash", "params":{"hash":"1172121c30fa86757a193170966903ef7a3dbb9dcdbad906040730f90465fb82"}}' 0.0.0.0:9999
// Result
{"jsonrpc":"2.0","id":1,"result":{"dump":"0123456789abcdefcead1a5c000000005d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba152164645df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6c1001e954698a8d7d32d491866c19e4ceaab3458696492e96d670100fa6c0900483046022100f443ae752e606fa162dfffc66e7a03788deb38d9c5ba56111bb6a93665de46440221008afa421023f9d93e3037ca3dced2288ba89c62c67875e832a79925e82ab46bb2583056301006072a8648ce3d020106052b8104000a034200047f2c35bdb88d6a1d778322c0604d3dd96eaf83e624f4bd4bbe0aa0d5d84f955e88023886c49294fa6eb080043755e5f895746c1afa3f47e277c30bb9ba013a6d00"}}
Getting block dump by its number.
number
- block number
dump
- block dump
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-dump-block-by-number", "params":{"number":7907}}' 0.0.0.0:9999
// Result
{"jsonrpc":"2.0","id":1,"result":{"dump":"0123456789abcdefcead1a5c000000005d21042bc72ccdef03e27881375668abb3be33579714db3dfec101eba152164645df25ee86ae2245bde6bdc05e5b9910e45518b8825e361f5848ceae5bbd66a6c1001e954698a8d7d32d491866c19e4ceaab3458696492e96d670100fa6c0900483046022100f443ae752e606fa162dfffc66e7a03788deb38d9c5ba56111bb6a93665de46440221008afa421023f9d93e3037ca3dced2288ba89c62c67875e832a79925e82ab46bb2583056301006072a8648ce3d020106052b8104000a034200047f2c35bdb88d6a1d778322c0604d3dd96eaf83e624f4bd4bbe0aa0d5d84f955e88023886c49294fa6eb080043755e5f895746c1afa3f47e277c30bb9ba013a6d00"}}
View info on transaction
hash
- transaction hash
from
- address amount was transferred from
to
- address amount was transferred to
value
- amount of transfer
transaction
- transaction hash
data
- transaction-related data in HEX format
timestamp
- date and time of the transaction in timestamp format
type
- block type, there are the following types: block, state, forging. For more details read MetaHash-Wiki
blockNumber
- block number in blockchain
signature
- generated transaction signature
publickey
- sender public key
fee
- estimated fee
realFee
- actual fee paid for transaction
nonce
- number of outgoing transactions from the address at the time of this transaction
status
- transaction status, there are the following: "ok", "error", "pending", "module_not_set". For more details read MetaHash-Wiki
countBlocks
- number of downloaded blocks
knownBlocks
- number of currently known blocks (but possible not downloaded)
// Request
curl -s -X POST --data '{"id":1, "version":"1.0.0", "method":"get-tx", "params":{"hash":"27857e9bf3e00c35cbfb0d09870250af7585dfdf7b946265e97c8c5f244beaa5"}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
{
"transaction":
{
"from":"0x002382e6e78e4f97ee636ba6ff42e80a34c076c118cb288e3c",
"to":"0x0004cd0ecb06e091efd2fc486d13c94eafd422486d0d3fc80c",
"value":1,
"transaction":"27857e9bf3e00c35cbfb0d09870250af7585dfdf7b946265e97c8c5f244beaa5",
"data":"",
"timestamp":1545308555,
"type":"block",
"blockNumber":7972,
"signature":"3044022076...2bad167d93b",
"publickey":"3056301006072a86...c9ba98268c33c329bd59781ed0af",
"fee":0,
"realFee":0,
"nonce":1,
"status":"ok"
},
"countBlocks":141069,
"knownBlocks":141069
}
}
Method that allows to find all transactions with a specific value of data
field.
address
- wallet address in HEX format.
data
- data to be looked for in the data field in all transactions of this wallet in HEX format.
from
- address amount was transferred from
to
- address amount was transferred to
value
- amount of transfer
transaction
- transaction hash
data
- transaction-related data in HEX format
timestamp
- date and time of the transaction in timestamp format
type
- block type, there are the following types: block, state, forging. For more details read MetaHash-Wiki
blockNumber
- block number in blockchain
signature
- generated transaction signature
publickey
- sender public key
fee
- estimated fee
realFee
- actual fee paid for transaction
nonce
- number of outgoing transactions from the address at the time of this transaction
intStatus
- numerical value that specifies the type of transaction. For more details read MetaHash-Wiki
status
- transaction status, there are the following: "ok", "error", "pending", "module_not_set". For more details read MetaHash-Wiki
// Request
curl -X POST --data '{"id":1, "version":"1.0.0","method":"fetch-transaction", "params":{"address":"0x00e5cc4426dffdb85ab2773c4d2537b9f319989eac9ab9ba22", "data":"35"}}' 0.0.0.0:9999
// Result
{
"jsonrpc":"2.0",
"id":1,
"result":
[
{
"from":"0x00e5cc4426dffdb85ab2773c4d2537b9f319989eac9ab9ba22",
"to":"0x001b3b70b8710b7fc1b12b3c1668d667dce83b8dac7d987c33",
"value":500,
"transaction":"6bfba3a9dc340f3befc974d3d707c9be321fb56a0cad36af2f43356730321dda",
"data":"3335",
"timestamp":1552436277,
"type":"block",
"blockNumber":142055,
"signature":"3045022026ccc809047fe4...a597a7a0d",
"publickey":"3056301006072a8648...a09bb1b070309c",
"fee":0,
"realFee":0,
"nonce":17,
"intStatus":20,
"status":"ok"
},
{
"from":"0x00e5cc4426dffdb85ab2773c4d2537b9f319989eac9ab9ba22",
"to":"0x001b3b70b8710b7fc1b12b3c1668d667dce83b8dac7d987c33",
"value":500,
"transaction":"76dfaebc78455164d1f350f54222fde4d766e6b0085a96f97f6e23de228b2858",
"data":"3335",
"timestamp":1552435996,
"type":"block",
"blockNumber":141976,
"signature":"3045022100f7bb949a1abd140...e6699",
"publickey":"3056301006...e5ab35a4a1018d9ddb41a09bb1b070309c",
"fee":0,
"realFee":0,
"nonce":16,
"intStatus":20,
"status":"ok"
}
]
}