Allows interact with Mint node via JSONRPC.
By default node listens port TCP 4010.
go get github.com/void616/gm.mint.rpc
See /examples
Messages are delimited with zero-terminator (\0).
Valid JsonRPC body followed by zero-terminator.
For instance (via netcat):
nc localhost 4010
{"method":"get_blockchain_state","params":{},"id":1}
# Press Ctrl+Shift+2 or Ctrl+2 to print zero-terminator, then Enter
Example response for the request above:
{
"method": "get_blockchain_state",
"id": 1,
"result": {
"last_block_digest": "umPfEnn7qmARdPtxTbxv4NdXpaP5dZ36GgoRxHMxjji97P2cg",
"last_block_merkle_root": "Law4XPsP5Q113RMfNKm8xcmn55q2RAB2kdjG76rMTjBBjHHZ8",
"block_count": "1300",
"transaction_count": "2984",
// ...
}
} // zero-terminator here
Node-side initiated events are delivered on the same connection. For instance, when new blocks are received by the node:
{
"method": "blocks_synchronized",
"params": {
"count": "1",
"last_id": "1300",
"last_digest": "w15pNFWu2aAXkh7rnKs2uqBx4yK1M4nH1X3vf2r1ZS7CpRvsx"
}
}
// zero-terminator here
Node and API version, supported transactions, assets and wallet tags.
Params:
{}
Blockchain height, overall balance, transaction pool state.
Params:
{}
Peer nodes list.
Params:
{}
Binary data of the block defined by ID or digest.
Params:
{
"id": "1", // numeric block ID, optional
"digest": "2rY5Kri4t22T8xCsXfJVNV7MUYxT7npGNFYSGQWr5b3UfA1hKS" // block digest, optional
}
Add a transaction to the pending pool.
Params:
{
"name": "transfer_asset", // predefined transaction name
"data": "deadbeef" // hex-encoded transaction data
}
Force the node to synchronize blocks.
Params:
{
"mode": "regular", // one of regular|fast|manual
"nodes": "1,2,3" // node IDs in manual mode, optional
}
Balance, nonce and tags of the specific address.
Params:
{
"public_key": "111111111111111111111111111111115RyRTN" // address
}
List of incoming/outgoing transactions for the specific address.
Params:
{
"public_key": "111111111111111111111111111111115RyRTN", // address
"count": 1000, // limited output, default is 1000
"pool_lookup": true, // include pending transactions
"binary": true, // binary/textual transaction representation
"incoming": true, // include incoming transactions, optional
"outgoing": true // include outgoing transactions, optional
}
Dump existing addresses (LZ4 compressed).
Params:
{
"with_mnt": true, // include only adresses with non-zero MNT balance, optional
"with_gold": true // include only adresses with non-zero GOLD balance, optional
}