Skip to content

Mubashir-ali-baig/time-sensitive-escrow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Time Sensitive Upgradeable Escrow

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.

Features

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

Prerequisites

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)

Installation Steps

1. Clone the Repository

git clone https://github.com/Mubashir-ali-baig/time-sensitive-escrow.git
cd escrow-contracts

2. Install Dependencies

Ensure you have Foundry installed. Then, run the following command to install dependencies:

forge install

3. Compile the Contracts

Compile the Solidity contracts to ensure everything is set up correctly:

forge build

4. Run Tests

Execute the test suite to verify the contracts:

forge test

Project Structure

  • contracts/: Contains the main contract files.
    • EscrowV1.sol: First version of the escrow contract.
    • EscrowV2.sol: Upgraded version with additional functionality.
  • libraries/: Utility libraries like TransferHelper.
  • interfaces/: Contract interfaces like IEscrowV1 and IEscrowV2.
  • test/: Test files for contracts.
  • script/: Deployment and upgrade scripts.
  • foundry.toml: Foundry configuration file.

Key Commands

Compile Contracts

forge build

Run Tests

forge test

Deploy the Contract

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).

Run a Script

forge script <SCRIPT_PATH> --broadcast --rpc-url <RPC_URL>

Contribution

Feel free to contribute to this project by opening issues or submitting pull requests. Please ensure all tests pass before submitting any changes.

License

This project is licensed under the MIT License.

About

An upgradeable escrow payment gateway with time sensitive refund feature

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published