Validate balance conservation in a Mina custom-token approval

A custom token's approval method receives a forest of account updates. Validating a displayed sender and recipient alone can overlook additional balance changes in that forest.

Compare the complete update forest

For transfer-only approval, use the TokenContract conservation helper where it matches your policy. Supply the actual update forest to checkZeroBalanceChange inside approveBase. The example's first transfer balances; the second would create an extra unit. Test a third case in which a nested update introduces that unit outside the displayed pair.

forest A: Alice -9, Bob +9 → net 0
forest B: Alice -9, Bob +10 → net +1

Specify minting separately

Zero net change enforces a supply property for the checked updates. It cannot decide whether a particular recipient is allowed or whether an authorized issuer should mint new units. Define those policy checks explicitly and test the transfer interface independently of issuance methods.

Sources