12

When I was exploring haddock of Plutus I have found that Plutus script can have Rewarding ScriptPurpose:

data ScriptPurpose
    = Minting CurrencySymbol
    | Spending TxOutRef
    | Rewarding StakingCredential
    | Certifying DCert
    deriving stock (Generic, Haskell.Show, Haskell.Eq)

This raised me a lot of questions like:

  • How do Rewarding scripts differ from Spending scripts?
  • How to use Rewarding script, how are Rewarding scripts interacted with?
  • Can Rewarding scripts be used with native tokens? Could I for example create smartcontract for staking KUGIS native tokens and getting KUGIS coins as a reward?

I have tried searching for resources but couldn't find a single resource on this except one example of the adafinance cardano staking contract on github.

1
  • 1
    Should one of the answers be marked as accepted?
    – gRebel
    Commented Apr 28, 2022 at 5:26

2 Answers 2

3

The best resources I can recommend are the following in regards to StakeValidators:

Plutus Pioneer Program Lecture #10 Cohort 3

Example Implementation StakeValidator

Plutonomicon StakeValidator Intro

How do Rewarding scripts differ from Spending scripts?

Rewarding scripts can only make assertions in regards to the registration/ deregistration of delegation certificates for some provided payment keys. In addition, they can also implement logic that validates withdrawals of staking rewards from a given address as well as ensure delegations to a new pool.

How to use Rewarding script, how are Rewarding scripts interacted with?

This was part of the PPP lecture 10 (see link above). Whenever someone creates a transaction trying to withdraw from an address that is managed by a StakeValidator then the rewarding purpose is used that provides the corresponding StakingCredentials in the ScriptContext. These StakeValidators are implicitly run whenever someone tries to withdraw rewards from an address that was created with a script StakeValidator.

Can Rewarding scripts be used with native tokens?

Could I for example create smartcontract for staking KUGIS native tokens and getting KUGIS coins as a reward? The rewarding mechanism through staking is as far as I know only done for Cardano's native currency ADA. If you wanted to create your mechanism you could use a minting policy instead for your custom token. So your smart contract/ minting policy would have to validate under what conditions new KUGIS coins can be minted. You could also airdrop coins for participants acting a certain way - such as delegating to a pool etc.

3
  • Not sure if I understand, can you clarify? It would be possible to build a reward system of a native token, but not through scripts having Rewarding ScriptContext purpose param. Instead one should use normal minting transactions and smart contracts addresses? How it would work? Commented May 26, 2022 at 17:56
  • 1
    StakeValidators are definitely not possible to use for native asset rewards, as they are strictly triggered only for actions involving the (de)registration of DCerts/ delegation to a new pool or withdrawal of rewards. So the only way to create a rewards scheme for native assets is via a minting policy or a combination of spending validator + minting policy.
    – Will
    Commented May 26, 2022 at 18:31
  • 1
    You could for instance let users create an output at a script address for a specific rewards scheme (storing the datetime they joined in the output datum) and then allow them to consume it in the future. Based on the amount of time they waited until they consume their output at the script address, they are eligible to mint a specific amount of your native tokens. Your spending validator script can check for the specific output and amount of the native tokens minted.
    – Will
    Commented May 26, 2022 at 18:34
3

To me, rewarding refers to Staking Pools Rewards (anybody can correct me on this), which for that, it is also my understanding that it uses a wallet address (rewarding wallet address) different of the payment wallet address (anybody can correct me on this too). For more information I'd invite to take a look at the documentation for apps related to staking.

On a tangent from this topic: Less than a week ago, Charles twitted that Cardano may be able to pay transaction fees in custom currencies (first blockchain to be capable of this): https://twitter.com/IOHK_Charles/status/1484193096178946048?cxt=HHwWgMCqvbzw9JgpAAAA

Paper title: Babel Fees via Limited Liabilities https://arxiv.org/pdf/2106.01161.pdf

I have not read the details of the paper but possibly then the rewards (your topic) will also be in those custom currencies.

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.