A comprehensive Initial DEX Offering (IDO) platform built on Ethereum that enables projects to launch their tokens through a secure, whitelisted crowdfunding mechanism. This platform allows projects to raise ETH in exchange for their ERC-20 tokens with built-in access control, pool management, and automated token distribution.
- Pool Management: Create and manage fundraising pools with configurable hard caps, soft caps, and timeframes
- Whitelist System: Secure access control ensuring only approved participants can invest
- Token Distribution: Automated ERC-20 token distribution based on investment amounts
- Role-Based Access: Multi-level permission system with admin and pool owner roles
- Refund Mechanism: Secure token claiming system for participants
- Real-time Tracking: Complete visibility into pool status, participants, and raised funds
- OpenZeppelin Integration: Built on battle-tested security libraries
- Access Control: Role-based permissions with granular control
- Pausable Contracts: Emergency stop functionality for security
- Input Validation: Comprehensive validation for all user inputs
- Reentrancy Protection: Secure against common attack vectors
- Node.js (v14 or higher)
- npm or yarn
- Git
- Ethereum wallet (MetaMask recommended)
- Hardhat development environment
-
Clone the repository
git clone https://github.com/your-username/Atomic-swap-eth-erc20.git cd Atomic-swap-eth-erc20 -
Install dependencies
npm install
-
Environment Setup Create a
.envfile in the root directory:NETWORK_GATEWAY_API=your_ethereum_rpc_url POOL_OWNER_PRIMARY_KEY=your_private_key DEPLOYER_PRIMARY_KEY=your_deployer_private_key RAISED_WEI_RECEIVER_PRIMARY_KEY=your_receiver_private_key RAISED_WEI_RECEIVER_ADDRESS=your_receiver_address
The central contract managing the entire IDO process:
- Pool creation and management
- Role-based access control
- Whitelist management
- Token distribution coordination
Handles individual fundraising pools:
- Investment tracking
- Participant management
- Pool status updates
- Fund collection
Standard ERC-20 token implementation for project tokens:
- Mintable tokens
- Transfer functionality
- Balance tracking
Manages participant whitelisting:
- Address validation
- Whitelist management
- Access verification
Utility library for input validation:
- Address validation
- Zero address checks
Defines the structure and methods for pool operations:
- Pool models and data structures
- Status enums
- Method signatures
-
Start local blockchain
npm run node
-
Deploy contracts locally
npm run deployLocal
-
Run tests
npm test -
Run tests with events
npm run testWithEvents
-
Deploy to testnet
npm run deployTestNet
-
Deploy to mainnet
npx hardhat deploy --network mainnet
- Pool owner creates a new fundraising pool
- Sets hard cap, soft cap, start/end times
- Initial status:
Upcoming
- Add project token details
- Set exchange rates and pricing
- Configure allocation limits
- Add approved participants
- Manage access permissions
- Pool status:
Ongoing - Whitelisted users can invest ETH
- Real-time tracking of raised funds
- Pool status:
Finished - Participants claim their tokens
- One-time claim per participant
The project includes comprehensive test coverage:
# Run all tests
npm test
# Run tests with detailed logs
npm run testWithEvents
# Lint Solidity code
npm run solhint
# Format Solidity code
npm run prettier:solidity- Pool creation and management
- Whitelist functionality
- Investment and refund processes
- Access control validation
- Edge cases and error handling
The project uses Hardhat for development and deployment:
- Solidity Version: 0.8.0
- Optimizer: Enabled (200 runs)
- Networks: Local, Rinkeby (commented), Mainnet ready
- Plugins: Ethers, Waffle, Solhint, Prettier
- Full TypeScript configuration
- Type definitions for all dependencies
- Compile-time error checking
โโโ contracts/ # Smart contracts
โ โโโ IDO.sol # Main IDO contract
โ โโโ Pool.sol # Pool management
โ โโโ ProjectToken.sol # ERC-20 token
โ โโโ Whitelist.sol # Access control
โ โโโ Validations.sol # Input validation
โ โโโ IPool.sol # Pool interface
โโโ scripts/ # Deployment scripts
โ โโโ deploy.ts # Main deployment script
โโโ test/ # Test files
โ โโโ ido.ts # Comprehensive test suite
โโโ helpers/ # Utility functions
โ โโโ bigNumber.ts # BigNumber utilities
โโโ hardhat.config.ts # Hardhat configuration
โโโ package.json # Dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
- Access Control: Multi-level role-based permissions
- Input Validation: Comprehensive validation for all inputs
- Reentrancy Protection: Secure against reentrancy attacks
- Integer Overflow: SafeMath operations (Solidity 0.8.0+)
- Emergency Stops: Pausable functionality for emergencies
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Solidity style guide
- Use Prettier for formatting
- Run Solhint for linting
- Write comprehensive tests
This project is licensed under the MIT License - see the LICENSE file for details.
Milad Mehdizade
- Email: milad.mehdizade1394@gmail.com
- GitHub: @miladmehdizade
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Contact the maintainer directly
- Multi-token support
- Advanced analytics dashboard
- Integration with DEX aggregators
- Mobile app support
- Cross-chain compatibility
- Automated KYC integration