A decentralized OTC marketplace for ERC20 tokens with partial fill support.
- Create and fill orders for ERC20 tokens
- Partial fill support
- Platform fee mechanism
- Order management (close/cancel)
- Emergency pause functionality
- Gas-optimized design
Main marketplace contract that handles:
- Order creation and filling
- Partial fills tracking
- Fee collection
- Order management
Simple ERC20 token for testing purposes.
- Node.js
- npm
- Hardhat
- MetaMask
- Install dependencies:
npm install- Create
.envfile:
PRIVATE_KEY=your_metamask_private_key
SEPOLIA_URL=your_alchemy_sepolia_url
ETHERSCAN_API_KEY=your_etherscan_api_key
npx hardhat testnpx hardhat run scripts/deploy.js --network sepolia// Approve tokens first
await token.approve(crowdfill.address, amount);
// Create order
await crowdfill.createOrder(token.address, amount, price);// Fill order with ETH
await crowdfill.fillOrder(orderId, amount, { value: price * amount });// Close order and get remaining tokens back
await crowdfill.closeOrder(orderId);- ReentrancyGuard for fill operations
- Pausable for emergency stops
- Ownable for admin functions
- Gas optimizations for cost efficiency