By the end of this lesson, you will be able to:
In the previous lesson, we outlined how to write a smart contract using the Solidity programming language for use on the BNB Smart Chain network. Remember that, BNB Smart Chain is the component of the BNB Chain ecosystem that is equipped with the smart contract programmability and hence any smart contract or dapps are in essence deployed on the BNB Smart Chain. In this lesson, we will outline the steps to compile and deploy the written smart contract using the Truffle IDE on the BNB Smart Chain Testnet.
Truffle is one of the most popular development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM).
This is a hands-on guide and readers are encourged to perform these tasks along for a better understanding. Before starting off with the practical demo, it is necessary to make sure you have the following software requisites installed.
npm installto install node dependencies specified in the
.envand paste the following into it. To get the Secret Pharse from MetaMask wallet you can go to Metamask Settings, then from the menu choose Security and Privacy where you will see a button that says Reveal Secret Recovery Phrase, refer here for more details.
MNEMONIC = SECRET PHRASE OF YOUR METAMASK ACCOUNT
Make sure to follow the lesson Write Your First Smart Contract, for writing the
HelloWorld smart contract using the Truffle IDE.
After we have written a smart contract, its time to compile it to make sure that its error free. In order to compile your smart contract using Truffle, navigate to the root directory of your project, and run the command
truffle compile --config=truffle-config-bsc.js.
--all tag is used to compile all of the smart contracts present in the contracts directory. This is an optional parameter and can be omitted.
This tutorial guided you through the basics of compiling a smart contract using the Truffle IDE. This tutorial uses testnet, however, the exact same instructions and sequence will work on the mainnet as well.