A decentralized escrow service for secure peer-to-peer SPL token exchanges on Solana.
- Node.js 18+ or Bun
- Solana CLI
- Anchor Framework
- Phantom/Solflare wallet
# Clone and setup
git clone <your-repo>
cd escrow
# Install dependencies
yarn install
# or
bun install
# Build program
anchor build
# Deploy to devnet
anchor deploy --provider.cluster devnet
# Start frontend
cd frontend
bun install
bun run dev- Connect Wallet at http://localhost:5174
- Create Escrow - Deposit tokens and set exchange terms
- Take Escrow - Complete trades by providing requested tokens
- Refund - Reclaim your deposited tokens anytime
Here's a complete example to test the escrow functionality on devnet:
# Create a custom token for testing
spl-token create-token --decimals 6
# Example output: GRmDAdVee795cya78KNVcxaGE1FuR7sLegqBFVzscNPf
# Create token account and mint tokens to your wallet
spl-token create-account GRmDAdVee795cya78KNVcxaGE1FuR7sLegqBFVzscNPf
spl-token mint GRmDAdVee795cya78KNVcxaGE1FuR7sLegqBFVzscNPf 10000Fill out the escrow form with these example values:
| Field | Value | Description |
|---|---|---|
| Seed | 1 |
Unique number (user-chosen, 1-999999) |
| Token A Mint | GRmDAdVee795cya78KNVcxaGE1FuR7sLegqBFVzscNPf |
Your custom token |
| Token B Mint | So11111111111111111111111111111111111111112 |
Wrapped SOL |
| Deposit Amount | 1000 |
1,000 of your custom tokens |
| Receive Amount | 100000000 |
0.1 SOL (100M lamports) |
- As Maker: You can refund to get your tokens back
- As Taker: Someone with 0.1 SOL can complete the trade
- Result: Atomic swap of 1,000 custom tokens ↔ 0.1 SOL
The seed is a user-chosen number that:
- Must be unique per maker (you can't reuse the same seed)
- Creates deterministic escrow addresses
- Allows you to have multiple active escrows
- Can be any number (commonly 1, 2, 3... for simplicity)
Example Seeds:
- Use
1for your first escrow - Use
2for your second escrow - Use
42if you like that number - Use
123456for a more unique identifier
escrow/
├── programs/escrow/ # Anchor program
├── tests/ # Test suite
├── frontend/ # React frontend
└── target/ # Build artifacts
- Escrow Account: Stores trade parameters and state
- Vault ATA: Holds deposited tokens securely
- PDA Authority: Program-controlled token operations
# Run all tests
anchor test
# Test specific scenarios
anchor test --skip-deployTest Coverage:
- ✅ Escrow creation and token deposits
- ✅ Successful token exchanges
- ✅ Maker refunds and account closure
- ✅ Error handling and constraint validation
Program ID: 8hMrECVej1KoLvygnfLytvGEuvQwGMT5jobXHkjjWpyS
Instructions:
make- Create escrow and deposit tokenstake- Execute token exchangerefund- Return tokens to maker
Security Features:
- PDA-based authority control
- Comprehensive constraint validation
- Atomic token operations
- Zero-trust architecture
Built with React, TypeScript, and Solana wallet adapters.
Features:
- Real-time escrow monitoring
- Multi-wallet support
- Error handling and validation
- Responsive design
- Fork the repository
- Create feature branch
- Add tests for new functionality
- Submit pull request
MIT License - see LICENSE file for details.