It’s one of the safest existing way to create a digital asset that can’t be counterfeited. Once the contract is deployed, all the supply is sent to your own address. We will deploy this contract on the Goerli network, which is an Ethereum testnet.
// SPDX-License-Identifier: GPL-3.0pragma solidity >=0.6.0 <0.8.0;import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";contract MyStupidToken is ERC20
constructor() ERC20("My Stupid Token", "MST")
Here’s how to deploy it using Remix IDE:
- Copy the piece of code above, and go to Remix, click on ‘New File’ (you’ll rename it later), paste your code here, change the name (‘My Stupid Token’) and the 3 letters (‘MST’), and change the supply (10000).
- Then in the file explorer (on the left), do a right click on your file and select ‘rename’. Make sure each word of your ‘.sol’ file name starts with a capital letter.
- In the left menu, click on ‘Solidity Compiler’ (you can use the version 0.7.4), then click on the big ‘Compile’ button.
- In the left menu again, click on ‘Deploy & run transactions’ and select ‘Injected Web3’ as ‘environment’.
- In Metamask (Chrome extension), make sure you’ve selected the Goerli Network.
- Click on ‘Deploy’. Copy the address of this contract.
The token contract is now deployed on Goerli network, which also means that you currently have 100% of the supply in your wallet. You can check what’s happening on the (Goerli) blockchain thanks to Etherscan:
Add a custom token in Metamask
Let’s add your token in Metamask:
- In Metamask, click on the left menu.
- At the bottom of the window, click on ‘Add a token’.
- Select ‘Custom token’, in ‘Token contract address’, paste the address of your contract, fill the ‘Symbol’ field with the three letters, and put ‘18’ in the ‘Decimals’ field.
- Click on ‘Next’.