[英]transaction not mined on rinkeby network even with a very high gas price
I'm playing Ethernaut level 1, and I created a truffle script.我正在玩 Ethernaut 1 级,我创建了一个松露脚本。 But the transaction is not mined.但该交易并未被挖掘。 So I increased the gasPrice
to gasPrice * 5
, but it still times out in 750 seconds.所以我将gasPrice
增加到gasPrice * 5
,但它仍然在 750 秒内超时。
Does anyone know what's wrong?有谁知道出了什么问题? The program first prints txHash: XXXX
, and times out after a long time:程序先打印txHash: XXXX
,时间长了就超时了:
require('dotenv').config()
let privateKey = process.env["RINKEBY_PRIVATE_KEY"]
let account = web3.eth.accounts.privateKeyToAccount(privateKey)
async function main () {
let level1 = new web3.eth.Contract(
artifacts.require("Level1").abi,
"0x7717554cE81f6255D223e64f6cA9ABF4c131e4cf"
);
console.log('contract object created')
await level1.methods.contribute().send({
from: account.address,
value: web3.utils.toWei("0.0001", "ether"),
gas: 10000000,
gasPrice: await web3.eth.getGasPrice() * 5,
gasLimit: 5000000
}).on('transactionHash', (txHash) => {
console.log("txHash: "+ txHash)
}).on('error', (error) => {
console.log("error: " + error)
})
console.log('contribute() done')
await level1.send(web3.utils.toWei("0.0001", "ether")).on('receipt', console.log);
console.log('send() done')
await level1.methods.withdraw().send({
from: account.address,
value: web3.utils.toWei("0.0001", "ether"),
gasPrice: await web3.eth.getGasPrice() * 5,
gasLimit: 50000
}).on('transactionHash', (txHash) => {
console.log("txHash: "+ txHash)
}).on('error', (error) => {
console.log("error: " + error)
})
console.log('withdraw() done')
let balance = await web3.eth.getBalance(account)
console.log(balance.toString())
}
main()
.then(() => {
})
.catch((err) => {
console.log(err)
})
module.exports = () => {}
I've reduced the gas price and it worked, but I don't know why:我已经降低了汽油价格并且它起作用了,但我不知道为什么:
require('dotenv').config()
let privateKey = process.env["RINKEBY_PRIVATE_KEY"]
let account = web3.eth.accounts.privateKeyToAccount(privateKey)
async function main () {
let level1 = new web3.eth.Contract(
artifacts.require("Level1").abi,
"0x792E9c766436Aa7CA99Fd1eBDdCFf0480243Fd1c"
);
console.log('contract created')
await level1.methods.contribute().send({
from: account.address,
value: web3.utils.toWei("0.0009", "ether"),
gasPrice: await web3.eth.getGasPrice(),
gasLimit: 1000000
}).on('transactionHash', (txHash) => {
console.log("txHash: "+ txHash)
})
console.log('contribute() done')
await web3.eth.sendTransaction({
from: account.address,
to: level1._address,
value: web3.utils.toWei("0.0009", "ether")
}).on('error', (error) => {
console.log("error: " + error)
})
console.log('sendTransaction() done')
await level1.methods.withdraw().send({
from: account.address,
gasPrice: await web3.eth.getGasPrice(),
gasLimit: 1000000
}).on('transactionHash', (txHash) => {
console.log("txHash: "+ txHash)
})
console.log('withdraw() done')
let balance = await web3.eth.getBalance(level1._address)
console.log(balance.toString())
}
main()
.then(() => {
})
.catch((err) => {
console.log(err)
})
module.exports = () => {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.