A decentralized token trading platform built with Solidity, Hardhat, and Web3.js. The platform allows users to buy and sell WRT tokens with ETH through a simple and intuitive interface.
- Buy and sell WRT tokens with ETH
- Real-time price updates
- Transaction history tracking
- MetaMask wallet integration
- Price chart visualization
- Responsive web interface
WindRanger/
├── contracts/ # Smart contracts
│ └── WindRanger.sol # Main token contract
├── frontend/ # Web interface
│ ├── services/ # Frontend services
│ │ ├── blockchain.service.js # Web3 integration
│ │ ├── chart.service.js # Price chart handling
│ │ └── ui.service.js # UI management
│ ├── app.js # Main application logic
│ ├── config.js # Configuration and ABI
│ ├── index.html # Main HTML file
│ └── styles.css # Styling
├── scripts/ # Deployment scripts
│ └── deploy.js # Contract deployment
└── test/ # Contract tests
└── WindRanger.test.js # Contract test suite
- Node.js v14+ and npm
- MetaMask browser extension
- Git
- Clone the repository:
git clone https://github.com/yourusername/WindRanger.git
cd WindRanger
- Install dependencies:
npm install
- Start a local Hardhat node:
npx hardhat node
- Deploy the contract:
npx hardhat run scripts/deploy.js --network localhost
-
Update the contract address in
frontend/config.js
with the deployed contract address -
Start the frontend server:
npm run frontend
- Open your browser and navigate to
http://localhost:3000
The WindRanger token contract (WindRanger.sol
) implements the following functionality:
- ERC20 token standard
- Buy and sell tokens with ETH
- Transaction history tracking
- Contract balance management
buyTokens()
: Purchase WRT tokens with ETHsellTokens(uint256 amount)
: Sell WRT tokens for ETHgetTransactions(uint256 start, uint256 limit)
: Get transaction historygetContractBalance()
: Get contract's ETH balance
The frontend is built with vanilla JavaScript and Web3.js, providing a clean and responsive interface for interacting with the smart contract.
- BlockchainService: Handles Web3 integration and smart contract interactions
- UIService: Manages the user interface and event handling
- ChartService: Handles price chart visualization using Chart.js
- Real-time price updates
- Transaction history display
- Price chart visualization
- Wallet connection management
- Buy/sell token interface
- Network switching support
Run the test suite:
npx hardhat test
- Make changes to the smart contract
- Run tests to ensure functionality
- Deploy the contract to local network
- Update frontend configuration
- Test frontend interactions
The platform supports the following networks:
- Local Hardhat Network (for development)
- Ethereum Mainnet (future deployment)
- Other EVM-compatible networks (configurable)
- ReentrancyGuard implementation
- Input validation
- Balance checks
- Error handling
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.