# How to use Binance Smart Chain in your Dapp

Author: Markus Waas

Published: 2021-06-12T22:33:06.000Z

Updated: 2026-09-13T14:25:30.000Z

Source: [https://soliditydeveloper.com/deploy-to-binance-smart-chain](<https://soliditydeveloper.com/deploy-to-binance-smart-chain>)

## Compatibility and review

Before you start

Historical 2021 Binance Smart Chain tutorial. The network is now called BNB Smart Chain; it is a separate Layer 1 using Proof of Staked Authority. Beacon Chain’s older role ended with its sunset. Network example syntax and wallet requests have been corrected, but the Truffle deployment has not been rerun.

[Official reference](<https://docs.bnbchain.org/bnb-smart-chain/introduction/>)

Defi has been a major contributor to the Binance Smart Chain taking off recently. Along with increasing gas costs on Ethereum mainnet which are actually at one of the lowest levels since a long time at the time of this writing, but will likely pump again at the next ETH price pump.

So how does one deploy to it and what actually is the BSC?

## What is the Binance Smart Chain?

**Historical context:** The name and dual-chain architecture below describe the 2021 ecosystem. BSC is now called BNB Smart Chain, a separate Layer 1. Beacon Chain subsequently reached its [final sunset](<https://docs.bnbchain.org/announce/final-sunset-bc-mainnet/>); its old staking and bridge role is not the current architecture.

Binance Chain launched in April 2019. It's a tendermint-based chain with its main functionality to transfer assets. This allowed for a more decentralized form of value transfer within the Binance ecosystem.

In September 2020 they added the Binance Smart Chain (BSC) to it. This is its own separate chain, but is part of a dual chain design which synchronizes state with the original Binance Chain. The BSC itself is simply a geth fork, so it relies on the same technology as ETH 1.0. But the gas costs are much lower due to a higher output achieved by a very limited amount of validators.

## Is BSC decentralized?

BNB Smart Chain uses **Proof of Staked Authority (PoSA)**: stake-based validator selection combined with authority-based block production. The original article’s fixed set of 21 validators and Beacon Chain staking description reflect the earlier network design. See the current [BSC consensus overview](<https://docs.bnbchain.org/bnb-smart-chain/introduction/>) for the validator model and [Beacon Chain sunset notice](<https://docs.bnbchain.org/announce/final-sunset-bc-mainnet/>) for the architecture change.

## How to deploy to Binance Smart Chain

Deploying to the Binance Smart Chain is [very simple](<https://docs.matic.network/docs/develop/truffle/>). If you're using Truffle, simply add the Binance Smart Chain network configuration like this:

```javascript
// Legacy Truffle configuration. HDWalletProvider and mnemonic are defined by the surrounding project.
module.exports = {
  networks: {
    bsc: {
      provider: () => new HDWalletProvider(mnemonic, "https://bsc-dataseed.bnbchain.org"),
      network_id: 56,
    },
    bsc_testnet: {
      provider: () => new HDWalletProvider(mnemonic, "https://bsc-testnet-dataseed.bnbchain.org"),
      network_id: 97,
    },
  },
};
```

You'll also need funds in the chain of course. For the testnet you can use the faucet [here](<https://testnet.binance.org/faucet-smart>). For how to transfer funds from the public chain, read on.

## How to onboard users to your Binance Smart Chain Dapp

### 1. Choice of wallet

These days you have much more than just MetaMask as possible wallets to support available. Take a look at [Yearn Finance](<https://yearn.finance/>) for example. They are supporting 11 different wallets alone at the time of this writing.

- [MetaMask](<https://metamask.io/>)
- [WalletConnect](<https://walletconnect.org/>)
- [Trezor](<https://trezor.io/>)
- [Ledger](<https://www.ledger.com/>)
- [Lattice](<https://lattice.exchange/>)
- [Coinbase Wallet](<https://wallet.coinbase.com/>)
- [Portis](<https://www.portis.io/>)
- [Fortmatic](<https://fortmatic.com/>)
- [Torus](<https://toruswallet.io/>)
- [Authereum](<https://authereum.com/>)
- [Opera](<https://www.opera.com/crypto>)

![Wallet Options](<https://cdn0.scrvt.com/b095ee27d37b3d7b6b150adba9ac6ec8/ac0842258dbc25f6/d3314fc5d569/v/cf1b58ac0a47/wallet-options.png>)

![MetaMask confirmation to add Binance Smart Chain, showing chain ID 56 and a warning to verify the network details.](<https://cdn0.scrvt.com/b095ee27d37b3d7b6b150adba9ac6ec8/bc962073c270ce69/20757e7244f4/v/94590f892bf0/bsc-metamask.png>)

### 2. MetaMask example live in action

We'll focus on MetaMask as the biggest wallet with the most features. With MetaMask you can nowadays actually request to connect directly to a custom network.

If you want to see this live, check out [Pancake Swap](<https://pancakeswap.finance/>) as example. Unless you already have Binance Smart Chain added, it will request to add this network. Or simply click 'Add network' in the Binance [bridge](<https://www.binance.org/en/bridge>).

### 3. How to add BSC automatically for users

`wallet_addEthereumChain` requests that the wallet add a network. The user can decline, and success does not guarantee that the network becomes active. If switching is needed, request `wallet_switchEthereumChain` separately and handle rejection. Check the wallet’s actual chain before enabling network-specific actions.

```javascript
// BNB Smart Chain: chain ID 56 (decimal).
// Testnet: chain ID 97 (0x61); use the matching testnet RPC, currency and explorer from the official docs.
const params = [
  {
    "chainId": "0x38",
    "chainName": "BNB Smart Chain",
    "rpcUrls": [
      "https://bsc-dataseed.bnbchain.org"
    ],
    "nativeCurrency": {
      "name": "BNB",
      "symbol": "BNB",
      "decimals": 18
    },
    "blockExplorerUrls": [
      "https://bscscan.com"
    ]
  }
];

try {
  await ethereum.request({ method: "wallet_addEthereumChain", params });
  // Adding a network does not guarantee that it is selected.
  await ethereum.request({
    method: "wallet_switchEthereumChain",
    params: [{ chainId: params[0].chainId }],
  });
} catch (error) {
  // The wallet may reject either request; keep the UI on its actual chain.
  console.error("Network request was not completed", error);
}
```

![Binance Bridge](<https://cdn0.scrvt.com/b095ee27d37b3d7b6b150adba9ac6ec8/1c0bb66d3d82d57f/97c67e0becc1/v/e93f04dd231d/binance-bridge.png>)

## Using the Binance Bridge

The bridge UI and dual-chain assumptions described in the original article belong to the earlier Binance ecosystem. Beacon Chain has since been sunset. Consult the [official sunset and migration information](<https://docs.bnbchain.org/announce/final-sunset-bc-mainnet/>) before following an old bridge link. The bridge’s trust model must be assessed for the specific current bridge; it cannot be inferred from BSC’s validator consensus.

## Defi on Binance Smart Chain

One of the advantages of BSC may be its vast ecosystem, in particular Defi projects. Just take a look at the following image provided by [BNB Swap](<https://twitter.com/BNBSwap>):

![BSC Defi](<https://cdn0.scrvt.com/b095ee27d37b3d7b6b150adba9ac6ec8/890a0792be0fe84f/4ca39068c83b/v/f1b118d080d4/defi-bsc.jpeg>)

For an overview of more than just Defi, check out the Github of the ecosystem [here](<https://github.com/binance-chain/bsc-ecosystem>). What are the most popular projects?

- [PancakeSwap](<https://pancakeswap.finance/>): The Uniswap v2 fork for BSC. Similar to SushiSwap, the fork has added a few extra features, namely staking, a lottery and NFT support, see the guide [here](<https://academy.binance.com/en/articles/a-guide-to-pancakeswap>) and if you are not aware of AMMs, you might want to check out my guides of Uniswap [v2](<https://soliditydeveloper.com/uniswap2>), [v3](<https://soliditydeveloper.com/uniswap3>) and [SushiSwap](<https://soliditydeveloper.com/sushi-swap>).
- [Venus](<https://app.venus.io/>): The MakerDao and Compound fork of BSC is a money market where you can borrow and lend BEP-20 (ERC-20 on BSC) tokens.
- [Autofarm](<https://autofarm.network/>): This is essentially the Yearn Finance for BSC. You can participate in a vault and it automatically tries to find the most optimal way for you to earn a yield on your deposits.
- [BurgerSwap](<https://burgerswap.org/>): BurgerSwap is also a popular AMM on BSC. You can do BEP-20 token swaps and provide liquidity. It implemented [ERC-2917](<https://eips.ethereum.org/EIPS/eip-2917>) and it for once is not a fork of Uniswap. They wanted to improve upon the incentive and governance model of Uniswap.
- [Spartan Protocol](<https://spartanprotocol.org/>): This is a combination of a liquidity pools based on AMMs, synthetics assets (tokenized derivatives) and a lending protocol.
- [Cream](<https://app.cream.finance/>): Cream is another popular lending protocol which exists on Ethereum and that is also deployed on BSC.
