TON Part 2 — Contracts and Interaction¶
Learning goals¶
By the end of this lecture students should be able to:
- Trace the message cascade for a standard Jetton transfer.
- Explain wallet v4 checks: deadline, seqno, signature.
- Recognize deterministic address authentication for Jetton Wallets.
- Read Jetton Wallet state.
- Sketch off-chain TypeScript read/write code.
Wallet v4 behavior¶
When a signed external message arrives:
- Check deadline.
- Check seqno.
- Verify signature.
- Call
accept_message. - Fan out internal messages.
- Increment seqno.
Jetton transfer cascade¶
A Jetton transfer usually involves:
- User wallet receives signed external message.
- User wallet sends
op::transferto sender Jetton Wallet. - Sender Jetton Wallet sends
op::internal_transferto recipient Jetton Wallet. - Recipient Jetton Wallet credits the balance and may notify the owner wallet.
- Excess TON may be refunded.
Safety pattern¶
The recipient Jetton Wallet does not trust arbitrary messages. It recomputes the canonical sender Jetton Wallet address from the owner address, Jetton Master, and wallet code, then checks that the actual sender matches.
Bounces¶
If an internal transfer fails after the sender Jetton Wallet has debited balance, the bounce handler restores the balance. This is explicit compensation, not automatic rollback.