Alchemy: Create Your Own ERC20 Cryptocurrency
Learn how to create your own ERC20 Cryptocurrency.
Last updated
Was this helpful?
Learn how to create your own ERC20 Cryptocurrency.
Last updated
Was this helpful?
ERC20 is a token contract that keeps track of fungible tokens, such as exchange currency, staking, or other things with an exact value. ERC20 tokens do not have special rights or behaviors associated with them like non-fungible tokens (NFTs) do.
An example of ERC20 tokens are Shiba Inu (SHIB), Chainlink (LINK), and Wrapped Bitcoin (WBTC).
Read below to learn how to create your own ERC20 Cryptocurrency.
This tool is available on a Linux or macOS system.
Set up a credentials file for S3FS at ${HOME}/.passwd-s3fs
. You will need to save your Filebase Access and Secret keys to this file and give it owner permissions. You can do so with the following commands:
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ${HOME}/.passwd-s3fs
chmod 600 ${HOME}/.passwd-s3fs
You can mount a Filebase IPFS bucket with the command:
s3fs mybucket /path/to/mountpoint -o passwd_file=${HOME}/.passwd-s3fs -o url=https://s3.filebase.com
mybucket: name of your Filebase bucket
/path/to/mountpoint
Create a new folder for your project:
mkdir myFirstToken
yarn add hardhat @nomiclabs/hardhat-waffle @nomiclabs/hardhat-ethers ethers ethereum-waffle
npx hardhat
Select ‘Create a Basic Sample Project’ > ‘Leave Default Root’ > ‘Add a .gitignore’.
Select the ‘Create App’ button to get started.
Set the chain to ‘Polygon’, and the network to ‘Mumbai’.
Add the following code into the module.exports section:
Replace ALCHEMY_HTTP_URL with your Alchemy HTTP key we previously copied.
yarn add dotenv
.env
.This will house your wallet’s private key. If you plan to upload your project files to GitHub, we recommend adding this file to your .gitignore, which will prevent this file from being pushed to GitHub where your wallet’s private key will be accessible by others.
.env
file, input the following variable:PRIVATE_KEY=”CRYPTO WALLET PRIVATE KEY”
Replace the value with your wallet’s private key.
require('dotenv').config()
Then in the module.exports section, add the following accounts: line:
Overall, your hardhat.config.js file should resemble the following:
Token.sol
. Input the following content into this new file:Replace the values to match your desired configuration:
TokenName: Token Name
TKN: Token Symbol
This contract uses a fixed supply of tokens, meaning the total amount of tokens available to be minted and traded is a fixed value.
scripts
directory, rename the file sample-script.js
to deploy.js
, and replace the existing content with the following:Replace TokenName and tokenName with the name of the token you configured in Token.sol.
Use the following command to compile:
npx hardhat compile
npx hardhat run ./scripts/deploy.js --network mumbai
Take note of the contract address that gets returned.
This tutorial uses Metamask. If you are using another wallet provider, the workflow will differ.
Make sure you are on the Mumbai network, then scroll down to ‘Import Tokens’.
Then select ‘Add Custom Token’.
Congratulations! You’ve created your own Cryptocurrency!
ACCESS_KEY_ID is your Filebase Access key, and SECRET_ACCESS_KEY is your Filebase Secret key. For more information on Filebase access keys, see .
If you are using Metamask, follow the instructions found .
Navigate to the , select the Mumbai network, and send some MATIC to your wallet address.