Compiling smart contracts
This recipe focuses on compiling smart contracts for a Truffle project. You will also learn about compiling multiple contracts and locating the output to use with your project.
Getting ready
You need to have a working installation of Truffle in your system to try this recipe. Truffle uses solc-js
to compile your smart contracts, and it will be installed along with Truffle. Ensure that you have the latest version of both using the version
command:
truffle version
How to do it...
Smart contracts for a Truffle project are located in the
./contracts
directory. Since solidity is the language of choice for smart contracts, the source code files will have the.sol
extension.
- There may be one or more contract files in a project. Use the
compile
command to compile the smart contracts present in the directory. Make sure that you are at the root of the project:
truffle compile
- If you are running the command for the first time, then it will compile all the contracts present in the folder...