├── package.json ├── ignition └── modules │ └── Lock.js ├── scripts └── deploy.js ├── contracts ├── DohaICO.sol └── DohaToken.sol ├── LICENSE ├── test ├── DohaICO.test.js └── DohaToken.test.js ├── README.md ├── .gitignore └── hardhat.config.js /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@nomicfoundation/hardhat-toolbox": "^5.0.0", 4 | "@nomiclabs/hardhat-waffle": "^2.0.6", 5 | "chai": "^5.1.1", 6 | "hardhat": "^2.22.10" 7 | }, 8 | "dependencies": { 9 | "@openzeppelin/contracts": "^5.0.2", 10 | "dotenv": "^16.4.5", 11 | "ethers": "^6.13.2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ignition/modules/Lock.js: -------------------------------------------------------------------------------- 1 | const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules"); 2 | 3 | const JAN_1ST_2030 = 1893456000; 4 | const ONE_GWEI = 1_000_000_000n; 5 | 6 | module.exports = buildModule("LockModule", (m) => { 7 | const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030); 8 | const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI); 9 | 10 | const lock = m.contract("Lock", [unlockTime], { 11 | value: lockedAmount, 12 | }); 13 | 14 | return { lock }; 15 | }); 16 | -------------------------------------------------------------------------------- /scripts/deploy.js: -------------------------------------------------------------------------------- 1 | const { ethers } = require("hardhat"); 2 | require("dotenv").config(); 3 | 4 | async function main() { 5 | // Array of co-founder addresses (replace with actual addresses) 6 | const coFounders = [ 7 | "0xAddress1", 8 | "0xAddress2", 9 | "0xAddress3", 10 | "0xAddress4", 11 | "0xAddress5", 12 | "0xAddress6", 13 | "0xAddress7", 14 | "0xAddress8", 15 | "0xAddress9", 16 | "0xAddress10", 17 | ]; 18 | 19 | const DohaToken = await ethers.getContractFactory("DohaToken"); 20 | console.log("Deploying DohaToken..."); 21 | const dohaToken = await DohaToken.deploy(coFounders); 22 | await dohaToken.deployed(); 23 | 24 | console.log(`DohaToken deployed to: ${dohaToken.address}`); 25 | } 26 | 27 | main() 28 | .then(() => process.exit(0)) 29 | .catch((error) => { 30 | console.error(error); 31 | process.exit(1); 32 | }); -------------------------------------------------------------------------------- /contracts/DohaICO.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier:MIT 2 | pragma solidity ^0.8.24; 3 | 4 | import "@openzeppelin/contracts/access/Ownable.sol"; 5 | 6 | import "./DohaToken.sol"; 7 | 8 | contract DohaICO is Ownable { 9 | DohaToken public token; 10 | bool public isICORunning; 11 | uint256 public tokensPerEth = 66; // 66 DOOHA for every 100 wei (0.66 DOOHA per 1 wei) 12 | 13 | constructor(DohaToken _token) { 14 | token = _token; 15 | } 16 | 17 | function startICO() external onlyOwner { 18 | require(!isICORunning, "ICO already running"); 19 | isICORunning = true; 20 | } 21 | 22 | function finishICO() external onlyOwner { 23 | require(isICORunning, "ICO is not running"); 24 | isICORunning = false; 25 | } 26 | 27 | function buyTokens() external payable { 28 | require(isICORunning, "ICO is not running"); 29 | require(msg.value > 0, "Must send ETH to buy tokens."); 30 | 31 | uint256 tokensToBuy = (msg.value * tokensPerEth) / 100; 32 | token.transfer(msg.sender, tokensToBuy); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Mitsuru Kudo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/DohaICO.test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const { ethers } = require("hardhat"); 3 | 4 | describe("DoohaICO", function () { 5 | let DoohaToken; 6 | let DoohaICO; 7 | let doohaToken; 8 | let doohaICO; 9 | let owner; 10 | 11 | beforeEach(async function () { 12 | DoohaToken = await ethers.getContractFactory("DoohaToken"); 13 | [owner] = await ethers.getSigners(); 14 | 15 | // Deploying the token first 16 | const coFounders = [owner.address, owner.address, owner.address, owner.address, owner.address, owner.address, owner.address, owner.address, owner.address, owner.address]; 17 | doohaToken = await DoohaToken.deploy(coFounders); 18 | await doohaToken.deployed(); 19 | 20 | // Deploying the ICO with the token 21 | DoohaICO = await ethers.getContractFactory("DoohaICO"); 22 | doohaICO = await DoohaICO.deploy(doohaToken.address); 23 | await doohaICO.deployed(); 24 | }); 25 | 26 | it("Should start and finish ICO", async function () { 27 | await doohaICO.startICO(); 28 | expect(await doohaICO.isICORunning()).to.be.true; 29 | 30 | await doohaICO.finishICO(); 31 | expect(await doohaICO.isICORunning()).to.be.false; 32 | }); 33 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Doha-ICO 2 | This is a simple ERC20 token and Crowd sale/ICO Smart Contract written in Solidity. The Doha Token meets the ERC20 standard. All of the code has been fully tested and executed in a live environment. This token is free to use as you see fit. I called it Doha just because its a fun word to say. Call it what ever you want. 3 | 4 | ### Prerequisites 5 | A good foundation of Solidity or JavaScript will be extremely helpful but not required. A good understanding of Ethereum transactions and EVM is required or ability to use Google and quickly look up and understand needed information should be about all you will need. 6 | 7 | ### Deployment 8 | 9 | ##### Token 10 | 11 | Make sure that you have an ERC20 compatible Ethereum wallet. Execute the token code: For MyEtherWallet; past the token code into the remix online compiler. Copy the EVM code and past into the MyEtherWallet execute smart contract. pay the gas price, enjoy your tokens. 12 | 13 | ##### ICO Contract 14 | 15 | You must have the tokens already created for this contract to work. 16 | Make sure that you have an ERC20 compatible Ethereum wallet. Execute the ICO Contract code: For MyEtherWallet; past the token code into the remix online compiler. Copy the EVM code and past into the MyEtherWallet execute smart contract. pay the gas price. Next you will need to send the required number of tokens as stated in the smart contract variables to the initialize function of the smart contract. The smart contract should be ready to go at this point. 17 | This is a no-burn contract, meaning that all unsold tokens are returned to the owner of the contract at the end of the ICO/Crowdsale. 18 | Only the owner (Wallet that issued the contract) can destroy or terminate the contract. 19 | 20 | ### Contributing 21 | 22 | Fork it and do your thing. Or get in touch with me and we can figure something out. 23 | 24 | ## License 25 | 26 | This project is licensed under the [MIT License](./LICENSE). 27 | 28 | ## 📞 Contact & Support 29 | 30 | - **Email**: [imcrazysteven143@gmail.com](mailto:imcrazysteven143@gmail.com) 31 | - **GitHub**: [Steven (@imcrazysteven)](https://github.com/imcrazysteven) 32 | - **Telegram**: [@imcrazysteven](https://t.me/imcrazysteven) 33 | - **Twitter**: [@imcrazysteven](https://x.com/imcrazysteven) 34 | - **Instagram**: [@imcrazysteven](https://www.instagram.com/imcrazysteven/) 35 | 36 | --- 37 | -------------------------------------------------------------------------------- /contracts/DohaToken.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.24; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import "@openzeppelin/contracts/access/Ownable.sol"; 6 | 7 | contract DohaToken is ERC20, Ownable { 8 | //Declare events 9 | event TokensMinted(address indexed to, uint256 amount); 10 | event ICOStarted(uint256 totalTokensForSale); 11 | event ICOFinished(); 12 | 13 | //state variables 14 | bool public isICORunning; 15 | uint256 public tokensPerEth = 66; // 66 DOOHA for every 100 wei (0.66 DOOHA per 1 wei) 16 | uint256 constant ICO_PERCENTAGE = 90; //90% of tokens for ICO, rest for initial cofounders 17 | uint256 public coFounderShare; //Share for each co-founder 18 | 19 | // Constructor for initializing the token 20 | constructor(address[10] memory coFounders) ERC20("Doha", "DOHA") { 21 | uint256 totalSupply = 300000 * (10 ** decimals()); // 300,000 tokens with decimals applied 22 | _mint(msg.sender, (totalSupply * ICO_PERCENTAGE) / 100); //Mint 90% for ICO 23 | coFounderShare = (totalSupply * (100 - ICO_PERCENTAGE)) / 10; //10% distributed among 10 co-founders 24 | 25 | for (uint8 i = 0; i < coFounders.length; i++) { 26 | _mint(coFounders[i], coFounderShare); //Distributing tokens to 10 co-founders 27 | } 28 | } 29 | 30 | function startICO() external onlyOwner { 31 | require(!isICORunning, "ICO already running"); 32 | isICORunning = true; 33 | emit ICOStarted((totalSupply() * ICO_PERCENTAGE) / 100); 34 | } 35 | 36 | function finishICO() external onlyOwner { 37 | require(isICORunning, "ICO is not running"); 38 | isICORunning = false; 39 | emit ICOFinished(); 40 | } 41 | 42 | function buyTokens() external payable { 43 | require(isICORunning, "ICO is not running"); 44 | require(msg.value > 0, "Must send ETH to buy tokens"); 45 | 46 | //Calculate token amount using the tokensPerEth 47 | uint tokensToBuy = (msg.value * tokensPerEth) / 100; //Adjust for scaling factor 48 | _transfer(owner(), msg.sender, tokensToBuy); 49 | } 50 | 51 | function mint(address to, uint256 amount) external onlyOwner { 52 | _mint(to, amount); 53 | emit TokensMinted(to, amount); 54 | } 55 | 56 | function burn(uint256 amount) external { 57 | _burn(msg.sender, amount); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | node_modules 133 | .env 134 | 135 | # Hardhat files 136 | /cache 137 | /artifacts 138 | 139 | # TypeChain files 140 | /typechain 141 | /typechain-types 142 | 143 | # solidity-coverage files 144 | /coverage 145 | /coverage.json 146 | 147 | # Hardhat Ignition default folder for deployments against a local node 148 | ignition/deployments/chain-31337 149 | 150 | node_modules 151 | .env 152 | 153 | # Hardhat files 154 | /cache 155 | /artifacts 156 | 157 | # TypeChain files 158 | /typechain 159 | /typechain-types 160 | 161 | # solidity-coverage files 162 | /coverage 163 | /coverage.json 164 | 165 | # Hardhat Ignition default folder for deployments against a local node 166 | ignition/deployments/chain-31337 167 | -------------------------------------------------------------------------------- /hardhat.config.js: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from "hardhat/config"; 2 | import "@nomicfoundation/hardhat-toolbox"; 3 | import "@nomicfoundation/hardhat-verify"; 4 | import dotenv from 'dotenv'; 5 | 6 | dotenv.config (); 7 | 8 | const PRIVATE_KEY = process.env.PRIVATE_KEY; 9 | 10 | const config = { 11 | solidity: { 12 | version: "0.8.24", 13 | settings: { 14 | optimizer: { 15 | enabled: true, 16 | runs: 100, 17 | }, 18 | viaIR: true, 19 | }, 20 | }, 21 | // defaultNetwork: "sepolia", 22 | networks: { 23 | sepolia: { 24 | url: process.env.SEPOLIA_URL, 25 | accounts: [PRIVATE_KEY], 26 | }, 27 | goerli: { 28 | url: process.env.GOERLI_URL, 29 | accounts: [PRIVATE_KEY], 30 | }, 31 | mantle: { 32 | url: process.env.MANTLE_URL, 33 | accounts: [PRIVATE_KEY] 34 | }, 35 | etc: { 36 | url: process.env.ETC_URL, 37 | accounts: [PRIVATE_KEY] 38 | }, 39 | polygon: { 40 | url: process.env.POLYGON_URL, 41 | accounts: [PRIVATE_KEY] 42 | }, 43 | opt: { 44 | url: process.env.OPTIMISM_URL, 45 | accounts: [PRIVATE_KEY] 46 | }, 47 | arbitrum: { 48 | url: process.env.ARBITRUM_URL, 49 | accounts: [PRIVATE_KEY] 50 | }, 51 | base: { 52 | url: process.env.BASE_URL, 53 | accounts: [PRIVATE_KEY] 54 | }, 55 | bsc: { 56 | url: process.env.BSC_URL, 57 | accounts: [PRIVATE_KEY] 58 | }, 59 | scroll: { 60 | url: process.env.SCROLL_URL, 61 | accounts: [PRIVATE_KEY] 62 | }, 63 | artio_testnet: { 64 | url: process.env.ARTIO_URL, 65 | accounts: [PRIVATE_KEY] 66 | }, 67 | }, 68 | etherscan: { 69 | apiKey: { 70 | goerli: process.env.ETHERSCAN_KEY, 71 | sepolia: process.env.ETHERSCAN_KEY, 72 | polygon: process.env.POLYGONSCAN_KEY, 73 | mantle: "any", 74 | etc: process.env.ETCSCAN_KEY, 75 | bsc: process.env.BSCSCAN_API_KEY, 76 | scroll: process.env.SCROLLSCAN_KEY, 77 | artio_testnet: "artio_testnet" 78 | }, 79 | customChains: [ 80 | { 81 | network: "mantle", 82 | chainId: 5000, 83 | urls: { 84 | apiURL: "https://api.routescan.io/v2/network/mainnet/evm/5000/etherscan", 85 | browserURL: "https://mantlescan.info" 86 | } 87 | }, 88 | { 89 | network: "etc", 90 | chainId: 61, 91 | urls: { 92 | apiURL: "https://etc.blockscout.com/api", 93 | browserURL: "https://etc.blockscout.com/" 94 | } 95 | }, 96 | { 97 | network: "polygon", 98 | chainId: 137, 99 | urls: { 100 | apiURL: "https://api.polygonscan.com/api", 101 | browserURL: "https://polygonscan.com/" 102 | } 103 | }, 104 | { 105 | network: "artio_testnet", 106 | chainId: 80085, 107 | urls: { 108 | apiURL: "https://api.routescan.io/v2/network/testnet/evm/80085/etherscan", 109 | browserURL: "https://artio.beratrail.io" 110 | } 111 | }, 112 | { 113 | network: "scroll", 114 | chainId: 534352, 115 | urls: { 116 | apiURL: "https://api.scrollscan.com/api", 117 | browserURL: "https://api.scrollscan.com" 118 | } 119 | } 120 | ] 121 | }, 122 | sourcify: { 123 | enabled: true, 124 | }, 125 | }; 126 | 127 | export default config; -------------------------------------------------------------------------------- /test/DohaToken.test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const { ethers } = require("hardhat"); 3 | 4 | describe("DohaToken", function () { 5 | let DohaToken; 6 | let dohaToken; 7 | let owner; 8 | let coFounders; 9 | 10 | beforeEach(async function () { 11 | coFounders = [ 12 | "0xAddress1", 13 | "0xAddress2", 14 | "0xAddress3", 15 | "0xAddress4", 16 | "0xAddress5", 17 | "0xAddress6", 18 | "0xAddress7", 19 | "0xAddress8", 20 | "0xAddress9", 21 | "0xAddress10", 22 | ]; 23 | 24 | DohaToken = await ethers.getContractFactory("DohaToken"); 25 | [owner] = await ethers.getSigners(); 26 | dohaToken = await DohaToken.deploy(coFounders); 27 | await dohaToken.deployed(); 28 | }); 29 | 30 | describe("Deployment", function () { 31 | it("Should assign tokens to the owner and distribute to co-founders", async function () { 32 | const ownerBalance = await dohaToken.balanceOf(owner.address); 33 | const totalSupply = await dohaToken.totalSupply(); 34 | expect(ownerBalance).to.equal(totalSupply.mul(90).div(100)); // 90% to owner 35 | 36 | for (let i = 0; i < coFounders.length; i++) { 37 | const coFounderBalance = await dohaToken.balanceOf(coFounders[i]); 38 | expect(coFounderBalance).to.equal(totalSupply.mul(10).div(100).div(10)); // 10% total, split among 10 39 | } 40 | }); 41 | }); 42 | 43 | describe("ICO functionality", function () { 44 | beforeEach(async function () { 45 | await dohaToken.startICO(); 46 | }); 47 | 48 | it("Should allow buying tokens", async function () { 49 | const buyAmount = ethers.utils.parseEther("1"); // Sending 1 ETH 50 | await owner.sendTransaction({ to: dohaToken.address, value: buyAmount }); 51 | 52 | const addr1Balance = await dohaToken.balanceOf(owner.address); 53 | expect(addr1Balance).to.be.gt(0); // Expect owner to have some tokens 54 | }); 55 | 56 | it("Should reject purchasing when ICO is not running", async function () { 57 | await dohaToken.finishICO(); 58 | await expect(owner.sendTransaction({ to: dohaToken.address, value: ethers.utils.parseEther("1") })) 59 | .to.be.revertedWith("ICO is not running"); 60 | }); 61 | }); 62 | 63 | describe("Minting", function () { 64 | it("Should allow owner to mint tokens", async function () { 65 | const mintAmount = ethers.utils.parseEther("1000"); // Minting 1000 tokens 66 | const recipient = "0xRecipientAddress"; // Address to mint tokens to 67 | 68 | await dohaToken.mint(recipient, mintAmount); 69 | 70 | const recipientBalance = await dohaToken.balanceOf(recipient); 71 | expect(recipientBalance).to.equal(mintAmount); 72 | }); 73 | 74 | it("Should not allow non-owner to mint tokens", async function () { 75 | const nonOwner = (await ethers.getSigners())[1]; // Get another account 76 | const mintAmount = ethers.utils.parseEther("1000"); 77 | 78 | await expect(dohaToken.connect(nonOwner).mint(nonOwner.address, mintAmount)) 79 | .to.be.revertedWith("Ownable: caller is not the owner"); 80 | }); 81 | }); 82 | 83 | describe("Burning", function () { 84 | it("Should burn tokens", async function () { 85 | const burnAmount = ethers.utils.parseEther("100"); 86 | await dohaToken.mint(owner.address, burnAmount); 87 | const initialBalance = await dohaToken.balanceOf(owner.address); 88 | await dohaToken.burn(burnAmount); 89 | const finalBalance = await dohaToken.balanceOf(owner.address); 90 | expect(finalBalance).to.equal(initialBalance.sub(burnAmount)); 91 | }); 92 | }); 93 | }); --------------------------------------------------------------------------------