Deploy a contract to the Binance Smart Chain

Deploy a contract to the Binance Smart Chain. The Binance Smart Chain (BSC) is a block chain that supports smart contracts and staking for the native BNB token. This chain runs in parallel with the Binance chain (yes, Binance has two chains in their architecture). For more information about BSC read their documentation.

The most interesting aspect of the BSC is that it is compatible with the Ethereum Virtual Machine. You can take an Ethereum smart contract and deploy it on the BSC. You can use Remix for development, MetaMask for your wallet, and their block explorer looks like a copy of Etherscan.

This sounded interesting so I tried it and was up and running in minutes.

Configure MetaMask for the BSC Test Network

Open MetaMask and select:

  • Settings
  • Network

Configure MetaMask to Deploy a contract to the BSC

Select Add Network

Configure MetaMask to Deploy a contract to the BSC

Add the Binance Smart Chain test configuration. Save this test configuration in notepad so the MetaMask screen does not close.

Configure MetaMask to Deploy a contract to the Binance Smart Chain

BSC Faucet for Test Tokens

Now go to the Binance test faucet and request test Peggy tokens. The tokens are sent to your wallet within minutes. Test LINK tokens are available from the community faucet.

Deploy a contract to the Binance Smart Chain Faucet

Deploy Smart Contract to BSC

Now that you are connected to the network, your wallet is setup, and you have BNB test tokens try deploying a simple contract.

You can use Remix to write Solidity contracts and deploy them to the Binance Smart Chain network. To test this you can copy the Solidity smart contract code below and give it a try.

//define which compiler to use
pragma solidity ^0.5.0;

//contract name is MyFirstBSContract
contract MyFirstBSContract {


    string private name;
    uint private amount;

//set
    function setName(string memory newName) public {
        name = newName;
    }

//get

    function getName () public view returns (string memory) {
        return name;
    }
    
//set
    function setAmount(uint newAmount) public {
        amount = newAmount;
        
    }

//get
    function getAmount() public view returns (uint) {
        return amount;
    }
    

}

Then submit your transaction to the network in Remix. MetaMask will display Smart Chain – Testnet in the upper right corner.

Deploy a contract to the Binance Smart Chain MetaMask

My transaction confirmed on the BSC network

Deploy a contract to the Binance Smart Chain BSC SCAN

https://bscscan.com/

I verified my contract on BSCScan and it worked.

Deploy a contract to the Binance Smart Chain BSC SCAN

In all I was surprised how simple it was to use the Binance Smart Chain. It appears to be a centralized clone of Ethereum but there could be more to it.

BSC test net addresses for Pancake Swap

If you would like to test with Pancake Swap on the test net you can interact directly with their factory and router addresses.

  • Factory: 0x6725F303b657a9451d8BA641348b6761A6CC7a17
  • Router: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1

Configure MetaMask for the BSC Mainnet network

The BSC Mainnet can be configured using the settings below. Copy and past the information below in a text editor.

  • It will make it easier to put this into MetaMask and will prevent the screen from closing on you.
  • Type the below information into MetaMask by adding a new custom RPC. Follow the instructions above for the test network and use the setting below for the Mainnet.
  1. Network Name: Smart Chain
  2. New RPC URL: https://bsc-dataseed.binance.org/
  3. ChainID: 56
  4. Symbol: BNB
  5. Block Explorer URL: https://bscscan.com

Transfer Funds from Ethereum to BSC on the Mainnet

If you have tokens on Ethereum and you want to transfer them to BSC you can use the Binance Bridge. This bridge is a two way transaction channel and you can read more about it here. To use the bridge visit https://www.binance.org/en/bridge. It takes approximately 12-15 mins for funds to transfer.

Other Blockchains to Build and Test on

Chick here for Ethereum help and additional information.

Next Review – How to deploy a Solidity smart contract to the Polygon Network