<p>The ledger already enforces this rule. See &quot;Reward accounts are set to zero for each corresponding withdrawal.&quot; in the <a href="https://github.com/intersectmbo/cardano-ledger/releases/latest/download/shelley-ledger.pdf" rel="nofollow noreferrer">Shelley ledger spec</a>.</p>

CC BY-SA 4.0
2024-02-06T14:31:35.940Z
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.
dmitry_stas
CC BY-SA 4.0
2024-02-05T07:50:46.423Z
2024-02-05T07:50:46.423Z
james
<p>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?</p>

<plutus>
Is there any way to check reward address value?
# Is there any way to check reward address value?

(Asked by: username_0 on 2024-02-03)

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?

**Tags:** plutus

---

## 1 answers

### Answer by username_1 on 2024-02-05. Score: 2

The ledger already enforces this rule. See "Reward accounts are set to zero for each corresponding withdrawal." in the [Shelley ledger spec](https://github.com/intersectmbo/cardano-ledger/releases/latest/download/shelley-ledger.pdf).

> **Comments:**
> **username_0**: 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.  

---

