The Solidity programming language is mostly connected to the Ethereum network. However, smart contracts written in Solidity can be easily deployed to any EVM-compatible blockchain like the Binance Smart Chain (BSC), Avalanche, Polygon, and more. In case you are developing for the Ethereum blockchain, you can choose between different Ethereum Testnets like Sepolia, Ropsten, Rinkeby, Goerli and Kovan.
Why deploy to Binance Smart Chain?
On of the main aspects of deploying a contract to the Binance Smart Chain instead of the Ethereum blockchain is cost. With soaring gas prices in the Ethereum network also the price of deploying a smart contract increases. It can get very pricey to deploy to Ethereum ...
Just deployed new ERC720 smart-contract on ethereum. Cost $436.
Meanwhile, contracts on the Binance Smart Chain can be deployed for cents. In fact, the test contract we have deployed for this tutorial cost 0.00199337 BNB to deploy. At the current rate that's around $0.45. The Binance Smart Chain is ideal for smaller transaction sizes and provides fast execution of transactions
How to deploy a contract
To deploy a contract to the Binance Smart Chain we have to follow three simple steps:
If your MetaMask is already set up for the Binance Smart Chain (BSC) and has some funds (BNB), deploy the contract directly to the Smart Chain.
- Configure MetaMask for Binance Smart Chain
- Use Faucet to get funds
- Deploy contract to BSC
MetaMask for Binance Smart Chain
MetaMask is mainly an Ethereum Wallet. It is not prepared for the Binance Smart Chain.
We can configure MetaMask for BSC by pointing it towards Binance Smart Chain nodes. To do so we have to click on the account icon and then on settings.
In the Settings menu, we click on Networks to select the network settings.
There we can see all the configured networks in MetaMask, to add the Binance Smart Chain we click the blue Add Network button.
Network Settings for BSC
Now we have to enter the configurations for the Binance Smart Chain mainnet and testnet. It makes sense to set up both networks. The testnet is for testing purposes and to learn. Later we can use the mainnet to deploy real contracts for real-world use cases.
Network Settings for Binance Smart Chain (BSC):
||Binance Smart Chain Mainnet
||Binance Smart Chain Testnet
|New RPC URL
|Block Explorer URL
Faucet: Get free BNB on testnet
The next step is to get some funds from a faucet. We need BNB the native token of the Binance Smart Chain to pay for the deployment of our smart contract. For the mainnet it is necessary to buy BNB but for the testnet, we can get free test BNB to play around with. To get the free BNB go to the Binance Smart Chain Faucet
Copy the testnet address from MetaMask to the faucet website and then click Give me BNB. It will take a moment until the funds arrive in our MetaMask wallet but once they arrive we are 0.2 BNB richer ... unfortunately it is just play money.
Deploy contract to BSC
Finally, it's time to deploy our contract. In this tutorial, we will deploy to the BSC testnet but deployment to the mainnet works in a similar way.
In remix we select Injected Web3 under Environment. This will open MetaMask and we have to confirm that we want to connect remix with MetaMask. Please make sure that the correct account is selected in MetaMask, in our case the smart chain testnet account.
After we have connected MetaMask, we can click Deploy in remix. It will then take a moment until we have to confirm the deployment in MetaMask. We will also see the estimated gas fees for deploying the smart contract to the Binance Smart Chain. Fortunately, we have accquired some BNB test funds from the faucet
which we can now use to deploy our contract. All we have to do is click the blue Confirm button and wait for a moment.
After our contract is deployed we can use it as we are used in our local test environment. For the tutorial we have deployed the hello world contract
so all we can do is show hello world. But there are many much more interesting use cases for smart contracts on the Binance Smart Chain.