1
Harmony - Metamask Staking
complete
D
David Whicker
Harmony API is not pulling in staking data i.e collect rewards from users who stake with the metamask wallet. The API is storing this data in a different method.
When a transaction is sent to: one1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq8uuuycsy
This is the staking precompile address. All the staking data is found within the 'input' variable.
you then need to decrypt that data e.g:
inputData = '0x510b11bb000000000000000000000000b517246eb8267d12a2568822c0ed97bfc7ec7bc400000000000000000000000038e3f62bd67509953e3b79a2ea1f03f46ae229c00000000000000000000000000000000000000000000000056bc75e2d63100000'
methodSignature = input[ :10 ]
delegatorAddress = '0x' + inputData[ 34:74 ]
validatorAddress = '0x' + inputData[ 98:138 ]
amountWei = int( '0x' + inputData[ -32: ], 16 )
methodSignature then equal one of the following:
0x510b11bb = Delegate
0xbda8c0e9 = Undelegate (same fields as above)
0x6d6b2f77 = CollectRewards (which has just the
delegatorAddress
field from above; no others)Once the CollectRewards has been identified you then need to get the transaction data for that tx to get the 'amount collected' . Using API: hmyv2_getTransactionReceipt. Amount is then found in ['logs'][0]['data'].
Please reach out if you need more information or enter the Harmony Discord
This post was marked as
complete
This post was marked as
in progress
This post was marked as
planned
P
Petur
Hi David,
thank you for the detailed explanation! I will ask the team to look into this asap.
Would you be able to share a link to this Discord group?
D
David Whicker
Petur: https://discord.gg/RK7Se3Un
And check out the developer channel under technical.
It’s also worth noting that when you run the method to get the collection amount with getTransactionReceipt. You should also use this method to check for a Status as successful. The reason being is sometimes a transaction may fail and you don’t want double ups of collections on koinly.
I’m always available if you have any questions as well