1

Smart contract should allow the reward withdrawal only if all rewards are withdrawn. In other words only if the reward address will have exactly 0 lovelaces after the reward withdrawal. Is there any way/idea how to check this?

1 Answer 1

2

The ledger already enforces this rule. See "Reward accounts are set to zero for each corresponding withdrawal." in the Shelley ledger spec.

1
  • Thanks for your answer james! Yeah, I know about this. But the question is how can Plutus validator script get this info? As far as I know, all withdrawal data Plutus validator has is txInfoWdrl :: Map StakingCredential Integer. So, there is no any flags like 'Rewards are set to zero' or something like that. At the moment I use a stakeDeregistrationCert trick (it fails in case withdrawal amount < reward amount since stake address can be deregister only if reward amount = 0). However it's a bit expensive (tx fee) and complicated, and I'm trying to find a cheaper and easier way. Feb 6 at 14:31

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.