Skip to content

Binance Escrow System is a decentralized smart contract for secure P2P crypto trades, inspired by Binance P2P. Built with Solidity and Hardhat, it enables trustless escrow, dispute resolution, and Ethereum dApp integration.

Notifications You must be signed in to change notification settings

emmanuelronoh/Binance-escrow-system

Repository files navigation

Binance Escrow System 🤝💸

A Solidity-based escrow protocol inspired by Binance P2P.
It holds crypto funds in a smart-contract escrow until both buyer and seller meet predefined conditions, helping eliminate counter-party risk in peer-to-peer trades.

Tech Stack Solidity 0.8 · Hardhat · Ethers.js
Tests Mocha & Chai
Languages Solidity 56 % · JavaScript 44 %
License MIT

✨ Features

  • Secure Escrow Logic – funds are locked until both sides confirm payment or an admin resolves a dispute.
  • Time-outs & Appeals – automatic refund / release after a deadline, plus dispute resolution hooks.
  • Upgradeable Architecture – contracts designed for future enhancements.
  • Automated Tests – unit tests cover happy paths and edge-cases.
  • Hardhat Tasks & Scripts – one-command deployment, verification and interaction.

📂 Project Structure

.
├─ contracts/         # Solidity smart contracts
├─ deployments/       # Network-specific deployment data
├─ scripts/           # Hardhat scripts (deploy, interact, verify)
├─ tasks/             # Custom Hardhat CLI tasks
├─ test/              # Mocha + Chai tests
├─ hardhat.config.js  # Hardhat configuration
└─ package.json       # NPM scripts & dependencies

🚀 Quick Start

1 · Clone & Install

git clone https://github.com/emmanuelronoh/Binance-escrow-system.git
cd Binance-escrow-system
npm install

2 · Configure Environment Create .env and set a private key for deployment:

PRIVATE_KEY=your_private_key_here
RPC_URL=https://rpc-url-of-your-testnet
ETHERSCAN_API_KEY=your_key   # optional for verification

3 · Compile & Test

npx hardhat compile
npx hardhat test

4 · Deploy

npx hardhat run scripts/deploy.js --network <network>

🧪 Testing Guide

test/Escrow.test.js covers:

  1. openTrade → funds locked

  2. confirmPayment & releaseFunds

  3. cancelTrade & refund

  4. dispute path & admin resolution

Run with:

npx hardhat test

📄 API / Contract Interface

Function Purpose
openTrade(address token, uint256 amount, uint256 deadline) Seller locks tokens in escrow.
confirmPayment(uint256 tradeId) Buyer marks fiat payment done.
releaseFunds(uint256 tradeId) Seller releases crypto to buyer.
cancelTrade(uint256 tradeId) Auto-refunds after deadline if no payment.
raiseDispute(uint256 tradeId) Escalate to admin.
resolveDispute(uint256 tradeId, bool buyerWins) Admin decision.

(See NatSpec in contracts/ for full details.)

🛡️ Security Considerations

  • Uses Checks-Effects-Interactions pattern to prevent re-entrancy.
  • Implements OpenZeppelin Ownable for admin controls.
  • All critical state changes are covered by unit tests.
  • Third-party audit is strongly recommended prior to mainnet deployment.

🖇️ Integrating With Front-Ends

  1. Deploy contracts; save the resulting deployments/<network>/Escrow.json.
  2. Import the ABI and address into your React/web3 application.
  3. Use Ethers.js to call openTrade, confirmPayment, etc.
  4. Listen for events like TradeOpened, TradeReleased, etc., to update the UI in real-time.

📝 Contributing

Pull requests, issues, and feature ideas are welcome!

Standard Workflow

git checkout -b feature/your-feature
npm run lint
npm test
git commit -m "feat: add your feature"
git push origin feature/your-feature

© License

This project is licensed under the MIT License – see LICENSE for details.

About

Binance Escrow System is a decentralized smart contract for secure P2P crypto trades, inspired by Binance P2P. Built with Solidity and Hardhat, it enables trustless escrow, dispute resolution, and Ethereum dApp integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published