import { web3 } from "hardhat" import deployer from '../.secret' import contracts from '../config/contracts' import logger from "../utils/logger"; describe('Base operation test', () => { it('Parse ether test', async () => { console.log(web3.utils.toWei('1', 'gwei')) }) it('Get block number test', async () => { console.log(await web3.eth.getBlockNumber()) }) it('Get balance test', async () => { console.log(await web3.eth.getBalance(deployer.address)) }) it('Transfer test', async () => { let rawTx = { from: deployer.address, nonce: await web3.eth.getTransactionCount(deployer.address), gasPrice: web3.utils.toWei('2', 'gwei'), gasLimit: 1_000_000, to: contracts.ZERO, value: 1e9 } await web3.eth.sendTransaction(rawTx).then(console.log) }) it('Weth withdraw test', async () => { const WETH_ABI = require('../abi/WETH_ABI.json') const WETH_ADDR = contracts.WETH let weth_contract = new web3.eth.Contract(WETH_ABI, WETH_ADDR) // await weth_contract.methods.balanceOf(deployer.address).call().then(console.log) let rawTx = { from: deployer.address, nonce: await web3.eth.getTransactionCount(deployer.address), gasPrice: web3.utils.toWei('2', 'gwei'), gasLimit: 1_000_000 } await weth_contract.methods.withdraw(1e15).send(rawTx).then(console.log) }) it ('Weth approve test', async () => { const WETH_ABI = require('../abi/WETH_ABI.json') const WETH_ADDR = contracts.WETH let weth_contract = new web3.eth.Contract(WETH_ABI, WETH_ADDR) // await weth_contract.methods.balanceOf(deployer.address).call().then(console.log) let rawTx = { from: deployer.address, nonce: await web3.eth.getTransactionCount(deployer.address), gasPrice: web3.utils.toWei('2', 'gwei'), gasLimit: 1_000_000 } await weth_contract.methods.approve(contracts.UNIV3, 1e18.toString()).send(rawTx).then(console.log) }) it ('IERC20 name test', async () => { const IERC20_ABI = require('../abi/IERC20_ABI.json') const IERC20_ADDRESS = web3.utils.toChecksumAddress('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48') let ierc20_contract = new web3.eth.Contract(IERC20_ABI, IERC20_ADDRESS) logger.debug(await ierc20_contract.methods.name().call()) logger.debug(await ierc20_contract.methods.symbol().call()) }) })