a solana smart contract, written in anchor framework. This is part of real use case and implementation of bounty hunting in return of task execution.
If you are interested to learn from it. It utilizes following constructs/features from solana
- Program owned accounts
- Program owned token accounts
- Cross Program Invocation (CPI)
- SPL token creation
- SPL token minting
- SPL token account authority transfer,
- SPL token transfer
KOII solana smart contract allows it's user to submit task it wants exectutor to excute. In return executor get bounty as reward for executing the task.
- user submits task and bounty token amount he is willing to pay in return
- a new bounty token account is created
- it's ownership is set to program
- bounty tokens are transferred to newly created bounty token account
- task metadata including bounty publickey is stored in pda associated with task.
- an executor interested in the bounty assigns assigns tasks to himself
- executor nominates itself as executor of the specific task
- updates metadata of task
- When the task is completed voting on task starts
- In order to be able to vote on tasks
- one has to stake tokens and earn voting power
- staking transfers tokens from stakers token account to program owned stake token account
- Eligible voters cast vote in favour of task, successful vote update task pda
- In order to be able to vote on tasks
- When sufficient votes have been casted task executor claims the bouty
- Program transfer bounty tokens from bounty account to executors token account