Concepts
The guard account
Where the snapshot lives, and why it cannot be reused.
Each owner has one guard account, a PDA of the program with the seeds ["guard", owner]. It is created once (init) and holds 1968 bytes: a header and up to ten snapshots of 192 bytes.
Layout
| Offset | Field |
|---|---|
| 0 | version |
| 1 | armed (1 between Begin and End) |
| 2 | number of watched accounts |
| 3 | bump |
| 8 | owner (32 bytes) |
| 40 | slot of the snapshot |
| 48 + 192 i | entry i: key, kind, flags, lamports, amount, program, token owner, delegate, delegated amount, close authority |
Why a snapshot cannot be replayed
Endrequiresarmed = 1and the snapshot slot equal to the current slot.Endreads the Instructions sysvar and requires aBeginfor this guard earlier in the same transaction.Endmust be the last instruction, so nothing can be added after the check.- Only the owner can use their guard: the owner must sign and the PDA is derived from their address.
Rent
The account keeps about 0.0146 SOL. Close returns it to the owner.