| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { web3 } from "hardhat";
- import deployer from '../.secret'
- 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: '0x0000000000000000000000000000000000000000',
- value: 1e9
- }
- await web3.eth.sendTransaction(rawTx).then(console.log)
- })
- it('Weth test', async () => {
- const WETH_ABI = require('../abi/WETH_ABI').default
- const WETH_ADDR = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
- 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,
- to: '0x0000000000000000000000000000000000000000'
- }
- await weth_contract.methods.withdraw(1e9).send(rawTx).then(console.log)
- })
- })
|