tornado-relayer/src.bak/setupWeb3.js

17 lines
476 B
JavaScript
Raw Normal View History

2019-11-23 11:18:54 +03:00
const Web3 = require('web3')
const { rpcUrl, privateKey } = require('../config')
function setup() {
try {
const web3 = new Web3(rpcUrl, null, { transactionConfirmationBlocks: 1 })
const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey)
web3.eth.accounts.wallet.add('0x' + privateKey)
web3.eth.defaultAccount = account.address
return web3
2020-08-04 10:39:56 +03:00
} catch (e) {
2019-11-23 11:18:54 +03:00
console.error('web3 failed')
}
}
const web3 = setup()
2020-08-04 10:39:56 +03:00
module.exports = web3