For some reason, I’ve spent all day on this. I give assign my token the supply in the deployment.js file but it doesnt seem to show up when I check the balance through metamask. Could someone put me in the right direction? First time setting up a ERC20 so I am quite new to all this.
If you are deploying to a public testnet, then I suggest you look at the holders on Etherscan to see how many tokens the account you are using with MetaMask has, otherwise use truffle console.
I suggest starting with the initial supply hardcoded in the constructor so that you know that there aren’t any issues with decimals. I use SimpleToken.sol for this purpose.
SimpleToken.sol
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
/**
* @title SimpleToken
* @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` functions.
*/
contract SimpleToken is ERC20, ERC20Detailed {
uint8 public constant DECIMALS = 18;
uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(DECIMALS));
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC20Detailed("SimpleToken", "SIM", DECIMALS) {
_mint(msg.sender, INITIAL_SUPPLY);
}
}
Thanks for the reply. This is my deploy.js. By the looks of it, I’m giving my ERC20 the attributes in the wrong file but was following along with a tutorial that done it this way.
In MetaMask, in the menu for your ganache account press add token, and change to custom token and paste in the contract address. You will see 500 MyToken’s with 1 decimal place.
Hi, Yeah, got it all sorted. I didn’t even know you could deploy a smart contract from remix but hey, eveydays a school day so they say Thank you so much for your help, really appreciate it