2

I am currently testing using this GitHub repo : https://github.com/oed/bonding-curves

truffle.js looks like this below:

const HDWalletProvider = require("truffle-hdwallet-provider");
const TestRPC = require("ganache-cli");

let provider

function getNmemonic() {
  try{
    return require('fs').readFileSync("./seed", "utf8").trim();
  } catch(err){
    return "";
  }
}

function getProvider(rpcUrl) {
  if (!provider) {
    provider = new HDWalletProvider(getNmemonic(), rpcUrl)
  }
  return provider
}


module.exports = {
  networks: {
    development: {
      get provider() {
        if (!provider) {
          provider = TestRPC.provider({total_accounts: 25})
        }
        return provider
      },
      network_id: "*"
    },
    local: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      get provider() {
        return getProvider("https://ropsten.infura.io/")
      },
      gas: 4004580,
      network_id: 3
    },
    rinkeby: {
      get provider() {
        return getProvider("https://rinkeby.infura.io/")
      },
      network_id: 4
    },
    infuranet: {
      get provider() {
        return getProvider("https://infuranet.infura.io/")
      },
      network_id: "*"
    },
    kovan: {
      get provider() {
        return getProvider("https://kovan.infura.io/")
      },
      gas: 4004580,
      network_id: 42
    },
    mainnet: {
      get provider() {
        return getProvider("https://mainnet.infura.io/")
      },
      gas: 1704580,
      gasPrice: 1000000000,
      network_id: 1
    }
  }
};

But seems like I could deploy the contracts without any infura's API_KEY but I don't know why.

Usually what I've done with my past experiences, I thought I need to add API_KEY after the infura url such as :

https://ropsten.infura.io/API_KEY

But after adding the deploy script and npm run deploy-ropsten command, looks like migration success.

Can anyone help me why?

user76333
  • 153
  • 1
  • 13

1 Answers1

4

You'd have to ask Infura to get a definitive answer, but as far as I know, an API key has been optional for quite some time. (Using an API key probably helps you to avoid rate limiting.)

user94559
  • 59,196
  • 6
  • 103
  • 103