Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 3.38 KB

06.md

File metadata and controls

57 lines (42 loc) · 3.38 KB
title actions requireLogin material
Deploying Our Smart Contract
checkAnswer
hints
true
terminal
help commands
You should probably run `truffle migrate --network rinkeby`.
truffle migrate --network rinkeby
hint output
truffle migrate --network rinkeby
Using network 'rinkeby'. Running migration: 1_initial_migration.js Deploying Migrations... ... 0xfc34bb95778e4bd53b80c6b705e5df6e753b1accecc38cfd35cb02c0e37ee223 Migrations: 0x9aba355cd9e68758c7bd9f1e58f911e0479fd29c Saving successful migration to network... ... 0x485c7e8096d61a8a1e3efa8d9f5c675b707ca7580ecdb46a307b11146351fc9d Saving artifacts... Running migration: 2_crypto_zombies.js Deploying CryptoZombies... ... 0xeed64afd64669674d0bc5a68e8c1f86a620d4bd338a652fc42f54353a252d07c CryptoZombies: 0xccdfdc3d7e002965843d52e610370e8d29d5737f Saving successful migration to network... ... 0xdcb1e77f4c1b3982bb15b10bec69bdafbc88fd4ea0b868971e850b02875de68e Saving artifacts...

Great! That was the difficult part — actually deploying to Rinkeby is going to be straightforward. To do this, Truffle relies on something called a migration.

Migrations

It sounds like a migration involves a lot of stuff moving around, but in practice, a migration is nothing more than a JavaScript file that tells Truffle how to modify the state of our smart contracts.

Obviously, the first migration will just deploy the smart contract. Some other migrations deploy a new version of the code to add features or fix bugs.

In a nutshell, migrations provide a convenient way to keep track of the changes you make to your code.

If you want to deploy more than one contract, a separate migration file must be created for each contract. Migrations are always executed in order- 1,2,3, etc.

In this lesson, we will deploy only to Rinkeby. Deployment to the main net would require real money to pay for the gas and, once deployed, we won't be able to modify the code. Hence, it's best to deploy to Rinkeby first, and thoroughly test the code.

Get some Ether

Before doing the deployment, make sure there is enough Ether in your account. The easiest way to get Ether for testing purposes is through a service known as a faucet. We recommend the Authenticated Faucet running on Rinkeby. Follow the instructions, and within a few minutes, your address will be credited with some Ether.

Put it to the test

  1. Now that everything is set up, it's time to deploy to Rinkeby. To do so, run truffle migrate --network rinkeby in the terminal to the right. Note how migrations are being executed in order😉.

Note: truffle deploy is just an alias for truffle migrate. However, since our command-line interpreter is pretty basic, it won't consider the answer correct unless you're using migrate.

Deployment to the main net is not complicated at all. Once the smart contract is tested, you'll only have to run: truffle migrate --network mainnet. Don't forget that you'll have to pay for gas! We trust you'll be able to do it.

If everything goes well, you're going to see a response that's similar to the one to the right.