EscrowFactory.sol
The EscrowFactory contract is a smart contract designed to facilitate the creation of Escrow contracts within the HUMAN Protocol ecosystem. It allows users to create escrow instances for secure and transparent transactions between job requesters and workers.
Key Features and Components#
ERC-20 Token Compatibility#
The factory supports the creation of escrows utilizing any ERC-20 compliant token, ensuring a wide range of payment options.
Staking Requirement#
Users must maintain a minimum stake (in HMT tokens) to create an escrow. This requirement integrates platform utility with token economics, ensuring that only committed users can initiate escrows.
Standardized Duration#
All escrows created through the factory have a predefined duration, standardizing the timeline for escrow completion.
Ownership and Upgradeability#
Utilizes OpenZeppelin's OwnableUpgradeable and UUPSUpgradeable for contract ownership and upgradeable functionality, ensuring secure management and the ability to introduce future improvements.
Escrow Tracking#
The contract maintains a counter of created escrows and provides functionalities to query the existence and details of individual escrows
Event Emission#
Events are emitted upon the creation of new escrows, providing transparency and traceability of operations.
Workflow/Functions#
Initialization#
This function initializes the factory by:
- Setting the staking contract address, ensuring that only users with sufficient stakes can create escrows.
- Configuring the minimum stake requirement.
- Initializing ownership via OpenZeppelin’s upgradeable pattern.
- Sets the admin address for the escrows that the factory will create.
- Ensuring the contract is ready for escrow creation.
Escrow Creation:#
Users with sufficient HMT token stakes can invoke the createEscrow function.
- Checks that the caller’s available stake meets the minimum requirement.
- Deploys a new Escrow contract with a standardized duration.
- Increments the internal counter and maps the new escrow’s address.
- Emits an event (
LaunchedV2) with details of the created escrow. - Can be called by:
- Anyone.
- Conditions:
- HMT stake > 0.
- Parameters:
- Funding token address.
- Fund amount.
- Job requester ID.
Escrow Creation Fund and Setup:#
Users with sufficient HMT token stakes can invoke the createFundAndSetupEscrow function to create, fund and setup an escrow.
Info
To be able to call this function you need to increase the allowance of the token at least with amount desired to fund the escrow.
- Checks that the caller’s available stake meets the minimum requirement.
- Deploys a new Escrow contract with a standardized duration.
- Funds and sets up the escrow.
- Increments the internal counter and maps the new escrow’s address.
- Emits an event (
LaunchedV2) with details of the created escrow. - Can be called by:
- Anyone.
- Conditions:
- HMT stake > 0.
- Parameters:
- Funding token address.
- Fund amount.
- Job requester ID.
- Reputation Oracle address.
- Recording Oracle address.
- Exchange Oracle address.
- Reputation Oracle fee.
- Recording Oracle fee.
- Reputation Oracle fee.
- Manifest url.
- Manifest hash.
Has Escrow#
The hasEscrow function allows checking if a given address corresponds to a created escrow.
-
Can be called by:
- Anyone.
Upgradeability#
Through the UUPSUpgradeable pattern, the contract owner can propose upgrades to the Escrow Factory, allowing for future enhancements and adjustments without disrupting existing operations.
- Can be called by:
- Owner.
Security and Trust#
The Escrow Factory Smart Contract embeds multiple layers of security and trust mechanisms, including staking requirements for escrow creation, ownership controls for critical operations, and upgradeability for future improvements. The contract's design prioritizes transparency, security, and efficiency, making it a foundational component of its ecosystem for managing escrow processes on a scalable and reliable platform.