Decentralized Staking

Hi team, we are interested in creating a decentralized staking process.

Example:

We have 10 million of a CAT and we want people to be able to block their tokens for a number of blocks in a decentralized way to receive a predefined percentage, in addition to the fact that we, the creators, no longer have control over the CAT.

We would really like to expand on this topic and see if we can create a working example of a Smart coin that allows decentralized staking.

Thanks in advance.

I’m by no means an expert on CATs, but here are some thoughts:

CATs take an inner puzzle that defines how it should be spent. Normally it would return conditions for signature etc, but you can create a custom puzzle that apart from signature, also requires ASSERT_HEIGHT_RELATIVE/ABSOLUTE condition. It’s also possible to allow a third party to spend the coin in that time in a limited way while keeping original ownership.
Identifying staked CATs is a bit trickier as you need to be able to compute puzzle hash or coin id to find them.
You could probably use a coin hint with additional validation that the CAT is actually staked as anyone can create a coin with a specific hint.
You’ll also have to create a custom wallet to handle staked coins as users will not see CATs in their Chia Wallet UI anymore.

2 Likes

I hate to mention a fork cause I don’t see the use case, but the hddcoin people wrote their hold program which is similar to what you describe and might give you some ideas. On the Chia blockchain the plot nft pooling is similar to what you mention, because it lets pools claim the rewards unless you’re not in a pool and you can claim it after some time like trepca says. Hopefully that gives you some code to read.

1 Like

Do you know any reference link?

https://hddcoin.org/hodl/
describes the HDDcoin HODL program as requested.

Short overview of how it works:
The client side creates the Smart Coin, with their deposit (hddcoin-blockchain/hddcoin/hodl at main · HDDcoin-Network/hddcoin-blockchain · GitHub)

The backend validates this is on chain / subscribes to the selected program attributes and adds the reward to the Smart Coin.

there are 3 different solutions that can be provided together with the reveal to spend the Smart Coin and we give out these solutions + reveal at the time the client created the Smart Coin. This allows the client to at any time interact with the Smart Coin, regardless if the HDDcoin team is around or not.

the solutions:

  • solution_cancel_deposited (only the owner is allowed to use this, applies to the Smart Coin before rewards added)
    solution_cancel_guaranteed (only the owner is allowed to use this, applies to the Smart Coin after rewards added)
    solution_payout (anyone can use this, but only after the maturity date is reached.

CLVM of the reveal:

(a (q 4 (c 44 (c 11 ())) (c (c 92 (c 23 ())) (c (c 52 (q 1)) (a (i (= 5 32) (q 4 (c 36 (c 34 (c 50 ()))) (a (i (> 11 38) (q 4 (c 90 (c 46 (c 38 ()))) (c (c 90 (c 54 (c (- 11 38) ()))) ())) (q 4 (c 90 (c 46 (c 11 ()))) ())) 1)) (q 2 (i (= 5 48) (q 2 (i (any (> (/ (* (q . 1000) 94) 38) (q . 350)) (> (q . 0x00e8d4a51000) 38) (> 38 (q . 0x0d8d726b7177a80000))) (q 8) (q 4 (c 44 (c 38 ())) (c (c 90 (c 23 (c (+ 38 94) ()))) (c (c 122 (c 50 ())) ())))) 1) (q 2 (i (= 5 56) (q 4 (c 44 (c (+ 38 94) ())) (c (c 124 (c 126 ())) (c (c 90 (c 46 (c (+ 38 94) ()))) ()))) (q 2 (i (= 5 40) (q 8 42 50 38 94 126 46) (q 8)) 1)) 1)) 1)) 1)))) (c (q (((q . 2) 4 . 3) (50 . 82) 73 72 . 81) ((0x91a7a4fa945415c04ad11407d28c638f6e0d39070fd27e71925fb235fe4d8ce6ce8423a948a4414876bf2a9529a78ce0 . 0x788427664b0028dc) “TEST1” 51 . 62) (0x00e8d4a51000 . 0x27c6730dcb3e95d198fb8d7) 0x317ea3cd6777048c7b44801d46d12de26fc9d723c9eedc4b0308afaa22498334 100 . 0x61ba231b) 1))

1 Like