Plutus: Pioneers Program 4th cohort - Lecture 8 - Staking
We came over Cardano's staking mechanism over and over.
At some point, a reward transaction is emitted and, like Script and Minting, there are Validators:
mkStakeValidator () ctx = case scriptContextPurpose ctx of
Certifying _ -> True
Rewarding cred -> traceIfFalse "insufficient reward sharing" $ amount cred >= 1
_ -> False
where
info = scriptContextTxInfo ctx
amount cred = case PlutusTx.lookup cred $ txInfoWdrl info of
Just amt -> amt
Nothing -> traceError "withdrawal not found"
mkWrappedStakeValidator = wrapStakeValidator mkStakeValidator
stakeValidator = mkStakeValidatorScript $$(PlutusTx.compile )
If we have a closer look, all Validators are wrappers around Script:
newtype Validator = Validator Script
newtype MintingPolicy = MintingPolicy Script
newtype StakeValidator = StakeValidator Script
It takes the following steps to be activated:
- Build a stake address from the script (
cardano-cli stake-address build) - Build the payment address (
cardano-cli stake-address build) - Build stake registration and delegation certificates (
cardano-cli stake-address delegation-certificateandcardano-cli stake-address registration-certificate) - Build, sign, and submit the registration transaction with certificates and the stake script (
cardano-cli transaction build|sign|submit --certificate-*) - Build, sign, and submit the withdrawal transaction with the stake script (
cardano-cli transaction build|sign|submit --withdrawal-*)