0

I have set a secret for my project in infura.

Here is my truffle-config.js file:

module.exports = {
  networks: {
    ...
    ropsten: {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/xxxxx"),
      network_id: 3
    }
  }
};

My question is: Where can i put secret in this configuration file. I have read a lot of documentation/turorials and there is nothing about this secret.

Thanks a lot

0

You should be able to use something like a .env file to secure your project secret and keep it from being seen. Alternatively, you could take an approach similar to what this user did for their

0

Make a .env file in the same folder:

MNEMONIC="Your MNEMONICs"
INFURA_URL="Your Infura URL with API key"

Then replace the truffle-config.js code with this:

const HDWallet = require('@truffle/hdwallet-provider');
const dotenv = require('dotenv');
dotenv.config();
const mnemonic = process.env.MNEMONIC;

module.exports = {
  networks: {
    kovan: {
       provider: () => new HDWallet(mnemonic, process.env.INFURA_URL),
       network_id: process.env.NETWORK_ID,       
       gas: 5500000,        
       confirmations: 0,    
       timeoutBlocks: 200,  
       skipDryRun: true     
     },
  },
3
  • Thanks that is exactly what i have done in my real project. I have removed env var stuff for my question. but there is no infura secret in your answer... – Bob5421 Apr 15 at 6:11
  • Go to infura.io, after that you can signup and get the secret. – Dharmveersinh Jadeja Apr 15 at 6:20
  • I have the secret ! What i want to do is to know how i can set this secret in truffle-config.js – Bob5421 Apr 15 at 8:54

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.