1

I've been using truffle console to interact with a contract which I developed locally with Ganache. I'd like to be able to call the contract's methods using the console once deployed to the Rinkeby network in the same way that I've been able to do so with Ganache.

I'm aware that I can do this using Remix but I'm wondering if I can do this using the terminal as well. In other words, is there a config option for the console to interact with Rinkeby?

1

You should be able to use truffle console --network rinkeby.

You will need to configure truffle-config.js properly, e.g. using Infura and the hdwallet-provider package:

const HDWalletProvider = require('@truffle/hdwallet-provider');
const infuraURL = 'https://rinkeby.infura.io/v3/YOUR-INFURA-PROJECT-ID';
const fs = require('fs');
const mnemonic = fs.readFileSync('.secret').toString().trim();

module.exports = {
  networks: {
    rinkeby: {
      provider: () => new HDWalletProvider(mnemonic, infuraURL),
      network_id: 4,
      gas: 5500000,        
    },
// additional configuration...
}

Your mnemonic should be stored in .secret and the account will need to have Rinkeby testnet Ether to pay for transaction gas.

| improve this answer | |

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.