Skip to content

Commit

Permalink
Update ERC20 Token with Decimals & Permit support (#220)
Browse files Browse the repository at this point in the history
* Update ERC20 Token with Decimals & Permit support

* Fixing decimals on token amounts

* Fix lint

* Change to float number

* lint

* Handle 0 decimal case with int value on transfer

* lint
  • Loading branch information
seaona authored Mar 17, 2023
1 parent 5fc7801 commit 9947689
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 117 deletions.
17 changes: 17 additions & 0 deletions contracts/ERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
import "@openzeppelin/[email protected]/token/ERC20/extensions/draft-ERC20Permit.sol";

contract MyToken is ERC20, Ownable, ERC20Permit {

constructor(uint256 initialAmount, string memory tokenName, uint8 decimalUnits, string memory tokenSymbol) ERC20(tokenName, tokenSymbol, decimalUnits) ERC20Permit(tokenName) {
_mint(msg.sender, initialAmount * 10 ** decimals);
}

function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
Loading

0 comments on commit 9947689

Please sign in to comment.