Docs
Smart contract reference
Program ID, PDA seeds, accounts, instructions, errors and events, straight from lib.rs.
Program
- Item
- Program ID
48KEXpcdXgpeqTaZW2whYrWz823yewZxAr3x4cYh4S3W
- Item
- Framework
- Anchor 0.30.1
- Item
- Cluster
- Devnet
- Item
- Source
PDA seeds
- Account
- Bounty
[b"bounty", sponsor, bounty_id.to_le_bytes()]
- Account
- Vault
[b"vault", bounty](SPL token account, authority = Bounty PDA)
- Account
- Submission
[b"submission", bounty, creator](one per creator per bounty)
const bounty = PublicKey.findProgramAddressSync(
[Buffer.from("bounty"), sponsor.toBuffer(), bountyId.toArrayLike(Buffer, "le", 8)],
programId
)[0];
const vault = PublicKey.findProgramAddressSync([Buffer.from("vault"), bounty.toBuffer()], programId)[0];
const submission = PublicKey.findProgramAddressSync(
[Buffer.from("submission"), bounty.toBuffer(), creator.toBuffer()],
programId
)[0];Account data
Bounty
- Field
- sponsor
- Type
- Pubkey
- Notes
- Creator of the bounty; the only wallet that can approve, reject and reclaim
- Field
- mint
- Type
- Pubkey
- Notes
- Token mint of the prize
- Field
- reward_per_winner
- Type
- u64
- Notes
- Base units (USDC has 6 decimals)
- Field
- max_winners
- Type
- u16
- Field
- paid_count
- Type
- u16
- Notes
- Number of approved submissions
- Field
- submission_count
- Type
- u32
- Field
- deadline
- Type
- i64
- Notes
- Unix seconds
- Field
- status
- Type
- enum
- Notes
OpenorClosed
- Field
- title
- Type
- String
- Notes
- ≤ 64 bytes
- Field
- description
- Type
- String
- Notes
- ≤ 280 bytes
- Field
- bump / vault_bump
- Type
- u8
- Notes
- PDA bumps
- Field
- bounty_id
- Type
- u64
- Notes
- Part of the PDA seeds
Submission
- Field
- bounty
- Type
- Pubkey
- Field
- creator
- Type
- Pubkey
- Field
- link
- Type
- String
- Notes
- 1–200 bytes
- Field
- status
- Type
- enum
- Notes
Pending,ApprovedorRejected
- Field
- paid_amount
- Type
- u64
- Notes
- 0 until approved
- Field
- paid_at
- Type
- i64
- Notes
- Unix seconds, 0 until approved
- Field
- bump
- Type
- u8
create_bounty
create_bounty(bounty_id: u64, title: String, description: String,
reward_per_winner: u64, max_winners: u16, deadline: i64)Accounts: sponsor (signer, mut), mint, bounty (init PDA), vault (init token account, authority = bounty), sponsor_ata (mut, mint = mint, authority = sponsor), token_program, system_program.
reward_per_winner > 0,max_winners > 0.titleis 1–64 bytes;descriptionis at most 280 bytes.deadlineis later than the current chain time.total = reward_per_winner × max_winnersis checked for overflow, then transferred fromsponsor_atatovaultwithtransfer_checked.- Emits
BountyCreated.
submit_clip
submit_clip(link: String)Accounts: creator (signer, mut), bounty (mut), submission (init PDA), system_program.
linkis 1–200 bytes.- Bounty status is
Openand the current time is beforedeadline. - Creating the submission PDA fails if the creator already entered, which enforces one entry per creator.
- Increments
submission_count. EmitsSubmissionCreated.
approve_submission
approve_submission()Accounts: sponsor (signer, mut), bounty (mut, has_one = sponsor, has_one = mint), submission (mut, has_one = bounty, has_one = creator), creator, mint, vault (mut), creator_ata (init_if_needed associated token account, payer = sponsor), token_program, associated_token_program, system_program.
- Bounty is
Open, submission isPending, andpaid_count < max_winners. - Transfers
reward_per_winnerfrom the vault to the creator's token account, signed by the Bounty PDA. - Sets the submission to
Approvedwithpaid_amountandpaid_at, then incrementspaid_count. - Allowed after the deadline until the sponsor reclaims. Emits
PayoutEvent.
reject_submission
reject_submission()Accounts: sponsor (signer), bounty (has_one = sponsor), submission (mut, has_one = bounty). Requires the submission to be Pending; sets it to Rejected. Emits RejectEvent.
reclaim_unspent
reclaim_unspent()Accounts: sponsor (signer), bounty (mut, has_one = sponsor, has_one = mint), mint, vault (mut), sponsor_ata (mut), token_program.
- Bounty is
Openand the current time is at or afterdeadline. - Sets the bounty to
Closedbefore transferring the entire remaining vault balance tosponsor_ata. A second call fails withBountyClosed. - Emits
ReclaimEventwith the amount returned.
Errors
- Code
- 6000
- Name
- InvalidReward
- Message
- Reward per winner must be greater than zero
- Code
- 6001
- Name
- InvalidMaxWinners
- Message
- Max winners must be greater than zero
- Code
- 6002
- Name
- DeadlineInPast
- Message
- Deadline must be in the future
- Code
- 6003
- Name
- TitleTooLong
- Message
- Title must be 1-64 bytes
- Code
- 6004
- Name
- DescriptionTooLong
- Message
- Description must be at most 280 bytes
- Code
- 6005
- Name
- LinkTooLong
- Message
- Link must be 1-200 bytes
- Code
- 6006
- Name
- MathOverflow
- Message
- Arithmetic overflow
- Code
- 6007
- Name
- Unauthorized
- Message
- Only the bounty sponsor can do this
- Code
- 6008
- Name
- BountyClosed
- Message
- Bounty is closed
- Code
- 6009
- Name
- DeadlinePassed
- Message
- Submission deadline has passed
- Code
- 6010
- Name
- DeadlineNotReached
- Message
- Deadline has not been reached yet
- Code
- 6011
- Name
- SubmissionNotPending
- Message
- Submission is not pending
- Code
- 6012
- Name
- MaxWinnersReached
- Message
- Maximum number of winners already paid
Events
- Event
- BountyCreated
- bounty, sponsor, mint, bounty_id, reward_per_winner, max_winners, deadline, total_escrowed
- Event
- SubmissionCreated
- bounty, creator, submission
- Event
- PayoutEvent
- bounty, submission, creator, amount, paid_count, timestamp
- Event
- RejectEvent
- bounty, submission, creator
- Event
- ReclaimEvent
- bounty, sponsor, amount
