Professional Documents
Culture Documents
Elrond Staking - Blockchain Developer
Elrond Staking - Blockchain Developer
Blockchain Developer
Challenge
Context
Staking in the Elrond blockchain refers to the process of holding and locking
up Elrond (EGLD) tokens in a staking smart contract in exchange for
rewards. The primary purpose of staking in Elrond is to participate in the
consensus mechanism of the network and help secure it, as well as earn
rewards for doing so.
Challenge
● Users can deposit their EGLD tokens into the contract to become a
staker.
● Assume rewards are distributed based on a global speed. For
example, 0.0003 EGLD are distributed per second among all users.
● Users earn rewards in proportion to their stake. These rewards are
continuously distributed (of course, they are kept at the staking smart
contract).
● Users can withdraw their staked EGLD or claim their rewards at any
time.
The document may not be shared with anyone not associated with Rather Labs. Copying or sharing it outside the provided link is prohibited.
TECH CHALLENGE
Blockchain Developer
Hint
Avoid using a loop to update the rewards for all stakers at any given
protocol interaction. The problem can be thought as having a share
amount and a share price: while the share amount an account has does
not change when someone else interacts with the protocol, the share price
does.
Total Rewards:
dR(t) = v(t) * dt
Account Rewards:
dr(t) = n(t) / N(t) * dR(t)
dr(t) = n(t) / N(t) * v(t) * dt
dr(t) = n(t) * dS(t)
In which:
dS(t) = 1 / N(t) * v(t) * dt
Is the Share price.
Steps
Bonus Points
- Create some tests for the staking smart contract, tests are important
to ensure that the contract works as expected and to catch any
potential bugs or issues before deployment.
- Deploy the smart contract on the Elrond network using the mxpy or
any other Elrond development environment of your choice.
The document may not be shared with anyone not associated with Rather Labs. Copying or sharing it outside the provided link is prohibited.