Loading...
We will be using remix for the deployment purpose. Create new file named your token.sol...
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyTokenname", "MyTokenSymbol") {
_mint(msg.sender, initialSupply);
}
}
Give contract your token name and also in ERC20("", "") put your token name and symbol parameters.
Also constructor takes one more parameter - initialSupply, this will decide how much tokens you want to supply. note that the default decimals in openzeppeline in 18. you can change it if you want by calling their decimals() function. You will need to pass the intialSupply number along with decimals.
function decimals() public view virtual override returns (uint8) {
return 16;
}
Note that you can use more functionality to this like minting new tokens, burning tokens, transfer tokens, etc
// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyTokenname", "MyTokenSymbol") {
_mint(msg.sender, initialSupply);
}
function decimals() public view virtual override returns (uint8) {
return decimalnumber; // eg. return 12;
}
}
you can always add some custom functions in the contract and call the declared functions in openzeppelin erc20 sol file.