Skip to content

SushanthKS06/DeScrow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeScrow - Decentralized Escrow Service

A secure multi-party smart contract system that holds funds in escrow until predefined conditions are met, with built-in dispute resolution mechanisms.

Features

  • Multi-party Escrow: Buyer, Seller, and optional Arbitrator roles
  • Dispute Resolution: Neutral third-party arbitration system
  • Time-lock Protection: Automatic refunds after expiry
  • Platform Fees: Configurable fee structure
  • Security: Reentrancy guards, access control, emergency pause

Contract Architecture

contracts/
├── DeScrow.sol              # Main escrow contract
├── interfaces/
│   └── IArbitrator.sol      # Arbitrator interface
└── libraries/
    └── EscrowUtils.sol      # Utility functions and structs

Escrow States

  • PENDING: Escrow created, awaiting buyer deposit
  • FUNDED: Buyer has deposited funds
  • IN_DISPUTE: Dispute raised, awaiting arbitrator
  • COMPLETED: Funds released to seller
  • CANCELLED: Funds returned to buyer
  • EXPIRED: Time limit reached, funds automatically returned

Usage Examples

Creating an Escrow

const escrowId = await deScrow.connect(buyer).createEscrow(
  sellerAddress,
  arbitratorAddress,
  expiryTimestamp,
  { value: ethers.parseEther("1.0") }
);

Happy Path Completion

// Buyer confirms delivery
await deScrow.connect(buyer).confirmDelivery(escrowId);

// Seller requests payment
await deScrow.connect(seller).requestPayment(escrowId);
// Funds automatically released to seller

Dispute Resolution

// Either party raises dispute
await deScrow.connect(buyer).raiseDispute(escrowId, "Product not as described");

// Arbitrator resolves dispute
await deScrow.connect(arbitrator).resolveDispute(escrowId, true); // Award to seller

Time-based Withdrawal

// After expiry time passes
await deScrow.connect(buyer).withdrawExpired(escrowId);

Installation & Setup

npm install
npx hardhat compile
npx hardhat test

Deployment

# Deploy to local network
npx hardhat run scripts/deploy.js

# Deploy to testnet
npx hardhat run scripts/deploy.js --network goerli

# Deploy to mainnet
npx hardhat run scripts/deploy.js --network mainnet

Security Considerations

  • All functions include proper access control
  • Reentrancy protection on fund transfers
  • Input validation on all parameters
  • Emergency pause functionality for critical bugs
  • Platform fee capped at 10% maximum

Gas Optimization

  • Optimized storage layout
  • Minimal external calls
  • Efficient event emission
  • Library usage for common operations

Testing

Run the comprehensive test suite:

npx hardhat test

Test coverage includes:

  • Happy path scenarios
  • Dispute resolution flows
  • Time-based expiry handling
  • Edge cases and error conditions
  • Security attack vectors

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published