A beneficiary collects 50 ETH halfway through a 100 ETH grant. The sponsor deposits another 60 ETH on the same day. How much can the beneficiary collect again immediately?
30 ETH on the original schedule. Zero on a new schedule for each deposit. Vault Replay runs both policies in Solidity, records the calls, and lets you turn any checkpoint into a Foundry regression test. All amounts in the demo are local test funds.
Open the interactive replay · Download the offline HTML
Open the Solana counter replay. The three steps show the serialized account before dispatch, the instruction discriminator and the account after dispatch. The recording in replay/counter-recording.json contains the byte arrays printed by the native Rust test with cargo test --locked -p counter-lab --test dispatch -- --show-output. The browser decodes the little-endian account value from the saved bytes and works offline.
- Open Midpoint top-up at step 4. Both recipients have already received 50 ETH. The original schedule now vests half of 160 ETH, leaving 30 ETH due. The latest per-deposit installment is zero seconds old.
- Advance one step. The original vault pays 30 ETH. The second returns its
NothingDueerror. Open Inspect exact balances in wei to see the actual call outcomes and beneficiary balances. - Select Export Foundry test. Place the downloaded file in this checkout’s
test/directory and run the command shown in the viewer. The test repeats every call through the selected step and asserts both vaults’ balances after each one. Use Save JSON receipt for the inputs, raw readings, and SHA-256 fingerprints.
| Replay | Decision it exposes |
|---|---|
| Midpoint top-up | Should a top-up inherit elapsed vesting time? |
| After maturity | Can a new deposit become fully payable on arrival? |
| The last wei | When two 1-wei installments are half vested, do you round each installment or the pooled grant? |
With Foundry installed and the submodule initialized (see below), run this from the repository root:
forge test --match-test test_MidpointTopUpCreatesThirtyEtherGap -vvStep 4 of the replay records a 60 ETH top-up halfway through the grant. The regression test checks the resulting 30 ETH available on the original clock and zero on the per-deposit clock. In the companion Anchor Counter Lab, a native Rust test checks the account bytes after a single Solana instruction.
Use Git, Foundry v1.7.1, and Node.js 22 or newer. Foundry fetches the pinned Solidity 0.8.30 compiler on its first build. The browser replay itself runs offline from the single index.html file.
git clone --recurse-submodules https://github.com/dreddxyz/secure-vault.git
cd secure-vault
forge fmt --check
forge test --fuzz-seed 0x5641554c54 -vv
node replay/build.mjs --check
node replay/check-exports.mjsThe first suite includes 12 unit and fuzz tests and five stateful properties. For each property, Foundry runs 128 sequences of 64 handler calls. The handler funds, advances time, and collects while maintaining its own deposit ledger. The properties check funding totals, cash conservation, beneficiary receipts, entitlement against an independent calculation, and the ordering of the two vesting policies. The final command compiles and runs all 19 downloadable checkpoint tests. Those tests preserve observed outcomes for regression comparison. The independent ledger tests check the vesting rule itself.
Edit a scenario in cases.json. Steps use ordered whole days relative to the grant start. A fund step takes a positive decimal string in the scenario’s display unit. collect requests payment and observe reads state. focus is the zero-based step initially selected by the viewer.
node replay/build.mjs
node replay/check-exports.mjsOpen the regenerated index.html. The recorder deploys two independent vaults in a local EVM, calls each one, and returns the results. The build checks conservation, actual recipient balances, and available amounts before embedding the receipts. The browser formats those readings and joins chart samples with lines. Recording requires no RPC endpoint, account, or signing key.
- The vault holds native ETH. Its sponsor, beneficiary, start, duration, and clock policy are immutable. Only the sponsor can fund. Anyone can trigger a payment to the named beneficiary.
- The original clock pools all deposits. A per-deposit clock starts at the later of the grant start and deposit time. Its 32-installment lifetime limit bounds the cost of each release. Each installment rounds down to whole wei until maturity.
- Entitlement at a timestamp uses all deposits currently recorded. Historical receipts capture what each vault actually knew at that step. Only ETH accepted through
fund()enters the grant ledger. Unsolicited ETH can remain stranded. - A beneficiary contract must be able to receive ETH. A failed payment reverts the accounting and can be retried. The sponsor has no recovery, cancellation, or upgrade authority. This unaudited portfolio experiment is intended for local use.
