1

When I am trying to call a Write function of the smart contract deployed on the rinkeby network using truffle, I get error Invalid JSON RPC response: "" .

Can you please help with what is causing this issue and how to resolve it. It is a bit urgent. Thanks.

Content of my truffle.js file is:

const HDWalletProvider = require("truffle-hdwallet-provider-privkey");
const privKey = "my-address's private key from which i want to deploy it"; 

module.exports = {
 networks: {
     development: {
        host: "localhost",
        port: 8545,
        network_id: "*" // Match any network id
     },
     rinkeby: {
         provider: function() {
              return new HDWalletProvider(privKey, "https://rinkeby.infura.io/mytokenid");
         },
         network_id: 4,
         gas: 7003605,
         gasPrice: 21,

    }
  }
};
1
  • 1
    gasPrice looks very low, i'd adjust that. Make sure you copied your private key correctly, and that you have the correct infura link/ api token. Have you tested the setup with Ganache or a local instance yet? Edit: at second glance your infura url looks wrong, make sure it has the version "rinkeby.infura.io/v3/token"
    – blackops
    Commented Sep 17, 2018 at 18:09

2 Answers 2

1

GasPrice is measured in GWeis on interfaces like Metamask, but on Truffle the GasPrice is on Weis so 21 isn't a correct value because is too low.

According with Truffle documentation:

Default is 100000000000

To deploy on testnets, just don't write that field. Truffle will then recognize the medium GasPrice of the Network automatically and it will use that value as the GasPrice for the deployment.

Hope it helps!

0

Aside from the gasPrice being really low, while I was working with infura I find that if there is something wrong with the way you call your function if will return that error. I'm still new to this but there maybe something in your call that infura does not recognize. It maybe helpful if you can post how you call the function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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