Escrow.sol
The escrow smart contract is an integral part of HUMAN Protocol's ecosystem, designed to ensure secure and transparent transactions between job requesters and workers. It leverages the ERC20 token standard to manage escrow funds, providing a trustless platform for facilitating payments upon the successful completion of tasks.
Key Features and Components
ERC20 Token Compatibility
The contract supports transactions with any ERC20 compliant token, allowing for flexible payment options within the ecosystem.
Trusted Handlers
Designated addresses have privileged access to perform critical operations within the contract, enhancing security and control over the escrow process.
Oracle Integration
The contract interacts with specialized oracles, each serving a distinct purpose:
Reputation Oracle: Evaluates worker performance and determines the distribution of rewards based on worker reputation.
Recording Oracle: Records task completion and worker performance.
Exchange Oracle: Facilitates the distribution of tasks to workers, ensuring efficient task allocation and completion.
Bulk Payment Functionality
Supports bulk transfer operations to distribute payments to multiple recipients efficiently.
Dynamic Fee Structure
Oracle fees are predetermined and automatically deducted from payouts, ensuring fair compensation for oracle services.
Contract Status Management
The contract's lifecycle is managed through various statuses, ensuring that operations are executed in a logical sequence.
Workflow/Functions
Initialization
Upon deployment, the contract is initialized with essential parameters such as the ERC20 token address, launcher, and canceler addresses, and the contract duration. Trusted handlers can be specified during this phase to facilitate secure operations.
Setup
The setup function is invoked to specify the oracles and their corresponding fees, which are passed as percentage values, along with the job manifest. This action transitions the contract to a Pending
status, signifying its readiness to receive funds and begin operations.
Can be called by:
Trusted handlers.
Conditions:
Not expired.
Funding
Funds can be deposited into the contract at any stage. A getBalance
function is available to monitor the contract's balance. Trusted entities can initiate bulk payouts based on task completion, with the contract ensuring that oracle fees are paid.
Store Results
The contract allows for the storage of intermediate results. This ensures traceability of results throughout the escrow process.
Can be called by:
Recording Oracle
Trusted handlers.
Conditions:
Not expired.
Status is
Pending
orPartial
.
Bulk Payouts
Store final results and perform pay out of rewards to workers and fees to oracles.
Can be called by:
Reputation Oracle
Trusted handlers.
Conditions:
Not expired.
Balance > 0.
Status is
Pending
orPartial
.Status is not
Paid
.
Complete
This function sets the contract to Complete
state, symbolizing the successful conclusion of all escrow activities and settlements.
Can be called by:
Reputation Oracle
Trusted handlers.
Conditions:
Not expired.
Status is
Paid
.
Cancel
Cancellation returns funds to the canceler and destroys the contract. Ensures that cancellation is only possible before final settlements.
Can be called by:
Trusted handlers.
Conditions:
Balance > 0.
Status is not
Paid
orComplete
.
Security and Trust
The contract employs multiple security measures, including reentrancy guards and modifiers, to ensure operations are executed by authorized parties and under appropriate conditions. It also emits events for key operations, allowing external monitoring and interaction with the contract's activities.
Last updated