Univ3Test.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { web3 } from "hardhat";
  2. import deployer from '../.secret'
  3. describe('Univ3 Test', () => {
  4. it('Parse ether test', async () => {
  5. console.log(web3.utils.toWei('1', 'gwei'))
  6. })
  7. it('Get block number test', async () => {
  8. console.log(await web3.eth.getBlockNumber())
  9. })
  10. it('Get balance test', async () => {
  11. console.log(await web3.eth.getBalance(deployer.address))
  12. })
  13. it('Transfer test', async () => {
  14. let rawTx = {
  15. nonce: await web3.eth.getTransactionCount(deployer.address),
  16. gasPrice: web3.utils.toWei('2', 'gwei'),
  17. gasLimit: 1_000_000,
  18. to: '0x0000000000000000000000000000000000000000',
  19. value: '0x05'
  20. }
  21. const signedObj = await web3.eth.accounts.signTransaction(rawTx, deployer.private)
  22. if (signedObj.rawTransaction != null) {
  23. console.log('ready send hash: ' + signedObj.transactionHash)
  24. await web3.eth.sendSignedTransaction(signedObj.rawTransaction).on('error', function (rst) {
  25. console.error(rst)
  26. })
  27. console.log('sent finish.')
  28. }
  29. })
  30. })