Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

How to do your first ICO smart contract

License

NotificationsYou must be signed in to change notification settings

jellydn/dapp-token-ico

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VersionLicense: MITTwitter: jellydn

Opinionated Dapp Starter Template

Demo

Blockchain - DApp 101 - ICO Smart Contract

One click deployment

Deploy on Railway

Screenshot

./screenshot.png

Connect to MetaMask

https://gyazo.com/73e88806e52c1b70211dd4911bf5a4af.gif

Buy tokens

Place an orderhttps://gyazo.com/d6361cc2a18ca3140f2aa9b09fc385ca.gifBuy with MetaMask and wait for confirmation.https://gyazo.com/924565f84487b15f6c391f7a6378de57.gif

Features

  • ⚡️ 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

Install

yarn install

Usage

yarn dev

Run tests

yarntest

ICO Token

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

Hardhat guideline

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

Etherscan verification

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!"

Contract upgrade

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

Examples

  • Simple Store App: counter-like smart contract, read/write value and listen to event from smart contract.

Author

👤Dung Huynh

Stargazers 🌟

Stargazers repo roster for jellydn/dapp-token-ico

Show your support

kofipaypalbuymeacoffee

Give a ⭐️ if this project helped you!


[8]ページ先頭

©2009-2025 Movatter.jp