본문으로 건너뛰기
샘플 앱으로 돌아가기

EVM Token Factory

The EVM Token Factory app enables you to create an ERC-20 token on any EVM-compatible blockchain. You can customize the token name, symbol, and initial supply with ease.

프론트엔드 프레임워크/라이브러리:
React/Next.js
언어:
TypeScript
빌드 도구/개발 서버:
Next.js
샘플 앱 미리 보기

개요

The EVM Token Factory app enables you to create an ERC-20 token on any EVM-compatible blockchain. You can customize the token name, symbol, and initial supply with ease. Currently, the app supports Sepolia and Holesky, but you can add more networks as needed.

중요 공지

The Holesky testnet is no longer actively maintained. The overall process is valid for other chains, such as Hoodi testnet. If you’d like to see an updated version of this app or support for additional chains, please open an issue or a PR in the qn-guide-examples repository.

미리 보기

미리 보기

The app uses Next.js 14 project bootstrapped with create-next-app.


시작하기

프로젝트 디렉터리를 엽니다:

cd sample-dapps/evm-token-factory

Set Environment Variables


  1. Rename .env.example ~에 .env.local and update it with RPC URLs for each blockchain. Also, include your WalletConnect. project ID (optionally, you can leave this blank but some features will not be supported). To create RPC URLs for each chain, you can run your own node locally or use a service like 퀵노드 to quickly spin up a node endpoint.

Configure Smart Contract Addresses

  1. 다음 내용을 업데이트하십시오. factoryAddress value in evm-token-factory/app/utils/ethereum.ts with your deployed factory contract address. This is the address you received in the output during the Deployment section.

  2. Remove any unused chains (e.g., mainnet) from the src/context/web3modal.tsx 파일.

RPC Configuration

This app requires a valid RPC URL for each blockchain you want to support. Here are more details on how RPC is configured throughout the app.


  • The RPC URLs referenced in the .env.local file are for the WalletConnect modal.
  • To send transactions, the app utilizes the ethers.BrowserProvider class to wrap an injected provider (e.g., MetaMask, Rabby, Coinbase Wallet) and use the providers RPC configuration. Therefore, users interacting with the app should have the network they're creating tokens on added to their wallet and switched to that RPC network. Failing to do so will result in the app displaying a "This app doesn’t support your current network. Switch to an available option following to continue." message.

If you do not want to support a blockchain(s), you can remove references of the chain(s) from the src/context/web3modal.tsx 파일.

의존성 설치

그런 다음, 종속성을 설치하세요:

npm install
# 또는
yarn
# 또는
pnpm 설치
# 또는
bun install

After, start the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the app.


Using the Dapp


  1. Connect your wallet

    • Make sure you have enough ETH (or other native EVM gas token) in your wallet to cover the create token transaction
    • If you are using Testnet, you can get free ETH from the Quicknode Faucet
  2. Click "Create Token" and confirm the transaction to create the ERC-20 token!

건축

├── app
│ ├── api
│ │ └── evm
│ │ └── createToken
│ │ └── route.ts # API Method for calling CreateToken function
│ ├── components
│ │ ├── Connect.tsx # Web3Modal Component
│ │ ├── Footer.tsx
│ │ └── Navbar.tsx
│ ├── favicon.ico
│ ├── globals.css
│ ├── layout.tsx # The Web3Modal component
│ ├── page.tsx # Main page for Token Factory
│ └── utils
│ ├── abi.json # Factory ABI
│ └── ethereum.ts # Chain configuration and helpers
├── context
│ └── web3modal.tsx # Wallet Adapter Context providers
├── contracts
│ ├── README.md
│ ├── foundry.toml # Forge configuration
│ ├── lib # Dependencies
│ ├── remappings.txt # Library mappings
│ ├── script
│ │ ├── Counter.s.sol
│ │ └── CreateToken.s.sol
│ ├── src
│ │ ├── Counter.sol
│ │ ├── Factory.sol
│ │ └── Token.sol
│ └── test
│ ├── Counter.t.sol
│ ├── Factory.t.sol
│ └── Token.t.sol
├── next-env.d.ts
├── next.config.mjs
├── package-lock.json
├── package.json
├── postcss.config.mjs
├── public
│ ├── next.svg
│ ├── preview.png
│ ├── preview2.png
│ └── vercel.svg
├── .env.example # Configure RPCs and WalletConnect Project ID
├── tailwind.config.ts
└── tsconfig.json

스마트 계약

The ERC-20 Token Factory backend built on smart contracts with Solidity can be deployed on any EVM-compatible blockchain. For demonstration purposes, we have deployed the Token Factory to the Sepolia and Holesky testnet. It has not been deployed to any mainnet or L2 chains yet due to gas fee constraints but feel free to deploy it and open a PR in this repo.

The ERC-20 Token Factory is built with two smart contracts:

  • Factory: The Factory contract (contracts/Factory.sol) inherits the Token.sol smart contract and acts as a Factory for creating and tracking new ERC-20 tokens.

  • 토큰: This is an ERC-20 smart contract (contracts/Token.sol) defined by the OpenZeppelin standard and includes a 민트 그리고 transferOwnership function call in the constructor upon deployment.

Supported Chains & Addresses

  • Sepolia: 0x28D99a0A1B430B3669B8A2799dCDd7d332ceDb1C
  • Holesky: 0x5fCCa8dCeD28B13f2924CB78B934Ab0AF445542A

Deploy the Factory to another EVM blockchain

To deploy the Factory contract on a new chain using Foundry, follow these steps:


  1. 확보하십시오 파운드리 is installed and navigate inside the contracts directory. Install the required dependencies with the following commands:
forge install foundry-rs/forge-std --no-commit
forge install OpenZeppelin/openzeppelin-contracts --no-commit
  1. Build (compile) the smart contracts using the 포지 빌드 command.

  2. Run tests using the 포지 테스트 command.

  3. To deploy, run the forge create command below and input the proper RPC network and private key values:

forge create --rpc-url QUICKNODE_HTTP_URL \
--private-key YOUR_PRIVATE_KEY \
src/Factory.sol:TokenFactory

  1. Edit the src/context/web3modal.tsx file and add a new chain object with its chain ID (find a list 여기), name, native gas token currency, explorer URL, and RPC URL (e.g., Quicknode):
export const mainnet = {
chainId: 1,
name: 'Ethereum',
currency: 'ETH',
explorerUrl: 'https://etherscan.io',
rpcUrl: process.env.NEXT_PUBLIC_MAINNET_RPC_URL
}

  1. Add the Factory address and explorer URL to the CHAINS object in app/utils/ethereum.ts. For example:
    1: { // Ethereum Mainnet
factoryAddress: "FACTORY_ADDRESS",
explorerUrl: "https://etherscan.io",
},

If you would like to learn more about creating and deploying smart contracts, check out these resources:



Next.js Documentation

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!


기여 및 피드백
여러분의 의견을 듣고 싶으며, 이 샘플 앱에 대한 모든 기여를 환영합니다!
문제를 신고하거나 피드백을 공유하려면, 다음에서 GitHub 이슈를 생성해 주세요. qn-가이드-예시 저장소.
기여하시려면 다음 단계를 따르세요:
  1. 저장소를 포크하기
  2. 기능 브랜치 생성:
    git checkout -b feature/amazing-feature
  3. 변경 사항을 커밋하세요:
    git commit -m "멋진 기능 추가"
  4. 브랜치를 푸시하세요:
    git push origin feature/amazing-feature
  5. 풀 리퀘스트를 제출하세요.