Deploying Smart Contracts
Explore how to deploy smart contracts with the Truffle framework. Understand migration steps, writing deployment scripts in JavaScript, and how Truffle tracks executed migrations to manage deployments effectively.
Now that we know how to install Truffle and create a Truffle project, we'll look into smart contract deployment, one of the most powerful Truffle features. In a previous chapter, we deployed a smart contract to test the Ethereum network using the web3.js library. While that worked, it was cumbersome and required writing a lot of boilerplate code.
In this lesson, we'll see how to deploy smart contracts with Truffle and how a deployment process is organized. In the next lesson, we'll deploy the Auction smart contract using Truffle.
Migration steps
This process of smart contract deployment in Truffle draws inspiration from the migrations in the database world. Every Truffle project defines a smart contract deployment as a series of migration steps. Every migration step is a JavaScript file located in the migrations directory of the project.
├── contracts│ ...├── migrations│ ├── 1_initial_migration.js│ └── 2_deploy_contracts.js├── test│ ...└── truffle-config.js
Each migration step should start with a number prefix and contain an arbitrary ...