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: {
|
2020-09-30 13:48:27 +03:00
|
|
|
CONFIRMATIONS: 1,
|
2020-09-29 23:13:45 +03:00
|
|
|
GAS_BUMP_INTERVAL: 1000 * 15,
|
|
|
|
},
|
2020-09-29 18:01:22 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
const tx = {
|
|
|
|
value: 0,
|
2020-09-30 13:48:27 +03:00
|
|
|
gasPrice: toHex(toWei('0.1', 'gwei')),
|
|
|
|
to: '0xA43Ce8Cc89Eff3AA5593c742fC56A30Ef2427CB0',
|
|
|
|
}
|
|
|
|
|
|
|
|
const tx2 = {
|
|
|
|
value: 1,
|
2020-09-29 23:13:45 +03:00
|
|
|
// gasPrice: toHex(toWei('0.1', 'gwei')),
|
2020-09-30 13:48:27 +03:00
|
|
|
to: '0x0039F22efB07A647557C7C5d17854CFD6D489eF3',
|
2020-09-29 18:01:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
2020-09-30 13:48:27 +03:00
|
|
|
const Tx = await TxM.createTx(tx)
|
|
|
|
|
|
|
|
const receipt1 = await Tx.send()
|
2020-09-29 18:01:22 +03:00
|
|
|
.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)
|
|
|
|
})
|
2020-09-30 13:48:27 +03:00
|
|
|
|
|
|
|
// setTimeout(async () => await Tx.cancel(), 800)
|
|
|
|
|
|
|
|
// const receipt2 = await Tx.replace(tx2)
|
|
|
|
// .on('transactionHash', (hash) => {
|
|
|
|
// console.log('hash', hash)
|
|
|
|
// })
|
|
|
|
// .on('mined', (receipt) => {
|
|
|
|
// console.log('Mined in block', receipt.blockNumber)
|
|
|
|
// })
|
|
|
|
// .on('confirmations', (confirmations) => {
|
|
|
|
// console.log('confirmations', confirmations)
|
|
|
|
// })
|
|
|
|
|
|
|
|
// console.log('receipt2', receipt2)
|
|
|
|
console.log('receipt1', await receipt1)
|
2020-09-29 18:01:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|