diff --git a/contracts/test/TestERC20.sol b/contracts/test/TestERC20.sol new file mode 100644 index 000000000..9f9ff7697 --- /dev/null +++ b/contracts/test/TestERC20.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.12; + +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract TestERC20 is ERC20 { + uint8 private immutable __decimals; + + constructor(uint8 _decimals) ERC20("TestERC20", "T20") { + _mint(msg.sender, 1000000000000000000000000); + __decimals = _decimals; + } + + function decimals() public view override returns (uint8) { + return __decimals; + } + + function sudoMint(address _to, uint256 _amount) external { + _mint(_to, _amount); + } + + function sudoTransfer(address _from, address _to) external { + _transfer(_from, _to, balanceOf(_from)); + } + + function sudoApprove(address _from, address _to, uint256 _amount) external { + _approve(_from, _to, _amount); + } +} diff --git a/gascalc/6-simple-wallet-token-transfer.gas.ts b/gascalc/6-simple-wallet-token-transfer.gas.ts new file mode 100644 index 000000000..5145ba7bb --- /dev/null +++ b/gascalc/6-simple-wallet-token-transfer.gas.ts @@ -0,0 +1,22 @@ +import { GasCheckCollector } from './GasChecker' +import { createAddress } from '../test/testutils' +import { ethers } from 'hardhat' +import { TestERC20, TestERC20__factory } from '../typechain' + +// TODO: NOTE: Must be executed separately as otherwise test will reuse SimpleAccount +context.only('ERC-20 Token related', function () { + let token: TestERC20 + + before(async function () { + await GasCheckCollector.init() + GasCheckCollector.inst.createJsonResult = true + token = await new TestERC20__factory(ethers.provider.getSigner()).deploy(18) + }) + + it('simple 1', async function () { + const destEoa = createAddress() + const tx = await token.transfer(destEoa, 100) + const receipt = await ethers.provider.getTransactionReceipt(tx.hash) + console.log(`ERC-20 EOA -> EOA transfer: status = ${receipt.status}; gasUsed = ${receipt.gasUsed.toString()}; txid = ${receipt.transactionHash}`) + }) +})