Common RPC to check your node validator

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 :slight_smile:

10 Likes

Since we are moving from Telegram to Discourse, it might be better to let people who need test PRV private message the person in charge of that here on Discourse.

Ok, everyone who need testnet PRV can dm me or @Peter for some

2 Likes

Hi @khanhj, I think you should make clear that for all RPCs required <private_key> should not send to Full Node or any service. It is not safe.

2 Likes

Can you explain this to me in Dummy language? Lmao. I an not a techie so I dont understand what this is about… and yet I have 5 vnodes… lol

@hieutran, the mainnet fullnode may expose user privatekey if it running in debug mode. So, im going to public another topic How to run your own fullnode

@Mike_Despo lol, let it be, the mobile app wallet is good enough to check your node status. Somehow i wrote this tutorial for those who want to develop things.

Adding Information:

  • If you use RPCs to create transactions, init new privacy token, stake/ unstake, when sending the RPC requests to the full node, it will require your private key, it’s not safe at all. I strongly recommend that you should run your own full node before using these RPCs. Tutorial is here.
  • For our incognito wallet app, we eliminate that security issue by creating go mobile framework integrated into incognito wallet app. This helps your mobile phone generate transaction, execute pdex trading, do everything without sending private key to fullnode, therefore, your private key is safely kept on your phone storage.


image


image

1 Like

Hi @Mike_Despo, this topic is for tech validator, who need to call api for doing more extra feature for their node in needing. If you are not a techie, it is enough for you by using wallet app

1 Like

A post was split to a new topic: Withdrawal didn’t end up in external wallet

Hello

is there any command to query my node - so I know what shard_id it is on?

thanks

@huglester run this command:

curl -s --header "Content-Type: application/json" --request POST --data '{ "id": 1, "jsonrpc": "2.0", "method": "getmininginfo"}' http://YOUR_NODE_IP_OR_DNS:9334 | jq ".Result.ShardID"

1 Like

thanks!

why would it mostly return -1?
“ShardID”: -1,

If the Role of your node is “waiting”, that’s normal.

You’ll see a different ShardId if the current Role of your node is pending or commitee.

1 Like

does it mean that “ShardID” is changing from time to time? or its static?

1 Like

Without running any script, you may check your node status via https://incognito.mesquka.com

Once your node enters into a shard, it remains in that shard until it is swapped out. After swapped out, you may enter into another shard. In that case, shard id of your node may change.

so basically it means I cant migrate the node by simply copying the blockchain data?
best is to let it resync?

Because if node jumps between shards means its database consists of all shards?
but what is strange their size/heigh differs?

thanks @abduraman - will try

1 Like

I have some answers to your questions but let’s wait for the core team to get more accurate answers :slight_smile: @khanhj @Peter

What do you mean by migrate?

Migrate = from old hardware - to new hardware

For example out of space :slight_smile:

Your node, for the network is actually your validator key, the account that is used to stake, and to receive the earnings. You are only on a shard when you are earning. You could be earning on different shards when earning several epochs sequentially.

The easiest way is just to stop the current node when you are in “waiting” stage. Start the new node using the same validator key, and it will resync.

Do you want to save time resyncing by copying files from the old to the new one?

1 Like

Your node, for the network is actually your validator key, the account that is used to stake, and to receive the earnings. You are only on a shard when you are earning. You could be earning on different shards when earning several epochs sequentially.

The easiest way is just to stop the current node when you are in “waiting” stage. Start the new node using the same validator key, and it will resync.

yeah, this is the right method to migrate your node.
@huglester, you can copy blockchain data to new location/machine (just make sure the file path is correct as defined in run.sh)

1 Like