Skip to content

feat(tokens/hackathon): Squads-multisig hackathon prize program#40

Open
mikemaccana wants to merge 1 commit into
mainfrom
claude/solana-skill-review-4PfQ4
Open

feat(tokens/hackathon): Squads-multisig hackathon prize program#40
mikemaccana wants to merge 1 commit into
mainfrom
claude/solana-skill-review-4PfQ4

Conversation

@mikemaccana

@mikemaccana mikemaccana commented May 29, 2026

Copy link
Copy Markdown
Collaborator

What this adds

An Anchor 1.0 example at tokens/hackathon/anchor: a hackathon prize program whose authority is an external Squads multisig vault PDA. The program is multisig-agnostic — it stores one authority pubkey and checks signer == hackathon.authority on committee-only handlers, leaving the propose/vote/execute flow to Squads.

Design

  • One hackathon, many prizes. Each prize has its own PDA and its own vault ATA (owned by the prize PDA) that holds the prize in escrow.
  • Committee vs. permissionless. create_hackathon, add_prize, set_winner, cancel_prize, and close_hackathon require the committee's signature. pay_winner is permissionless, so once the committee has recorded a winner, anyone can deliver the payout without the committee staying online.
  • Token interface throughout (anchor_spl::token_interface), so the same compiled program works for both the Classic Token Program and the Token Extensions Program. One mint per prize lets a hackathon mix denominations (e.g. USDC for cash, a tokenized stock for a themed track).
  • Safety: add_prize rejects zero amounts; pay_winner transfers exactly prize.amount via transfer_checked and marks the prize paid before the CPI; prize tokens live in program-owned vault PDAs with no admin escape outside the documented handlers.
  • The hackathon name is hashed into its PDA seed via the sol_sha256 syscall (solana-sha256-hasher), with an sha2 fallback for host/IDL builds.

Handlers

Handler Signer Accounts created / changed
create_hackathon Committee Creates Hackathon.
add_prize Committee Creates Prize + vault ATA; increments prize_count.
set_winner Committee Sets Prize.winner.
pay_winner Anyone Moves tokens vault → winner; sets Prize.paid.
cancel_prize Committee Refunds vault; closes it; sets Prize.cancelled.
close_hackathon Committee Closes Hackathon once every prize is resolved.

Tests

Rust + LiteSVM integration tests build a real Squads v4 2-of-3 multisig and drive the full propose/vote/execute flow — happy path, failure cases (zero amount, no winner, under-funded, already paid, non-committee signer), and lifecycle (cancel and close). Run with:

cd tokens/hackathon/anchor
cargo build-sbf
cargo test

Docs

The README covers the concepts for newcomers (with links to definitions on first use), a worked walkthrough with named committee members and sample tokens (USDC, NVDAx, TSLAx), the account layout, and the handler-to-account mapping.

https://claude.ai/code/session_01DBFPwFobdi4SKkDq4BZdd8

Adds an Anchor 1.0 example at tokens/hackathon/anchor: a hackathon prize
program whose authority is an external Squads multisig vault PDA. The
program is multisig-agnostic — it stores one authority pubkey and checks
signer == hackathon.authority on committee-only handlers, leaving the
propose/vote/execute flow to Squads.

- One hackathon, many prizes. Each prize has its own PDA and its own vault
  ATA (owned by the prize PDA) that holds the prize in escrow.
- Committee-only handlers: create_hackathon, add_prize, set_winner,
  cancel_prize, close_hackathon. pay_winner is permissionless so anyone can
  deliver a payout the committee has already agreed on.
- add_prize rejects zero amounts. pay_winner transfers exactly prize.amount
  via transfer_checked and marks the prize paid before the CPI.
- anchor_spl::token_interface throughout, so the same program works for both
  the Classic Token Program and the Token Extensions Program.
- The hackathon name is hashed into its PDA seed via the sol_sha256 syscall
  (solana-sha256-hasher), with an sha2 fallback for host/IDL builds.
- Rust + LiteSVM tests build a real Squads 2-of-3 multisig and drive the full
  propose/vote/execute flow: happy path, failure cases, and lifecycle.
- README covers the concepts for newcomers, a worked walkthrough, the account
  layout, and the handler-to-account mapping.
@mikemaccana mikemaccana force-pushed the claude/solana-skill-review-4PfQ4 branch from e940809 to dd6b78d Compare May 31, 2026 14:24
@mikemaccana mikemaccana changed the title feat(tokens/hackathon): Squads-multisig hackathon prize program + skill review fixes feat(tokens/hackathon): Squads-multisig hackathon prize program May 31, 2026
mikemaccana pushed a commit that referenced this pull request Jun 4, 2026
These three Anchor examples were already migrated to Anchor 1.0.0 with
complete Rust (litesvm/solana-kite) test suites, but were still listed in
.ghaignore for reasons that no longer apply:

- finance/escrow/anchor: old reason was a JS helpers bug (#40); the test
  is now pure Rust, so that bug is irrelevant. Verified: anchor test green
  (4/4 + lib test).
- finance/token-swap/anchor: verified anchor build + 18/18 tests pass.
- tokens/external-delegate-token-master/anchor: verified 3/3 tests pass.

All three verified locally with Anchor 1.0.0, Solana CLI, and surfpool,
matching the CI flow (anchor keys sync -> anchor build -> anchor test).

Also clarifies basics/pyth/anchor's ignore reason: it fails because
pyth-solana-receiver-sdk 1.1.0 pulls a borsh version incompatible with
Anchor 1.0 / Solana 3.x (PriceUpdateV2 fails BorshDeserialize). Left
ignored pending a compatible upstream SDK.

https://claude.ai/code/session_013dpnF6uSGWXjkJJZseqzcP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants