I'm playing Ethernaut level 1, and I created a truffle script. But the transaction is not mined. So I increased the gasPrice
to gasPrice * 5
, but it still times out in 750 seconds.
Does anyone know what's wrong? The program first prints txHash: XXXX
, and times out after a long time:
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 = () => {}