Hi everyone,
Incognito chain provides many RPCs which help developers/users get data/info from the chain, for example: create send a transaction, get balance, check your node status, trading on pdex, etc.
Here is a common RPC that I use to check the status of my node.
Incognito is open-source; you can find RPC code here: https://github.com/incognitochain/incognito-chain/tree/master/rpcserver
I suggest that you go to telegram group, ask for some PRV on testnet, then try those RPCs on testnet before going to mainnet.
1. CONSTANT:
- Burning address:
12RxahVABnAVCGP3LGwCn8jkQxgw7z1x14wztHzn455TTVpi1wBq9YGwkRMQg3J4e657AbAnCvYCJSdA9czBUNuCKwGSRQt55Xwz8WA
- For PRV, token_id is:
0000000000000000000000000000000000000000000000000000000000000004
2. Get Blockchain info:
- Description: I usually send this request to
https://test-node.incognito.org
to get the latest beacon block, then I send the request again to my node (http://xxx.xxx.xxx.162:9334), if both numbers are the same, then my node is most probably working well and synced up to date. - Request body:
{
"jsonrpc":"1.0",
"method":"getblockchaininfo",
"params":[],
"id":1
}
- Sample Request:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"id": 1,"jsonrpc": "1.0","method": "getblockchaininfo","params": [] }' \
https://test-node.incognito.org
- Sample Response:
{
"Id": 1,
"Result": {
"ChainName": "testnet",
"BestBlocks": {
"-1": {
"Height": 693664,
"Hash": "e3c635b6b085af60bff0615ddcb5551dadf16a5ac25dc6a1551629b0e4b4a840",
"TotalTxs": 0,
"BlockProducer": "121...zM",
"ValidationData": "{\"ProducerBLSSig\":\"s89...QE=\",\"ProducerBriSig\":null,\"ValidatiorsIdx\":[0,1,2,3],\"AggSig\":\"kW9fRC+36LEU7RapW49uuAmcpRdEtqNEJLrqofv35NM=\",\"BridgeSig\":[\"\",\"\",\"\",\"\"]}",
"Epoch": 6937,
"Time": 1582514457,
"RemainingBlockEpoch": 36,
"EpochBlock": 100
},
"0": {
"Height": 639834,
"Hash": "9a47994a143a80e6e48d71bffdd5c59516135612441e308b571acf47e088b89f",
"TotalTxs": 27658,
"BlockProducer": "121...DYy",
"ValidationData": "{\"ProducerBLSSig\":\"Yck...A=\",\"ProducerBriSig\":null,\"ValidatiorsIdx\":[0,2,3,5,6],\"AggSig\":\"BMLfxfSgnWNL+kO89fDoArn6CH0hh9wEoCEz+92JGB0=\",\"BridgeSig\":[\"\",\"\",\"\",\"\",\"\"]}",
"Epoch": 0,
"Time": 1582514437,
"RemainingBlockEpoch": 0,
"EpochBlock": 0
},
...
},
"ActiveShards": 8
},
"Error": null,
"Params": [],
"Method": "getblockchaininfo",
"Jsonrpc": "1.0"
}
3. Get Reward from Payment Address
- Request body:
{
"jsonrpc": "1.0",
"method": "getrewardamount",
"params": ["<payment_address>"],
"id": 1
}
- Sample Response:
Token ID and reward amount corresponding to this payment address
{
"Id": 1,
"Result": {
"0000000000000000000000000000000000000000000000000000000000000100": 270,
"4cf0a2fe3d12f8e25cd824a4e9e0bf83bbb3e18cb662920e24b14fbab8cf59b8": 540,
"6dee6fa8d29dc2d1c286b86a9ba99ff70a183ddf7a7339ed7dd9f471b8ce91a6": 180,
"880ea0787f6c1555e59e3958a595086b7802fc7a38276bcd80d4525606557fbc": 30,
"PRV": 17287167093375,
"a198b3da0c24b0928afebcd2510e7b4c9f81e3c91385bd9f0ebaeb714833454e": 270,
"bb5f49e375a4f7a2fc45a32d051ea1ca0c6f853c1b7dbd3c0a10e29acf0c7c07": 81000000000,
"ecbdd103dd319dd91c45ea6b155c6ad4711c70c7d0e6bdd76b58c6ff3351684c": 81000000000
},
"Error": null,
"Params": [
"12Ry...mCE5"
],
"Method": "getrewardamount",
"Jsonrpc": "1.0"
}
4. Withdraw reward
- Request Body:
{
"jsonrpc": "1.0",
"method": "withdrawreward",
"params": [
"<private_key>",
0,
0,
0,
{
"PaymentAddress": "<payment_address>",
"TokenID": "<token_id>"
}
],
"id": 1
}
- Sample Response:
{
"Id": 1,
"Result": {
"Base58CheckData": "",
"TxID": "26f848e2e5d52dfb1f1f4efac889af7b0870fc57e26cc6dd60f204d1898fa6e7",
"ShardID": 5
},
"Error": null,
"Params": [
"112...M43",
0,
0,
0,
{
"PaymentAddress": "12S...EsL",
"TokenID": "0000000000000000000000000000000000000000000000000000000000000004",
"Version": 1
}
],
"Method": "withdrawreward",
"Jsonrpc": "1.0"
}
5. Get PRV balance by private key
- Request Body:
{
"jsonrpc":"1.0",
"method":"getbalancebyprivatekey",
"params":["<private_key>"],
"id":1
}
- Sample Response:
My balance is around 79.8 PRV
{
"Id": 1,
"Result": 79855095878,
"Error": null,
"Params": [
"112t...LBTA"
],
"Method": "getbalancebyprivatekey",
"Jsonrpc": "1.0"
}
6. Get pToken balance by private key
- Request Body:
{
"jsonrpc": "1.0",
"method": "getlistprivacycustomtokenbalance",
"params": ["<private_key>"],
"id": 1
}
- Sample Output:
{
"Id": 1,
"Result": {
"PaymentAddress": "12R...6m7",
"ListCustomTokenBalance": [
{
"Name": "chain-BNB",
"Symbol": "cBNB",
"Amount": 1782587,
"TokenID": "8f369ad9050252341fb52705b0c8c624a65f1dee09a01bb826637257292f75cf",
"TokenImage": "data:image/png;base64,iVB...g==",
"IsPrivacy": true,
"IsBridgeToken": false
},
{
"Name": "AUTO-pETH",
"Symbol": "ApETH",
"Amount": 777141,
"TokenID": "4129f4ca2b2eba286a3bd1b96716d64e0bc02bd2cc1837776b66f67eb5797d79",
"TokenImage": "data:image/png;base64,iVB...II=",
"IsPrivacy": true,
"IsBridgeToken": false
}
]
},
"Error": null,
"Params": [
"112...dfw"
],
"Method": "getlistprivacycustomtokenbalance",
"Jsonrpc": "1.0"
}
7. Create and Send Stake Transaction
- Description: Stake PRV, your node will be listed in committee waiting list in next Epoch
- Request Body:
{
"id": 1,
"jsonrpc": "1.0",
"method": "createandsendstakingtransaction",
"params": [
"<private_key>",
{
"12RxahVABnAVCGP3LGwCn8jkQxgw7z1x14wztHzn455TTVpi1wBq9YGwkRMQg3J4e657AbAnCvYCJSdA9czBUNuCKwGSRQt55Xwz8WA": 1750000000000
},
2,
0,
{
"StakingType": 63,
"CandidatePaymentAddress": "<payment_address>",
"PrivateSeed": "<validator_key>",
"RewardReceiverPaymentAddress": "<payment_address>",
"AutoReStaking": true
}
]
}
- Sample Output:
{
"Id": 1,
"Result": {
"Base58CheckData": "",
"TxID": "3d0ef41b464970bb45b3a7d98e91c41571f9b0fb207d602a03695b83744dfbf7",
"ShardID": 0
},
"Error": null,
"Params": [
"112t...LBTA",
{
"12RxahVABnAVCGP3LGwCn8jkQxgw7z1x14wztHzn455TTVpi1wBq9YGwkRMQg3J4e657AbAnCvYCJSdA9czBUNuCKwGSRQt55Xwz8WA": 1750000000000
},
2,
0,
{
"AutoReStaking": true,
"CandidatePaymentAddress": "12R...756",
"PrivateSeed": "12mF...9cy5",
"RewardReceiverPaymentAddress": "12R...756",
"StakingType": 63
}
],
"Method": "createandsendstakingtransaction",
"Jsonrpc": "1.0"
}
8. Stop Auto Staking Transaction
- Description: If you want to unstake, execute this RPC to stop auto staking.
- Request Body:
{
"id":1,
"jsonrpc":"1.0",
"method":"createandsendstopautostakingtransaction",
"params": [
"<private_key>",
{
"12RxahVABnAVCGP3LGwCn8jkQxgw7z1x14wztHzn455TTVpi1wBq9YGwkRMQg3J4e657AbAnCvYCJSdA9czBUNuCKwGSRQt55Xwz8WA":0
},
10,
0,
{
"StopAutoStakingType" : 127,
"CandidatePaymentAddress" : "<payment_address>",
"PrivateSeed":"<validator_key>"}
]
}
- Sample Output:
{
"Id": 1,
"Result": {
"Base58CheckData": "",
"TxID": "0ea3e68db1ec731b3d63d51ac80ae2236e6c86076e4d8b15fdd427ebb7afc4ac",
"ShardID": 0
},
"Error": null,
"Params": [
"112t...LBTA",
{
"12RxahVABnAVCGP3LGwCn8jkQxgw7z1x14wztHzn455TTVpi1wBq9YGwkRMQg3J4e657AbAnCvYCJSdA9czBUNuCKwGSRQt55Xwz8WA": 0
},
10,
0,
{
"CandidatePaymentAddress": "12Rx...G756",
"PrivateSeed": "12mF...9cy5",
"StopAutoStakingType": 127
}
],
"Method": "createandsendstopautostakingtransaction",
"Jsonrpc": "1.0"
}
Please feel free to ask question below.
Happy mining