This project implements an upgradeable escrow system using Solidity. The escrow contract allows users to deposit, claim, and redeem ERC20 tokens or Ether under time-based constraints. The system is designed with gas efficiency, security, and flexibility in mind, leveraging UUPS upgradeability for seamless contract upgrades. It showcases the upgradeability through the addition of Ether deposit support in the EscrowV2 and how the ERC1967Proxy is used with UUPS to upgrade from v1 to v2.
- ERC20 and Ether Support: Users can deposit and manage both ERC20 tokens and Ether.
- Upgradeable: Utilizes UUPS (Universal Upgradeable Proxy Standard) for seamless upgrades.
- Security: Implements non-reentrancy and proper storage layout for safety.
- Time-Based Claims: Funds can only be claimed or redeemed within specific intervals.
- Fail-Safe Design: Handles edge cases like invalid IDs, expired claims, and zero-amount transactions.
Before starting, ensure you have the following installed:
- Node.js (v14 or later)
- Foundry (Rust-based Ethereum development toolkit)
- Git
- Solc (Solidity compiler, compatible with version ^0.8.15)
git clone https://github.com/Mubashir-ali-baig/time-sensitive-escrow.git
cd escrow-contracts
Ensure you have Foundry installed. Then, run the following command to install dependencies:
forge install
Compile the Solidity contracts to ensure everything is set up correctly:
forge build
Execute the test suite to verify the contracts:
forge test
contracts/
: Contains the main contract files.EscrowV1.sol
: First version of the escrow contract.EscrowV2.sol
: Upgraded version with additional functionality.
libraries/
: Utility libraries likeTransferHelper
.interfaces/
: Contract interfaces likeIEscrowV1
andIEscrowV2
.test/
: Test files for contracts.script/
: Deployment and upgrade scripts.foundry.toml
: Foundry configuration file.
forge build
forge test
Customize the script/DeployEscrowV1.s.sol
or script/UpgradeEscrowV1.s.sol
script, and then deploy:
forge script script/DeployEscrowV1.s.sol --broadcast --rpc-url <RPC_URL>
Replace <RPC_URL>
with your Ethereum network endpoint (e.g., Alchemy, Infura).
forge script <SCRIPT_PATH> --broadcast --rpc-url <RPC_URL>
Feel free to contribute to this project by opening issues or submitting pull requests. Please ensure all tests pass before submitting any changes.
This project is licensed under the MIT License.