1

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()

2
  • What does compile.js do? What does the contract look like? Do you have enough ether to pay the transaction fees? Do you have a previous pending transaction? You aren't setting gasPrice when sending the transaction, why?
    – Ismael
    Dec 26, 2021 at 18:10
  • Ugh too many questions. turns out the code was just fine, I deployed the same code to Kovan and it deployed without any errors. Anyways, thanks for the help! Dec 28, 2021 at 8:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.