Developers Forum for XinFin XDC Network

David
David

Posted on • Updated on

[Solved] How to get the rewards received by each masternode in each epoch using RPC calls.

Hello, I am trying to figure out how can I get the rewards received by each masternode in each epoch. I am not able to find the rpc call in any documentation for that. I am able to get the masternode candidates ineach epoch using eth_getCandidates in each epoch, but not able to get the rewards received by each masternode. For getting the owner address for each candidate I use the GetCandidateOwner function call from the validator contract address, if there is any better way please help me out with that too.

Discussion (6)

Collapse
gzliudan profile image
Daniel Liu • Edited on

Maybe the method eth_getRewardByHash can help you, eg:

RPC="https://earpc.xinfin.network/"

# block number 67481100, epoch 74979
HASH="0xd3c31cf5625fcefe9289e503c36b6be4500cf6552c33956137b68c7a06b41489"

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 2008,
  "method": "eth_getRewardByHash",
  "params": [
     "'"${HASH}"'"
  ]
}' | jq
Enter fullscreen mode Exit fullscreen mode
Collapse
david profile image
David Author • Edited on

Thank you, I was able to get the data from this. Just need one help, can you please help me understand the data a bit, I figured out the data in the signers key, it contains the candidate address as the key and reward and sign by that address in the object. Can you help me to understand the rewards object, I am not able to figure out that, I see that the key is the candidate address, but then the object has 2/3 more addresses, which seem to be owner addresses but when I check the rewards tab for those, one show rewards being received, while the remaining show no rewards received. I have attached the screenshot of the result.

xdc.dev/uploads/articles/q27yvui6p...

Collapse
gzliudan profile image
Daniel Liu • Edited on

Please use the object '.result.signers' in json. For the below json:

  • signer: 0x014428e60faa874f8266d0648c52a83506dd9ec6
  • holders of signer:
    • 0x181fa59072559ec53ab23246f089ad8b78e97089
    • 0x333e300d6b5a3b4857f5421891caf6f7f7e39db9
    • 0x92a289fe95a85c53b8d0d113cbaef0c1ec98ac65
{
  "result": {
    "rewards": {
      "0x014428e60faa874f8266d0648c52a83506dd9ec6": {
        "0x181fa59072559ec53ab23246f089ad8b78e97089": 0,
        "0x333e300d6b5a3b4857f5421891caf6f7f7e39db9": 42870752619879326000,
        "0x92a289fe95a85c53b8d0d113cbaef0c1ec98ac65": 4763416957764369000
      }
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
david profile image
David Author

Yes, I am using that, thought .rewards also might be having some significance, so just wanted to understand that, thank you for the help.

Thread Thread
gzliudan profile image
Daniel Liu • Edited on

You can get some information from the function HookReward in the file engine_v1_hooks.go.

Thread Thread
david profile image
David Author

Okay, thank you, will check