Escrow.sol

The HUMAN Protocol Escrow Smart Contract is an integral part of the HUMAN Protocol ecosystem, designed to ensure secure and transparent transactions between job requesters and workers. It leverages the ERC-20 token standard to manage escrowed funds, providing a trustless platform for facilitating payments upon the successful completion of tasks.

Key Features and Components

ERC-20 Token Compatibility

The contract supports transactions with any ERC-20 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

Initialization

Upon deployment, the contract is initialized with essential parameters such as the ERC-20 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 or Partial.

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 or Partial.

    • 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 or Complete.

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

Logo

© 2023 HPF. HUMAN Protocol® is a registered trademark