Tasks
Create task
Inputs
Metadata: string; an uri to locate the json file describing the metadata of this task.
Deadline: uint64; unix time stamp (in seconds) before which the task should be finished. If not finished before the deadline, the task can be refunded by the manager.
Budget: ERC20Transfer[] (tuple(address,uint96)); a list of ERC20 contract addresses and the amount of this token that is up for budget. At task creation this amount of ERC20 tokens will be transfer from the sender of the transaction to an escrow contract. This means the Tasks contract should be approved to spend this amount of ERC20 tokens beforehand.
Manager: address; the address that will have the permission to manage the task, such as approving applicants and reviewing submissions. This allows the funder to give this responsibility to someone else.
Preapprove: PreapprovedApplication[] (tuple(address, Reward[] (tuple(bool, address, uint88))); these addresses will get an approved application on task creation. This can be used to save gas on internal tasks or motivate a contributor to take your task, by making it easier for them to take it.
Outputs
TaskId: uint256; the id of the newly created task. Note: currently Solidity does not give the return value of transactions, you can extract this id from the TaskCreated event in the transaction receipt logs instead.
Code
```solidity
function createTask(
string calldata _metadata,
uint64 _deadline,
ERC20Transfer[] calldata _budget,
address _manager,
PreapprovedApplication[] calldata _preapprove
) external returns (uint256 taskId) {
_ensureNotDisabled();
taskId = taskCounter++;
Task storage task = tasks[taskId];
task.metadata = _metadata;
task.deadline = _deadline;
task.budgetCount = uint8(_budget.length);
Escrow escrow = Escrow(Clones.clone(escrowImplementation));
escrow.__Escrow_init();
task.escrow = escrow;
for (uint8 i; i < uint8(_budget.length); ) {
_budget[i].tokenContract.transferFrom(
_msgSender(),
address(escrow),
_budget[i].amount
);
task.budget[i] = _budget[i];
unchecked {
++i;
}
}
task.manager = _manager;
task.creator = _msgSender();
// Default values are already correct (save gas)
// task.state = TaskState.Open;
unchecked {
// Impossible to overflow due to openTasks <= taskCounter
++openTasks;
}
// Gas optimization
if (_preapprove.length > 0) {
task.applicationCount = uint16(_preapprove.length);
for (uint16 i; i < uint16(_preapprove.length); ) {
Application storage application = task.applications[i];
application.applicant = _preapprove[i].applicant;
application.accepted = true;
_ensureRewardEndsWithNextToken(_preapprove[i].reward);
_setRewardBellowBudget(
task,
application,
_preapprove[i].reward
);
unchecked {
++i;
}
}
}
emit TaskCreated(
taskId,
_metadata,
_deadline,
_budget,
_msgSender(),
_manager,
_preapprove
);
}
```Apply for task
Inputs
TaskId: uint256; the id of the task that you want to apply for.
Metadata: string; the uri pointing to the json metadata of your application.
Reward: Reward[] (tuple(bool, address, uint88)); the desired reward if you manage to complete the task succesfully.
Outputs
ApplicationId: uint16; the id of the newly created application.
Code
Accept applications
Inputs
TaskId: uint256; the id of the task you want to accept applications of.
ApplicationIds: uint16; the ids of the applications you want to accept.
Code
Take task
Inputs
TaskId: uint256; the id of the task you want to take.
ApplicationId: uint16; the id of your applications, which has been accepted.
Code
Create submission
Inputs
TaskId: uint256; the id of the task you want to make a submission for.
Metadata: string; the uri pointing to your submission data.
Outputs
SubmissionId: uint8; the id of the newly created submission.
Code
Review submission
Inputs
TaskId: uint256; the id of the task you want to review a submission of.
SubmissionId: uint8; the id of the submission you want to review.
Judgement: SubmissionJudgement (uint8); if you accept the submission as completion of the task.
Feedback: string; the uri explaining why you made your decision.
Code
Cancel task
Inputs
TaskId: uint256; the id of the task you wish to cancel.
Explanation: string; the uri to why you would like to cancel this task.
Outputs
CancelTaskRequestId: uint8; in case the task is able to be cancelled instantly, this will return 255. Otherwise it will return the id of the request that has been made.
Code
Accept request
Inputs
TaskId: uint256; the id of the task you want to accept a request from.
RequestType: RequestType (uint8); the type of request you want to accept.
RequestId: uint8; the id of the request you want to accept.
Execute: bool; if you want to execute the request in this transaction.
Code
Execute request
Inputs
TaskId: uint256; the id of the task you want to execute a request from.
RequestType: RequestType (uint8); the type of request you want to execute.
RequestId: uint8; the id of the accepted request you want to execute.
Code
Extend deadline
Inputs
TaskId: uint256; the id of the task you want to extend the deadline of.
Extensions: uint64; how many seconds to increase the deadline by.
Code
Increase budget
Inputs
TaskId: uint256; the id of the task you want to increase the budget of.
Increase: uint96[]; the amount to increase the budget by. This array should be the same length as the budget array. Each item will increase the budget entry with the same array index.
Code
Edit metadata
Inputs
TaskId: uint256; the id of the task you want to edit the metadata of.
NewMetadata: string; the uri of the new metadata of this task.
Code
Last updated
