0

This my delpoy.js file:

const HDWalletProvider = require("@truffle/hdwallet-provider");
const Web3 = require('web3');
const {abi , bytecode} = require('./compile');
const provider = new HDWalletProvider(
    'december blossom school two brief lunar siren truth purse violin car submit',
    'https://rinkeby.infura.io/v3/737d5964ada94e2a8d812f1414c89c4e'
)
const web3 = new Web3(provider)
async function scan(message) {
    process.stdout.write(message);
    return await new Promise(function(resolve, reject) {
        process.stdin.resume();
        process.stdin.once("data", function(data) {
            process.stdin.pause();
            resolve(data.toString().trim());
        });
    });
}

async function getGasPrice(web3) {
    while (true) {
        const nodeGasPrice = await web3.eth.getGasPrice();
        const userGasPrice = await scan(`Enter gas-price or leave empty to use ${nodeGasPrice}: `);
        if (/^\d+$/.test(userGasPrice))
            return userGasPrice;
        if (userGasPrice == "")
            return nodeGasPrice;
        console.log("Illegal gas-price");
    }
}

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(abi)
        .deploy({data:'0x' +bytecode ,arguments: ['hii']})
        .send({from: accounts[0],gas: 1500000,gasPrice: await getGasPrice(web3)})
    console.log('contract deployed to', result.options.address);
}
deploy()

Output:

node deploy.js
attempting to deploy from account 0x010Ff624891610c8538824AB6F5AF4abfD1c3bfd
Enter gas-price or leave empty to use 1000000000: 1000000000
Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!
Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!
D:\github\blockchain\solidity-etherium\index\node_modules\solc\soljson.js:1
(function (exports, require, module, __filename, __dirname) { "use strict";var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in
Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Modu

RuntimeError: abort(Error: Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!). Build with -s ASSERTIONS=1 for more info.
    at process.abort (D:\github\blockchain\solidity-etherium\index\node_modules\solc\soljson.js:1:14506)
    at process.emit (events.js:189:13)
    at emitPromiseRejectionWarnings (internal/process/promises.js:119:20)
    at process._tickCallback (internal/process/next_tick.js:69:34)



  • Check the transaction pool of your node(s) (assuming private chain). Check that there is a miner on your network. – Florian Castelain Feb 27 at 7:07
  • @FlorianCastelain I'm deploying it on the rinkeby network – Ketan Verma Mar 6 at 17:03
0

This is a legitimate scenario, and it is typical to cases where transactions with a higher gas price than yours have been submitted around the same time as yours.

You can extend your code to check the transaction status later, or increase the gas price and retry executing the transaction.

Keep in mind to use the same nonce when you retry, so that your transaction doesn't end up being executed twice.

Also keep in mind that one of the two attempts will revert for sure, so you'll need to catch and handle that error as well.

As you can understand, handling all scenarios of executing a transaction can be rather complicated.

In particularly the error that you are currently dealing, because although you're getting an exception, it doesn't mean that your transaction has reverted (i.e., it's a "neither success nor failure" scenario that you need to deal with).


Increasing the gas price of your transaction:

Since you are not specifying it in your code, the node that you're sending it to uses the default value, which is computed as some sort of weighted-average of the last N transactions.

Thus, several transactions with a higher gas price submitted around the same time can "reduce the priority" of your transaction, leaving it "stuck in the pool".

So find out the default value right before executing your transaction, and then use a higher value.

For example:

const Web3 = require("web3");

async function scan(message) {
    process.stdout.write(message);
    return await new Promise(function(resolve, reject) {
        process.stdin.resume();
        process.stdin.once("data", function(data) {
            process.stdin.pause();
            resolve(data.toString().trim());
        });
    });
}

async function getGasPrice(web3) {
    while (true) {
        const nodeGasPrice = await web3.eth.getGasPrice();
        const userGasPrice = await scan(`Enter gas-price or leave empty to use ${nodeGasPrice}: `);
        if (/^\d+$/.test(userGasPrice))
            return userGasPrice;
        if (userGasPrice == "")
            return nodeGasPrice;
        console.log("Illegal gas-price");
    }
}

...

const web3 = new Web3(provider)
const deploy = async() =>{
    ...
    .send({
        gas: 1500000,
        gasPrice: await getGasPrice(),
        from: accounts[0]
    })
    ...
}
| improve this answer | |
  • tried your method,but still stuck with no deployments – Ketan Verma Mar 6 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.