-
- Formal erc20 definition: https://ethereum.org/en/developers/docs/standards/tokens/erc-20/.
- Methods: name, symbol, decimals, totalSupply, balanceOf, transfer.
- Events: Transfer, Approval.
- Maintained by OpenZeppelin.
- https://docs.openzeppelin.com/contracts/4.x/api/token/erc20.
- Created ERC20 token to compare to BrianCoin on Sol.
- Through remix. Gives you web3, ethers.js, an account address, more. Interact with deployed contracts. Orange methods modify the blockchain, costing gas. Blue methods do not. Native deploys to remix EVM (not accessible outside remix).
- Used solidity to write the contract and inherit from ERC20 rather than spl’s cli.
- Total token supply.
- Fixed: return total amount to the address that initially deployed the contract. That creator can redistribute however they’d like. If _mint is called in the constructor, that’s the max forever. Can’t be called again, only called once at deployment when the contract is instantiated. If mint() is a public method, it can be called over and over.
- Lazy minting: tokens are received as the result of an event (typically a reward). Mining a block, purchasing something, etc. This can be uncapped or have a max supply.
- Inherit from ERC20Capped and add the cap to the constructor to enforce.
- Inherit from Ownable to use onlyOwner, eg to restrict minting to only the person who originally deployed the contract.
- @openzeppelin/contracts/access for all the security and RBAC: https://docs.openzeppelin.com/contracts/4.x/access-control.
- Then got out of remix and used a local dev blockchain. Went with hardhat instead of truffle to get some lateral experience.
- Tested against an alchemy node (rather than my local geth, or ganache, or infura).
- Update the deploy script with hardhat.ethers.getContractFactory and provide the inputs (cap) rather than remix’ gui.
- Did the dev version of erc20 brian coin on the polygon mumbai test network. Just add the http endpoint from alchemy to module.exports.networks.<mumbai>.url.<address>. And priv key of deploying address to dotenv, read in on hardhat.config as well.
- Added mumbai to metamask. It’s a child of goerli. Faucet: https://faucet.polygon.technology/. Added the custom token as well (via simple address after hardhat deploy).
- Overall, I liked the local dev experience of truffle/ganache better than hardhat/alchemy.
- And overall, I liked the sol dev experience better than eth.
- “sill idealTree buildDep” timing out during npm install. https://github.com/npm/cli/issues/3257.
- Disconnect the vpn, or npm config set http[s]-proxy to the proper address.
- Remember your wallet seed phrase (at least in metamask) is only associated to the first account. Other accounts must be imported with their relevant private keys. If someone obtains the private key of one account, that doesn’t mean they get automatic access to all other accounts you have in your metamask wallet.