Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rsync25/Split-Bill

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 Choice Reason
Two parties only Clear responsibility, easier to understand
4-state machine Complete coverage of all scenarios
Separate release & approve Explicit intent, safety net
Time-based refund No external oracles needed
No DeFi features Focus 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

Component Technology
Smart Contract Solidity 0.8.20
Development Hardhat
Frontend React + Ethers.js
Wallet MetaMask
Network RSK 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 frontend
cd frontend
npm start

πŸ“Š Rules Enforced

Rule How It's Enforced
Only payer can create/release/refund require(msg.sender == escrow.payer)
Only payer/payee can approve require(msg.sender == payer OR payee)
Cannot approve twice require(!escrow.payerApproved)
Cannot approve before release State must be AWAITING_APPROVAL
Refund only after deadline require(block.timestamp > deadline)

πŸ“ Capstone Requirements

Requirement How This Project Meets It
One clear primitive Time-based escrow state machine
Not product-oriented Focuses on mechanism, not platform
Educational value Demonstrates state management, time-based logic
Complete but simple 4 states, 5 functions, ~120 lines
Demo-friendly 2-minute walkthrough shows both paths
Deployed on RSK Testnet 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

License

Stars

Watchers

Forks

Contributors

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /