【发布时间】:2022-01-25 06:10:29
【问题描述】:
下面的代码在控制台中的“尝试从帐户部署:..”行停止工作,一段时间后它给出“Trnsaction 未在 750 秒内开采,请确保您的交易已正确发送”,早些时候它是给出错误“交易低估”,我尝试添加gasPrice并提高gas价格,但仍然得到相同的结果。谁能帮帮我?
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()
【问题讨论】:
标签: javascript deployment ethereum web3 truffle