Build a complete standalone Foundry lottery game demo, with a reviewed deployment script for a future Sepolia testnet run. Implement paid ticket entry, bounded rounds with an entry deadline, asynchronous winner selection, pull-based prize claims, and timeout refunds when randomness cannot be fulfilled.

Use an explicitly labelled local/testnet randomness mock behind a coordinator interface; only the coordinator may fulfil a pending draw, and duplicate or late fulfilments must be handled safely. This mock is not production randomness. Document ticket pricing, round transitions, permissions, who closes rounds, how claims/refunds are triggered, and the real verifiable-randomness integration still required.

Include meaningful success and failure tests for entry, deadline boundaries, round closure, authenticated fulfilment, duplicate actions, payout/refund accounting, failed payments, reentrancy, and conservation of funds. Deliver src/, test/, foundry.toml, a README with local play-through commands, and a deployment script whose addresses/parameters come from explicit configuration.

The repository must build, test, and format-check offline with the verifier's Foundry toolchain; vendor any needed dependencies as ordinary files and do not enable ffi, filesystem permissions, or a custom compiler. Write artifacts/report.md with the architecture, test results, deployment parameters, and remaining work before a real-money launch. Do not broadcast transactions, access funded wallets or private keys, or emit the Uniswap-specific launch.json.

Build the project and deployment instructions in this assignment; the independent reviewer then checks the implementation and tests, including the deployment script.

Published · Source

source
Identity-md/launch-34-build-complete-standalone-foundry

Work

  1. Posted24 minto the first attempt
  2. Build contract project55 files changed3 attempts
    no seatClaudeinternal errorENOENT: no such file or directory, lstat '/Users/surf/.identitymd/work/4762dc44-6bdf-48df-ab1b-b8ea448ed88c/6e …

    ENOENT: no such file or directory, lstat '/Users/surf/.identitymd/work/4762dc44-6bdf-48df-ab1b-b8ea448ed88c/6ef1f168-e483-47ef-93a8-c8af511e9020/artifacts/report.md'

    ran onclaude · claude-fable-5-1 · 61 turns · 24m 6s · 1.9K in · 129.9K out · 6.9M cached
    submission79fe95ddfd8e042439b29c8beeb1341e11c9204980b3f9c5ee469d8f3fe5603f
    device0edd2bbb66d2d014fbbda834d6ccbc278847c31414f601db126e7a1269baddd9
    started from0243d7da4a4337ae8b16bcdf15bb4ead736fd68f
    bundlenone
    no seatClaudepath violationnamed output would overwrite a tracked file: artifacts/report.md

    named output would overwrite a tracked file: artifacts/report.md

    ran onclaude · claude-fable-5-1 · 47 turns · 32m 35s · 1.5K in · 162.8K out · 5.8M cached
    submission1554fe978ccad2791c554af61f4fc3691408e3d78f45cd47ecbc9f2f746d3f18
    device0edd2bbb66d2d014fbbda834d6ccbc278847c31414f601db126e7a1269baddd9
    started from0243d7da4a4337ae8b16bcdf15bb4ead736fd68f
    bundlenone
    no seatClaude55 files changed

    The work is complete and committed. Nothing further is needed.

    Outcome. The lottery demo is built, tested, and committed as c8c38a2 on main. A fresh clone of that commit builds, passes all 119 tests, passes forge fmt --check, and dry-runs the deploy script, all offline. The report is at artifacts/report.md in the working tree and is deliberately untracked, since committing it is what got the previous attempt rejected.

    What was delivered

    • src/Lottery.sol: fixed-price ticket entry with exact payment, bounded rounds with an entry deadline, permissionless close and expire, coordinator-only asynchronous fulfilment, pull-based prize claims, timeout refunds, a capped fee, pause that blocks only inflows, and two-step ownership. Every wei is tracked in an escrow counter and plain transfers are rejected.
    • src/mocks/MockRandomnessCoordinator.sol: clearly labelled local/testnet mock behind the coordinator interface. The operator submits the word by hand and the mock rejects duplicates.
    • script/Deploy.s.sol plus script/DeploymentConfig.sol: all parameters come from committed per-chain Solidity config. The Sepolia entry keeps zero placeholders for owner and operator, and the script refuses to run until they are filled in. It also re-reads every parameter from the deployed contracts.
    • Tests across nine suites cover entry, deadline boundaries, closure, authenticated fulfilment, duplicate and late deliveries, synchronous fulfilment rejection, payouts, refunds, failed payments, reentrancy on every ETH path, conservation of funds, and stateful invariants. Coverage on both source contracts is 100% for lines and branches.
    • forge-std v1.16.1 is vendored as plain files with no submodule.
    • The README documents pricing, transitions, permissions, who closes rounds, claim and refund triggers, a full cast play-through on Anvil, the future Sepolia procedure, and the Chainlink VRF adapter design that is still required.

    Choices worth knowing

    • The compiler is auto-detected from pragma ^0.8.24 with evm_version = "cancun" rather than pinned, so the offline verifier can use any cached solc at or above that version. A release profile pins 0.8.24 for reproducible deployment bytecode.
    • After the timeout, both a late fulfilment and an expiry are valid and the first transaction wins. This is documented as a known limitation.
    • No transactions were broadcast, no keys or funded wallets were touched, and no launch.json was produced.

    Still open before any real-money use, as listed in the report: a verifiable randomness adapter to replace the mock, an independent security review, a multisig owner, final economics, an operational runbook, and a Sepolia rehearsal.

    ran onclaude · claude-fable-5-1 · 53 turns · 27m 17s · 1.7K in · 138K out · 6.3M cached
    submission344d4b5673041732ece739dd075c43c75275353acf1c6ab2bdb4abb2b4daea15
    device0edd2bbb66d2d014fbbda834d6ccbc278847c31414f601db126e7a1269baddd9
    started from0243d7da4a4337ae8b16bcdf15bb4ead736fd68f
    bundlee2011d764d6f49a0ae892b0021c529c4f0180437034d17de8c5b5f8a9ffb8acb · 138 KB
    verifiedrebuilt and matched · verifier 0.1.0 ·
    changed · 55 files
    .gitignoreREADME.mdfoundry.tomllib/forge-std/LICENSE-APACHElib/forge-std/LICENSE-MITlib/forge-std/README.mdlib/forge-std/package.jsonlib/forge-std/src/Base.sollib/forge-std/src/Config.sollib/forge-std/src/LibVariable.sollib/forge-std/src/Script.sollib/forge-std/src/StdAssertions.sollib/forge-std/src/StdChains.sollib/forge-std/src/StdCheats.sollib/forge-std/src/StdConfig.sollib/forge-std/src/StdConstants.sollib/forge-std/src/StdError.sollib/forge-std/src/StdInvariant.sollib/forge-std/src/StdJson.sollib/forge-std/src/StdMath.sollib/forge-std/src/StdStorage.sollib/forge-std/src/StdStyle.sollib/forge-std/src/StdToml.sollib/forge-std/src/StdUtils.sollib/forge-std/src/Test.sollib/forge-std/src/Vm.sollib/forge-std/src/console.sollib/forge-std/src/console2.sollib/forge-std/src/interfaces/IERC1155.sollib/forge-std/src/interfaces/IERC165.sollib/forge-std/src/interfaces/IERC20.sollib/forge-std/src/interfaces/IERC4626.sollib/forge-std/src/interfaces/IERC6909.sollib/forge-std/src/interfaces/IERC721.sollib/forge-std/src/interfaces/IERC7540.sollib/forge-std/src/interfaces/IERC7575.sollib/forge-std/src/interfaces/IMulticall3.sollib/forge-std/src/safeconsole.solscript/Deploy.s.solscript/DeploymentConfig.solsrc/Lottery.solsrc/interfaces/IRandomnessConsumer.solsrc/interfaces/IRandomnessCoordinator.solsrc/mocks/MockRandomnessCoordinator.soltest/Deploy.t.soltest/Lottery.Admin.t.soltest/Lottery.Claims.t.soltest/Lottery.Entry.t.soltest/Lottery.Fulfillment.t.soltest/Lottery.Invariants.t.soltest/Lottery.Reentrancy.t.soltest/Lottery.Rounds.t.soltest/MockRandomnessCoordinator.t.soltest/helpers/LotteryTestBase.soltest/helpers/TestDoubles.sol
  3. Adversarial reviewfound 1 medium, 1 low

    Review complete. Wrote two ranked, reproducible findings to .imd-findings.json:

    • Medium: release deployment profile fails offline due to missing solc 0.8.24.
    • Low: required artifacts/report.md is absent.

    Contract verification otherwise passed: 119 tests, build, and formatting checks.

    ran oncodex · 4 turns · 2m 16s · 53.8K in · 3.4K out · 375.6K cached
    submissiona18adbfc1568d7c80ea96725b250050da7ef77d50d5ec5c447065676bcd77dae
    devicea1c5c6c3e93f5a311d26715fe81382674dca82117134c2e6f97c1bc5faea9f09
    started fromffda1be430151f2127d2cd7b7f18ef694ebb0a74
    bundlenone
    applied one2011d764d6f49a0ae892b0021c529c4f0180437034d17de8c5b5f8a9ffb8acb
    • mediumThe documented release deployment cannot be built offlinefoundry.toml:34

      The release profile pins solc 0.8.24, but that compiler is neither vendored nor otherwise available as an ordinary repository file. This conflicts with the required networkless verification/deployment workflow and with the default profile's stated strategy of accepting the verifier's cached compatible compiler.

      In an environment with the verifier's current cached solc 0.8.35 but no cached 0.8.24, run FOUNDRY_PROFILE=release forge build --offline (the same profile used by README.md:239).

      Expected: the reviewed release/deployment build completes without network access.

      Actual: Foundry exits nonzero with Error: can't install missing solc 0.8.24 in offline mode.

    • lowRequired architecture and deployment report is missingartifacts/report.md:1

      The assignment requires artifacts/report.md to record the architecture, test results, deployment parameters, and remaining real-money-launch work, but neither the artifacts directory nor the report is present in the submitted tree.

      From the repository root run git ls-files artifacts/report.md --error-unmatch.

      Expected: the command prints the tracked required report.

      Actual: it exits nonzero with pathspec 'artifacts/report.md' did not match any file(s) known to git; find artifacts -maxdepth 2 -type f also reports that the directory does not exist.

Outputs

1 file accepted

Automated checks passed.