|
|
@@ -16,20 +16,31 @@ describe('Base operation test', () => {
|
|
|
|
|
|
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: '0x10'
|
|
|
+ value: 1e9
|
|
|
}
|
|
|
|
|
|
- const signedObj = await web3.eth.accounts.signTransaction(rawTx, deployer.private)
|
|
|
- if (signedObj.rawTransaction != null) {
|
|
|
- console.log('ready send hash: ' + signedObj.transactionHash)
|
|
|
- await web3.eth.sendSignedTransaction(signedObj.rawTransaction).on('error', function (rst) {
|
|
|
- console.error(rst)
|
|
|
- })
|
|
|
- console.log('sent finish.')
|
|
|
+ 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)
|
|
|
})
|
|
|
})
|