tornado-relayer/testTxManager.js

39 lines
931 B
JavaScript
Raw Normal View History

2020-09-29 18:01:22 +03:00
const { toHex, toWei } = require('web3-utils')
const TxManager = require('./src/TxManager')
const { rpcUrl, privateKey } = require('./config')
2020-09-29 23:13:45 +03:00
2020-09-29 18:01:22 +03:00
const TxM = new TxManager({
privateKey,
rpcUrl,
2020-09-29 23:13:45 +03:00
config: {
CONFIRMATIONS: 2,
GAS_BUMP_INTERVAL: 1000 * 15,
},
2020-09-29 18:01:22 +03:00
})
const tx = {
from: '0x03Ebd0748Aa4D1457cF479cce56309641e0a98F5',
value: 0,
2020-09-29 23:13:45 +03:00
// gasPrice: toHex(toWei('0.1', 'gwei')),
2020-09-29 18:01:22 +03:00
to: '0x03Ebd0748Aa4D1457cF479cce56309641e0a98F5',
}
async function main() {
const receipt = await TxM.submit(tx)
.on('transactionHash', (hash) => {
console.log('hash', hash)
})
2020-09-29 23:13:45 +03:00
.on('mined', (receipt) => {
console.log('Mined in block', receipt.blockNumber)
})
2020-09-29 18:01:22 +03:00
.on('confirmations', (confirmations) => {
console.log('confirmations', confirmations)
})
console.log('receipt', receipt)
2020-09-29 23:13:45 +03:00
// const hash = await when(TxM.submit(tx), 'transactionHash')
// console.log('hash', hash)
2020-09-29 18:01:22 +03:00
}
main()