ERC-20 token
ERC-20 tokens are blockchain-based assets, issued on the Ethereum network, that have value and can be sent and received. These tokens are fungible, meaning they can be exchanged with another token of the same type because they have identical properties and there is an equal value. For example, the ERC-20 token of Alice is exactly the same as the ERC-20 token of Bob. They can exchange their token without consequences.
Examples of fungible assets are currencies, stocks of a company, bonds, gold and other precious metals.
The ERC-20 smart contract is the perfect standard to organize a crowdsale and let companies raise funds to launch their project.
ERC-20 smart contract features
An ERC-20 smart contract is used to create fungible tokens and bring them to the blockchain. This process is called minting. It also keeps track of the total supply as well as the balances of users as they exchange their tokens.
The ERC-20 smart contract on the SettleMint platform has the following features:
- Custom name, symbol and initial supply that can be chosen by the user.
- Minting capabilities that let the admin of the smart contract mint (i.e create) new tokens.
- Pausable capabilities that let the admin pause the contract in case of emergency.
- Burnable capabilities that let users burn (i.e destroy) their token.
By default, the account that deploys the ERC-20 smart contract gets 1,000,000 tokens. You can change this behaviour by modifying the “constructor” in “GenericToken.sol”. If you do not mint tokens in the constructor, make sure to mint some after the deployment.
contract GenericToken is ERC20, ERC20Burnable, Pausable, AccessControl {
constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_mint(msg.sender, 1000000 * 10**decimals());
}
Deploying an ERC-20 smart contract
To set the name and symbol for your token, go to the “deploy” folder and in “00_Deploy_GenericToken.ts”, change the values in “args” in the “deploy” function.
await deploy('GenericToken', {
from: deployer,
args: ['GenericToken', 'GT'],
log: true,
});
As soon as you are happy with the changes you made, just click on “deploy” in the “task runner” of the IDE and after a few seconds, your ERC-20 smart contract should be deployed on the network of your choice.
The