3

I'm working on a basic SPL staking contract for a token i've created on devnet. Pretty simple goal: lock up tokens for x amount of time, claim, unstake. As this is all relatively ~basic~ functionality, are these functions standardized anywhere? As of now i'm just writing from scratch.

I'm also interested in the entire process, aside from just the program development. I've created the token, that's great. Created an openbook marketID + raydium pool just to understand the process of making it tradeable + getting liquidity

As for staking, where do i send tokens? Do i create a pool, externally, outside of my contract that holds a set amount of the token? Or do i initialize the pool within the contract itself? Would love a general TLDR of how this entire process works to ensure i'm on the right track. Any resources or docs would be helpful, thanks!

1 Answer 1

1

The way i would think about staking a token is only via a smart contract that can save the lock time in a PDA, send rewards based on that and have the authority to lock and unlock token in the user wallet.

To do this in a non-custodial way (token in the wallet of the user) i would look into:

Then once the user want to unlock the token you grab the current time, the time of the lock and you reward it by calculating the time difference between the 2 time frame.

At this point you need to:

NB: all of this can be done in using @solana/spl-token in typescript but you will need to save the time in a off-chain backend and have an authority keypair that can sign the transaction in a serverless way

2
  • Appreciate the insight. I would feel more comfortable doing it via a smart contract vs the typescript library, although I agree it definitely can be done that way. In terms of actually sending the reward tokens - Should these tokens be stored in an account that the smart contract controls + distributed from there? Or should they actually be minted dynamically on the fly when a user claims?
    – blockchief
    Jan 2 at 6:46
  • The way i set it up is by minting token directly in the user wallet on claim. Here there is an example that i made (will get an upgrade as soon as i have some time to spare) i think it might help you! github.com/L0STE/Anchor-Staking-2023-1
    – LEO
    Jan 3 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.