1

so I'm trying to deploy my first contract on rinkeby using web3 and truffle/hdwallet-provider.

even with different gas prices it doesn't get mined.Please help out.

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: 1050000000
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!
C:\Users\Ketan Verma\Desktop\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 locat

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 (C:\Users\Ketan Verma\Desktop\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)
  • There's a pending transaction from 2 minutes ago. Is that yours? Previous ones are from 11 days ago BTW, and your question here is from 1 hour ago, so I can't quite see where your transaction has gone to. – goodvibration Mar 9 at 6:31
  • I was ill so didn't work a couple of dats, now tried it again,same result.I've tried everything i could think of – Ketan Verma Mar 9 at 8:14
1

According to this, you have used a gas-price of 0.00000000003 Ether (0.03 Gwei (30,000,000 wei)).

According to your question, you have used in your transaction a gas-price of 1,050,000,000 wei.

Conclusion: you are not telling the truth (though you are probably not doing it intentionally).

| improve this answer | |
  • yes, i didn't know this, but how would i fix it.I'm still new to this so really confused – Ketan Verma Mar 9 at 16:59

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.