By the end of this lesson, you will be able to:
In the previous lessons, we outlined how to write, compile and unit test a smart contract based on 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 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 install
to install node dependencies specified in the package.json
file..env
and 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. Make sure to follow the lesson Compiling Smart Contract to compile the smart contract using Truffle IDE.
truffle-config-bsc.js
as the truffle configuration file..env
file containing the secret phrase of your MetaMask account.truffle migrate --network bscTestnet --config=truffle-config-bsc.js
In order to make sure your smart contract is deployed, BscScan Testnet Explorer can be used. Copy the contract address obtained when the contract was deployed as shown in the figure below.
On the BscScan homepage, paste it in the search bar and press enter.
Upon pressing enter, you can view all of the deployment details of your smart contract.
This tutorial guided you through the basics of creating and deploying a smart contract using the Truffle IDE. We also provided steps on how to verify your smart contract using the BscScan. This tutorial uses testnet, however, the exact same instructions and sequence will work on the mainnet as well.