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 |
- 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.
.
├─ 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 & dependencies1 · Clone & Install
git clone https://github.com/emmanuelronoh/Binance-escrow-system.git
cd Binance-escrow-system
npm install2 · 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 verification3 · Compile & Test
npx hardhat compile
npx hardhat test4 · Deploy
npx hardhat run scripts/deploy.js --network <network>test/Escrow.test.js covers:
-
openTrade → funds locked
-
confirmPayment & releaseFunds
-
cancelTrade & refund
-
dispute path & admin resolution
Run with:
npx hardhat test| 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.)
- 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.
- Deploy contracts; save the resulting
deployments/<network>/Escrow.json. - Import the ABI and address into your React/web3 application.
- Use Ethers.js to call
openTrade,confirmPayment, etc. - Listen for events like
TradeOpened,TradeReleased, etc., to update the UI in real-time.
Pull requests, issues, and feature ideas are welcome!
git checkout -b feature/your-feature
npm run lint
npm test
git commit -m "feat: add your feature"
git push origin feature/your-featureThis project is licensed under the MIT License – see LICENSE for details.