Raiders Contracts will allow anyone to create bounties for community members to earn rewards for taking specific actions.
NOTE - This set of validators limits one user IO currently, however it is designed with it is designed with future updates in mind, however, so you will be able to do the w0 optimisation to increase this throughput limitation, or to add new features to the validators without affecting pre-existing user bounties
To use these you will need to complete the setup transaction to mint your RefToken
first, with the following Datum:
RefDatum {
v: [raidValHash], // parameterised scriptHash of raidVal
i: [0n] // 0 fee list, unused currently but available for future changes
} Once you have your refToken it will need to be added as a reference input to each transaction that mints a Bounty as it will control the RaidToken output ( to make sure it is sent to the validator ).
There are a few validators we will be using:
raidMint - This is the minting policy for RaidTokens
raidVal - This locks RaidTokens with their rewards
refMint - This minting policy creates a reference token used to hold the validator Dapp state
refVal - locks the RefToken with the Dapp state datum
When a user wants to create a Raid, they will mint a token with this policy and send it
to the raidVal.
It will require to have a specific datum which contains:
type RaidDatum {
q: Int // Bounty Quantity
v: Int // Bounty Value (in ADA)
c: VerificationKeyHash // Users PubKeyHash
}They will also need to deposit the appropriate amount of ADA ((q * v + 2) * 1000000)
To burn the RaidToken and remove the bounty the transaction must be signed by the owner
of the bounty (RaidDatum.c)
When someone completes a bounty they can withdraw the given reward.
The bounty rewards info is held within the given RaidToken and will enforce the rewards
that can be withdrawn.
This validator requires a signature from Raiders infrastructure wallet which will allow us to verify the bounty has been completed and will prevent anyone from trying to exploit the contract.
If the Raid owner wants to update their bounty to increase rewards or close the bounty, they can do so aswell.
To update the bounty they will need to make sure to maintain an ADA value at that matches the rewards calculation ((q * v + 2) * 1000000).
This means they cant create a bounty, then withdraw the rewards themselves and get free interactions with no rewards for participants.
They can also close a bounty with their signature if there are no more rewards available.
This minting policy is for the Raid Dapp to create a StateToken which will be provided
as a reference input to allow for validator upgradeability.
The reference input controls where RaidTokens are sent after mint so we can change the
raidVal in the future to add different features to the Dapp without trying to organise a
mass migration of users to the new validator ( we have seen with other projects that this
doesn't work and can get very messy ).
All we need to do is update the RefDatum with the new validator hash and it will become
the new destination for all future bounties.
This will allow us to increase the complexity of our services easily without affecting pre-existing bounties.
This is the locking validator for our StateToken
Changes can only be made with our InfrastructureWallet meaning that as long as we sign
we can do whatever we need with our reference token.
The main data points we need for the validators are
RaidDatum - containing all of the Raid details
RefDatum - containing the ScriptHash of the RaidValidator in a list ( to allow for upgradability to w0 optimisation or other features) & any fees or other values in a list ( to add fees etc in the future)
aiken buildYou can write tests in any module using the test keyword. For example:
test foo() {
1 + 1 == 2
}To run all tests, simply do:
aiken checkTo run only tests matching the string foo, do:
aiken check -m fooIf you're writing a library, you might want to generate an HTML documentation for it.
Use:
aiken docsFind more on the Aiken's user manual.