In this comprehensive guide, you'll learn how to:
- Deploy an ERC20 token smart contract on Ethereum
- Mint tokens and manage balances
- Set up a Uniswap v3 liquidity pool
- Enable token swapping functionality
👉 Discover more about decentralized finance
ERC20 Token Smart Contract
We'll use OpenZeppelin's audited smart contract templates to create our cryptocurrency token. These battle-tested contracts provide secure, standardized functionality for token creation.
Token Contract Code
Create a file named myToken.sol with the following Solidity code:
pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
contract myToken is ERC20PresetMinterPauser {
constructor() ERC20PresetMinterPauser("myToken", "MYT") {}
}Key components:
"myToken": The token name"MYT": The token symbol- Inherits all standard ERC20 functions plus minting capabilities
You can test this contract in Remix IDE before deployment.
Deploying A New Token To Ethereum
Required Tools
- NodeJS (JavaScript runtime)
- Git (version control)
- Truffle Suite (development framework)
- Infura API Key (Ethereum node access)
- MetaMask (crypto wallet)
Deployment Steps
Initialize Truffle project:
truffle init git clone https://github.com/OpenZeppelin/openzeppelin-contracts.git npm install @truffle/hdwallet-providerConfigure
truffle-config.js:const HDWalletProvider = require('@truffle/hdwallet-provider'); const infuraKey = 'YOUR_INFURA_KEY'; const mnemonic = 'YOUR_MNEMONIC'; ropsten: { provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${infuraKey}`), network_id: 3, gas: 5500000 }Deploy to Ropsten testnet:
truffle compile truffle migrate --network ropsten
👉 Learn advanced blockchain development techniques
Minting Tokens Using Truffle Console
After deployment:
Create contract instance:
const instance = await myToken.deployed();Mint tokens to an address:
instance.mint('0x...','1000000000000000000000'); // Mints 1000 tokens (18 decimals)Check balances and transfer:
instance.balanceOf('0x...'); instance.transfer('0x...','500000000000000000000'); // Transfers 500 tokens
Setting Up A Uniswap Liquidity Pool
Pool Configuration
- Visit Uniswap v3 interface (Ropsten network)
- Navigate to Pool > Create a Pool
Parameters:
- Token address: Your contract address
- Fee tier: 0.3% (standard for most tokens)
- Initial price: Set your token's ETH value (e.g., 0.001 ETH per MYT)
- Liquidity range: Define your active price range
Adding Liquidity
- Approve token spending
- Deposit both ETH and your token
- Confirm the transaction
Typical deployment costs:
- ERC20 deployment: ~0.065 ETH
- Pool creation: ~0.032 ETH
Swapping ETH For Your New Token
Once liquidity is added:
- Users can swap between ETH and your token
- New users may need to add your token manually using its contract address
Consider applying for token listings on:
- CoinGecko
- Other reputable token lists
FAQ
What's the difference between a token address and wallet address?
The token address is where your smart contract lives on-chain. Wallet addresses represent user accounts that hold tokens.
How much liquidity should I provide?
A good starting point is 5x your expected daily trading volume. More liquidity reduces price volatility during swaps.
Can I change token parameters after deployment?
No, most token characteristics (name, symbol, decimals) are immutable after deployment. Plan carefully before launching.
What's the advantage of concentrated liquidity?
It allows you to provide liquidity more efficiently by focusing on specific price ranges, earning more fees for your capital.
Conclusion
Creating and listing a new token has become remarkably accessible:
- Smart contract deployment takes minutes with modern tools
- Liquidity pools enable immediate trading
- Costs are primarily in liquidity provision, not technical setup
👉 Explore more DeFi opportunities
Remember that successful tokens require:
- Clear utility
- Community support
- Sustainable tokenomics
- Ongoing development
This guide provides the technical foundation - the rest is up to your vision and execution.