Skip to content

Repository files navigation

EscrowChain — Decentralized Escrow Service dApp

A decentralized escrow service built on Ethereum that enables trustless transactions between buyers and sellers. Funds are locked inside a smart contract and released automatically once predefined conditions are met.

This project demonstrates how blockchain can eliminate the need for centralized intermediaries in digital transactions.


Overview

EscrowChain is a decentralized application (dApp) designed to facilitate secure peer-to-peer transactions using Ethereum smart contracts.

Traditional escrow services require a trusted third party to hold funds during a transaction. EscrowChain replaces this intermediary with a transparent and automated smart contract.

The system ensures that:

  • The buyer’s funds remain locked until the transaction is completed.
  • The seller receives payment only after the buyer confirms delivery.
  • Disputes can be handled through predefined contract rules.

This ensures trustless, transparent, and secure transactions.


Key Features

Smart Contract Based Escrow

Funds are securely locked inside a Solidity smart contract until conditions are satisfied.

Trustless Transactions

No central authority or intermediary is required.

Buyer Protection

Buyers retain control over releasing funds until the product or service is delivered.

Seller Assurance

Sellers are guaranteed payment once delivery is confirmed.

Transparent State Tracking

All transaction states are visible on-chain.

Dispute Handling

Optional arbitration logic can be implemented for dispute resolution.


System Architecture

The application follows a modular Web3 architecture composed of three layers.

User Interface
      │
      ▼
Frontend (React / Next.js)
      │
      ▼
Web3 Interaction Layer (Ethers.js / Wagmi)
      │
      ▼
Ethereum Smart Contract (Solidity)
      │
      ▼
Ethereum Test Network (Sepolia / Local Hardhat)

Core Components

1. Smart Contract Layer

The smart contract manages all escrow logic.

Responsibilities:

  • Creating escrow agreements
  • Locking buyer funds
  • Tracking escrow states
  • Releasing payments to sellers
  • Handling refunds and disputes

Technology Stack:

  • Solidity
  • OpenZeppelin security libraries
  • Hardhat development framework

2. Web3 Interaction Layer

Handles communication between the frontend and the smart contract.

Responsibilities:

  • Wallet connection
  • Transaction signing
  • Smart contract interaction
  • Event listening

Technology Stack:

  • Ethers.js
  • Wagmi
  • MetaMask wallet integration

3. Frontend Application

Provides the user interface for interacting with the escrow system.

Responsibilities:

  • Creating escrow transactions
  • Viewing escrow status
  • Confirming delivery
  • Handling dispute actions

Technology Stack:

  • Next.js / React
  • TailwindCSS
  • Web3 wallet integration

Escrow Transaction Workflow

Step 1 — Escrow Creation

The buyer creates a new escrow agreement specifying:

  • Seller address
  • Payment amount
  • Transaction description

The smart contract initializes the escrow record.


Step 2 — Deposit Funds

The buyer deposits ETH into the smart contract.

Funds remain locked inside the contract.

Escrow state becomes:

FUNDED

Step 3 — Seller Delivers Service

The seller completes the work or delivers the product.

This step occurs off-chain.


Step 4 — Buyer Confirms Delivery

The buyer confirms successful delivery.

The smart contract automatically releases funds to the seller.

Escrow state becomes:

COMPLETED

Step 5 — Dispute Resolution (Optional)

If the buyer is unsatisfied:

  • The escrow enters the DISPUTED state.
  • A predefined dispute resolution method is triggered.

Possible strategies:

  • Admin arbitration
  • DAO voting
  • Automatic refund after timeout

Smart Contract Design

Escrow States

The contract tracks escrow lifecycle using an enum.

AWAITING_PAYMENT
AWAITING_DELIVERY
COMPLETE
DISPUTED
REFUNDED

Escrow Data Structure

Each escrow agreement contains:

buyer address
seller address
transaction amount
current escrow state
timestamp

Core Contract Functions

createEscrow()

Creates a new escrow agreement.

deposit()

Buyer sends ETH into the escrow contract.

confirmDelivery()

Buyer confirms product/service delivery and releases funds to the seller.

raiseDispute()

Buyer raises a dispute.

refundBuyer()

Refunds funds to buyer if dispute is resolved in their favor.

getEscrowDetails()

Returns escrow information.


Repository Structure

EscrowChain/
│
├── contracts/
│   └── Escrow.sol
│
├── scripts/
│   └── deploy.js
│
├── frontend/
│   ├── components/
│   ├── pages/
│   ├── hooks/
│   └── styles/
│
├── test/
│   └── Escrow.test.js
│
├── hardhat.config.js
├── package.json
├── .env
└── README.md

Technology Stack

Layer Technology
Smart Contract Solidity
Development Framework Hardhat
Blockchain Network Ethereum
Web3 Library Ethers.js
Wallet Integration MetaMask
Frontend Framework Next.js / React
Styling TailwindCSS

Development Setup

1. Clone Repository

git clone https://github.com/yourusername/escrowchain.git
cd escrowchain

2. Install Dependencies

npm install

3. Compile Smart Contracts

npx hardhat compile

4. Run Local Blockchain

npx hardhat node

5. Deploy Smart Contract

npx hardhat run scripts/deploy.js --network localhost

6. Start Frontend

cd frontend
npm install
npm run dev

Testing

Run smart contract tests:

npx hardhat test

Tests include:

  • escrow creation
  • fund deposits
  • successful payment release
  • refund scenarios

Security Considerations

Smart contracts include protection against:

  • reentrancy attacks
  • unauthorized access
  • double withdrawals
  • incorrect state transitions

Security patterns used:

  • Checks-Effects-Interactions
  • Access modifiers
  • Safe ETH transfer patterns

Future Improvements

Potential enhancements for production deployment:

  • Multi-party arbitration system
  • Milestone based payments
  • NFT escrow support
  • DAO governed dispute resolution
  • Layer 2 scaling support
  • Cross-chain escrow functionality

License

MIT License


Author

Developed as a capstone project for the AI Powered Blockchain Builder Course.

About

A decentralized escrow service built on Ethereum that enables trustless transactions between buyers and sellers. Funds are locked inside a smart contract and released automatically once predefined conditions are met.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages