简体   繁体   中英

Error: transaction underpriced while deploying to rinkeby

The below code just stops working at the line "Attempting to deploy from account: .." in console and after sometime it gives "Trnsaction was not mined within 750s, please make sure your transaction was sent properly", Earlier it was giving the error "transaction underpriced", I tried adding gasPrice and increasing the gas price but still got the same result. can anyone help me out?

const hdWalletProvider = require('@truffle/hdwallet-provider')
const Web3 = require('web3')
const { interface, bytecode } = require('./compile')

const provider = new hdWalletProvider(
  'fee brass payment tiny edge spoon control trophy provide rather harbor course',
  'https://rinkeby.infura.io/v3/53ed6ca9c43446a98fb1f9f799d2ca8f'
)

const web3 = new Web3(provider)

const deploy = async () => {
  const accounts = await web3.eth.getAccounts()

  console.log('Attempting to deploy from account:' + accounts[0])

  const result = await new web3.eth.Contract(JSON.parse(interface))
    .deploy({
      data: bytecode,
      arguments: ['hello there!'],
    })
    .send({ gas: '1000000', from: accounts[0] })

  console.log('Contract deployed to:' + result.options.address)
  provider.engine.stop()
}
deploy()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM