Skip to content

Repository files navigation

Simple Escrow with Split Bill🔒

image

Demo project for Final Project on Rootstock Dev Course

📋 Project Overview

Simple Escrow is a minimal, educational smart contract that demonstrates time-based escrow - a fundamental blockchain primitive where funds are held until both parties approve OR a deadline passes for refund.

Core Primitive: Time-based state machine with multi-party approval

Key Concept: Funds are held in the contract until:

  • ✅ Both parties approve (success) → funds go to payee
  • ⏰ Deadline passes without full approval → payer gets refund

📍 Contract Deployment

  • Network: RSK Testnet
  • Contract Address:0x24a9f4ba13a490f7165725d311bb668814edb8d1
  • Explorer Link:View on RSK Explorer
  • Contract Verified:

Features

  • ✅ Smart contract deployed on RSK Testnet
  • ✅ Create escrow with single payee
  • ✅ Deposit RBTC to escrow
  • ✅ Release funds to approval state
  • ✅ Approve from both parties (payer + payee)
  • ✅ Automatic completion when both approve
  • ✅ Refund after deadline passes

🔄 How It Works

State Machine:

AWAITING_PAYMENT → AWAITING_APPROVAL → COMPLETED
↘ EXPIRED

User Flows:

Happy Path (Success):

  1. Payer creates escrow with RBTC deposit
  2. Payer releases funds to contract
  3. Payer approves
  4. Payee approves
  5. Funds automatically sent to payee

Refund Path (Dispute/No Action):

  1. Payer creates escrow
  2. Payer releases funds
  3. Deadline passes (e.g., 7 days)
  4. Payer calls refund
  5. Funds returned to payer

🧪 How to Test

  1. Connect MetaMask to RSK Testnet

  2. Get tRBTC from faucet

    • Visit RSK Faucet
    • Enter your wallet address
    • Request funds
  3. Create an escrow

    • Enter title, payee address, amount, deadline
    • Confirm MetaMask transaction
  4. Release and approve

    • Click "Release" to move funds to approval state
    • Approve from payer account
    • Switch to payee account in MetaMask
    • Approve from payee account
  5. Complete

    • Funds automatically transfer to payee
    • Status shows "Completed"

🎯 Why This Design?

Design ChoiceReason
Two parties onlyClear responsibility, easier to understand
4-state machineComplete coverage of all scenarios
Separate release & approveExplicit intent, safety net
Time-based refundNo external oracles needed
No DeFi featuresFocus on one primitive, matches feedback

📁 Project Structure

split-bill/
├── contracts/
│ └── SimpleEscrow.sol # ~120 lines - core escrow logic
├── frontend/
│ └── src/
│ ├── App.js # React frontend
│ └── abis/
│ └── SimpleEscrow.json
├── scripts/
│ └── deploy.js # Deployment script
├── test/
│ └── SimpleEscrow.test.js
├── hardhat.config.js
└── package.json

🛠 Tech Stack

ComponentTechnology
Smart ContractSolidity 0.8.20
DevelopmentHardhat
FrontendReact + Ethers.js
WalletMetaMask
NetworkRSK Testnet

🚀 Run Locally

# Clone repository
git clone https://github.com/Rsync25/Split-Bill.git
cd Split-Bill
# Install dependencies
npm install
cd frontend && npm install &&cd ..
# Compile contracts
npx hardhat compile
# Deploy to RSK Testnet
npx hardhat run scripts/deploy.js --network rskTestnet
# Run frontendcd frontend
npm start

📊 Rules Enforced

RuleHow It's Enforced
Only payer can create/release/refundrequire(msg.sender == escrow.payer)
Only payer/payee can approverequire(msg.sender == payer OR payee)
Cannot approve twicerequire(!escrow.payerApproved)
Cannot approve before releaseState must be AWAITING_APPROVAL
Refund only after deadlinerequire(block.timestamp > deadline)

📝 Capstone Requirements

RequirementHow This Project Meets It
One clear primitiveTime-based escrow state machine
Not product-orientedFocuses on mechanism, not platform
Educational valueDemonstrates state management, time-based logic
Complete but simple4 states, 5 functions, ~120 lines
Demo-friendly2-minute walkthrough shows both paths
Deployed on RSKTestnet deployment verified

🔗 Links


📞 Contact

For questions about this project, please reach out via the course platform.


Tests sucessful!

Made for RSK Developer Course Capstone Project 🚀


About

Simple Escrow is a minimal, educational smart contract that demonstrates time-based escrow - a fundamental blockchain primitive where funds are held until both parties approve OR a deadline passes for refund.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages