Skip to content

Deployment with Infura

In this step we are deploying our token into the Test-Network, either Görli or Ropsten. We do this without setting up our own Blockchain Node. We use a hosted node with Infura.

Because our setup is already so well prepared, it's extremely easy to do so.

Signup with Infura

First thing is to signup with Infura. Go to https://infura.io and signup with your email address.

Signup with Infura
Signup with Infura

Confirm the Mail address and enter the dashboard.

Create a new Infura Project

First you need to create a new Infura Project

Give it a name:

And hit "CREATE".

View the Project:

This is the important ID you will need:

Update the truffle-config.json File

Now let's update the truffle-config.json file so we can deploy using the nodes from Infura. Add a new network:

 networks: {
    development: {
      port: 7545,
      network_id: "*",
      host: "127.0.0.1"
    },
    ganache_local: {
      provider: function() {
        return new HDWalletProvider(process.env.MNEMONIC, "http://127.0.0.1:7545", MetaMaskAccountIndex)
      },
      network_id: 5777
    },
    ropsten_infura: {
      provider: function() {
        return new HDWalletProvider(process.env.MNEMONIC, "https://ropsten.infura.io/v3/YOUR_INFURA_ID", MetaMaskAccountIndex)
      },
      network_id: 3
    },
    goerli_infura: {
      provider: function() {
        return new HDWalletProvider(process.env.MNEMONIC, "https://goerli.infura.io/v3/YOUR_INFURA_ID", MetaMaskAccountIndex)
      },
      network_id: 5
    }
  },
  compilers: {
    solc: {

Where it says "YOUR_INFURA_ID" enter the ID from your own Infura Dashboard please! That's it. Let's run this!

Run the Migrations

The last part is to run the migrations. At the very beginning of the course we got some test-ether in our MetaMask. You should still have them. Just run the Migrations and see if it works:

truffle migrate --network ropsten_infura

and watch the output -- this might take a while:

Migration is Running
Migration is Running
Migration is Finished
Migration is Finished

And then open your Browser Window again and switch MetaMask to the Ropsten (or Görli) network, depending on which one you deployed. You already can see that you have no tokens there, but also the address of the TokenSale contract changed:

Deployed on Ropsten
Deployed on Ropsten
Deployed on Ganache
Deployed on Ganache

You could go ahead and whitelist another account now and get some tokens. You can also implement a spending token facility, for actually burning tokens once the cappuccino is bought. Before we do that, let's change the whole crowdsale!


Last update: April 17, 2021