Background
In MultiversX users can delegate their funds to a staking provider and earn staking rewards by delegating their funds to a validator smart contract.
Let's assume a user account has delegated 100 EGLD to the following smart contract
erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqd8llllslmf3hu
Pending Rewards Calculation
How can the pending rewards for the user be calculated since the last claimrewards operation or if no such operation took place, since the delegation date of the funds.
For the purpose of the example, lets assume that the last operation was 180 days ago.
A delegation contract contains a view function called
getClaimableRewardswhich takes a sole address parameter (the one we want to get rewards for)Let's suppose we want to get the pending rewards for the address
erd107x49me2mggc2cd3rgr588d7mgps4nyhn2u5tep9qw3vsdf4l2cqc9ntrf1) Via a HTTP request on the gateway
We first need to convert
erd107x49me2mggc2cd3rgr588d7mgps4nyhn2u5tep9qw3vsdf4l2cqc9ntrfto hexadecimal, this tools is useful to do so: https://utils.multiversx.com/convertersThe hex value of
erd107x49me2mggc2cd3rgr588d7mgps4nyhn2u5tep9qw3vsdf4l2cqc9ntrfis7f8d52ef2ada118561b11a07439dbeda030acc979ab945e42503a2c83535fab0The result:
Using the same tool as above we can convert the base64 value e1lP8VQRKg== to decimals: 34719622021517610 = 0.034719622021517610 EGLD
2) Via mxpy
You can use the following command:
The result:
Same as above: 34719622021517610 = 0.034719622021517610 EGLD
You can of course use any SDK (JavaScript, Go, Rust, ...) you want to perform this query