- Notifications
You must be signed in to change notification settings - Fork61
How to do your first ICO smart contract
License
jellydn/dapp-token-ico
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Opinionated Dapp Starter Template
✨Demo
Place an orderBuy with MetaMask and wait for confirmation.
- ⚡️ React TypeScript template withVite 2
- 📦Hardhat - Ethereum development environment for professionals
- 🦾TypeChain Hardhat plugin - Automatically generate TypeScript bindings for smartcontracts while using Hardhat.
- 🔥web3-react - A simple, maximally extensible, dependency minimized framework for building modern Ethereum dApps
- 🎨daisyUI Tailwind CSS Components - clean HTML with component classes
- 🎨OpenZeppelin - standard for secure blockchain applications
yarn install
yarn dev
yarntest
Sign up and earn$100 in credit on alchemy. More detailhere.
Send some ETH to your wallethttps://faucet.dimensions.network/
Create .env from .env.example from root directory. Remember to fill the value for deployed addresses.
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1ROPSTEN_PROVIDER_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>PRIVATE_KEY=<YOUR PRIVATE KEY>VITE_CROWDSALE_ADDRESS=<YOUR DEPLOYED SMART CONTRACT ADDRESS>VITE_PROVIDER_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
Then deploy to specific network, e.g: Ropsten
npx hardhat run scripts/deploy_itmantokencrowdsale.js --network ropsten
Output:
Generating typings for: 0 artifactsin dir: src/typesfor target: ethers-v5Successfully generated 3 typings!Successfully generated 3 typingsfor external artifacts!ITManToken deployed to: 0x58f0A11F8B2bD7c5D9251b620dcF502D3A40FCF2Name ITManTokenSymbol ITMDecimals 18Total Supply BigNumber { _hex:'0xd3c21bcecceda1000000', _isBigNumber:true }Owner 0x096cd10D7BEF8D5923b18b18E9f79CA230ee2285openingTime 1630780077closeTime 1631384877ITManTokenCrowdsale deployed to: 0x304c476c4521B6d352E76a950581A59Fe2032437
Next step is verifying the IT Man Token
npx hardhat verify --network ropsten 0x58f0A11F8B2bD7c5D9251b620dcF502D3A40FCF2
Output:
Nothing to compileGenerating typings for: 0 artifactsin dir: src/typesfor target: ethers-v5Successfully generated 3 typings!Successfully generated 3 typingsfor external artifacts!Compiling 1 file with 0.8.4Successfully submittedsource codefor contractcontracts/ITManToken.sol:ITManToken at 0x58f0A11F8B2bD7c5D9251b620dcF502D3A40FCF2for verification on Etherscan. Waitingfor verification result...Successfully verified contract ITManToken on Etherscan.https://ropsten.etherscan.io/address/0x58f0A11F8B2bD7c5D9251b620dcF502D3A40FCF2#code
Finally, verify the IT Man Token Crowdsale
npx hardhat verify --network ropsten 0x304c476c4521B6d352E76a950581A59Fe2032437 500 0x096cd10D7BEF8D5923b18b18E9f79CA230ee2285 0x58f0A11F8B2bD7c5D9251b620dcF502D3A40FCF2 0x096cd10D7BEF8D5923b18b18E9f79CA230ee2285 1630780077 1631384877
Output:
Nothing to compileGenerating typings for: 0 artifactsin dir: src/typesfor target: ethers-v5Successfully generated 3 typings!Successfully generated 3 typingsfor external artifacts!Compiling 1 file with 0.8.4... some warningsSuccessfully submittedsource codefor contractcontracts/ITManTokenCrowdsale.sol:ITManTokenCrowdsale at 0x304c476c4521B6d352E76a950581A59Fe2032437for verification on Etherscan. Waitingfor verification result...Successfully verified contract ITManTokenCrowdsale on Etherscan.https://ropsten.etherscan.io/address/0x304c476c4521B6d352E76a950581A59Fe2032437#code
This project demonstrates an advanced Hardhat use case, integrating other tools commonly used alongside Hardhat in the ecosystem.
The project comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts. It also comes with a variety of other tools, preconfigured to work with the project code.
Try running some of the following tasks:
npx hardhat accountsnpx hardhat compile --network localhostnpx hardhat cleannpx hardhattestnpx hardhat nodenpx hardhathelpREPORT_GAS=true npx hardhattestnpx hardhat coveragenpx hardhat run scripts/deploy_greeter.js --network localhostnode scripts/deploy.jsnpx eslint'**/*.js'npx eslint'**/*.js' --fixnpx prettier'**/*.{json,sol,md}' --checknpx prettier'**/*.{json,sol,md}' --writenpx solhint'contracts/**/*.sol'npx solhint'contracts/**/*.sol' --fix
To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Ropsten.
In this project, copy the .env.example file to a file named .env, and then edit it to fill in the details. Enter your Etherscan API key, your Ropsten node URL (eg from Alchemy), and the private key of the account which will send the deployment transaction. With a valid .env file in place, first deploy your contract:
npx hardhat run --network ropsten scripts/deploy_greeter.js
Then, copy the deployment address and paste it in to replaceDEPLOYED_CONTRACT_ADDRESS
in this command:
npx hardhat verify --network ropsten DEPLOYED_CONTRACT_ADDRESS"Hello, Hardhat!"
OpenZeppelin provides tooling for deploying and securingupgradeable smart contracts.
Smart contracts deployed using OpenZeppelin Upgrades Plugins can be upgraded to modify their code, while preserving their address, state, and balance. This allows you to iteratively add new features to your project, or fix any bugs you may find in production.
In this project, there are a 2 versions of contract: Box and BoxV2 which is improvement of Box. First deploy your contract:
npx hardhat run --network localhost scripts/deploy_upgradeable_box.js
Then, deploy the upgrade smart contract
npx hardhat run --network localhost scripts/upgrade_box.js
- Simple Store App: counter-like smart contract, read/write value and listen to event from smart contract.
👤Dung Huynh
- Website:https://productsway.com/
- Twitter:@jellydn
- Github:@jellydn
Give a ⭐️ if this project helped you!