Deploying to Ropsten with Truffle Updated
Deploying to Ropsten with Truffle Updated#
The cool thing about Truffle is that we can use the same scripts that we created when we deployed to a local blockchain with Truffle as when we are deploying to the Ropsten test network. The major difference will be how we call the Truffle scripts.
Another script that is available through Truffle is called
truffle migrate. This combines the
truffle compile and
truffle deploy script into one.
Recall that to send the contracts to a local blockchain we had to have a local blockchain running and then you can run
truffle migrate. This would compile the contracts and send them to the
ganache-cli instance that we had running.
This time, to deploy our contracts to the Ropsten test network, we will have to add a flag to the Truffle scripts. This will allow us to use the
ropsten configuration that we just added. Instead of running just
truffle migrate, we will be running
truffle migrate --network ropsten. The
--network flag allows us to select the
ropsten object we just added.
Let's try it out! Run
truffle migrate --network ropsten. After running the script we'll see our contracts compile. After they compile (they may not compile because we didn't change anything in the contracts since the beginning of this chapter) the migrations will start.