Creating an ETH-BSC bridge

Creating an ETH-BSC bridge

Bitcoin, the first cryptocurrency and the first widely popular blockchain, appeared in 2008. As this technology became popular, other networks gradually were introduced to the market: Litecoin, Ethereum, Bytecoin, Dash and others.

Each of these protocols offered something new: 

  • the hard fork of the first cryptocurrency, Bitcoin Cash, implemented an increase in the block size, allowing it to accommodate more transactions; 
  • Dash implemented a two-tier blockchain running on PoW and PoS, introduced masternodes and the original InstantSend and PrivateSend features; 
  • Ethereum was the first to introduce autonomous smart contracts, allowing simple operations between two parties without the involvement of intermediaries.

Thanks to Ethereum, developers were able to create new tokens and even blockchain applications on the main network (DApps) using their own smart contracts. This laid the foundation for DeFi, and blockchains themselves became full-fledged decentralized platforms offering autonomous financial services using smart contracts: cryptocurrency-backed lending, trading (atomic swaps), issuing synthetic assets backed by cryptocurrencies, and more.

However, all of these ecosystems had one key drawback: they were closed, which resulted in the fragmentation of the crypto market. In other words, you could not use BTC on the Ethereum network, but you could use ETH on the BNB Chain (formerly Binance Smart Chain) and vice versa.

In the 13 years of its existence, the blockchain industry has changed and evolved into a whole ecosystem consisting of numerous financial applications (DApps): decentralized exchanges, marketplaces, launchpads, oracles, lending protocols, and finally,,, blockchain bridges. 

In this article, we will analyze what blockchain bridges are, what they are, what role they play in DeFi and how to create them.

What are blockchain bridges, and why are they needed?

Put simply, a blockchain bridge is a special application that allows users to transfer cryptocurrencies from one blockchain to another. 

Previously, you could not use Bitcoin or Ethereum outside of your own blockchain. But with the advent of blockchain bridges, everything has changed. Now BTC, ETH, BNB, USDT and other coins can be used as tokens backed by these coins in other networks like Ethereum and BNB Chain (ex-BSC). 

Without blockchain bridges, users were dependent on a centralized intermediary: a crypto exchange or other financial institution providing custody services for digital assets. But at the same time, cryptocurrency owners delegated their private keys to companies and were forced to trust them, and these companies charged additional fees for transactions. The main value of blockchain bridges is that users can transfer cryptocurrencies from one network to another without giving up their ownership.

How do they work, what are blockchain bridges used for, and what problems do they solve for users and developers?

Their only function is to transfer a digital asset from one blockchain to a similar token on another network, with the main asset serving as a reserve. This means that tokens don’t disappear or reappear anywhere.

Suppose you transfer ETH from the Ethereum network to the BNB chain. Then to create 1 BEP-20 Wrapped Ethereum (WETH) token, you lock 1 original ETH (ERC-20) in a smart contract. 

At that moment, 1 new token is generated. This is a non-original ETH, but it’s just a token of another network secured by ETH and bound to its price. Meanwhile, you have to pay a commission for the transactions both on the Ethereum network and on the BNB chain (calling the smart contract function to lock coins in the first case and issue tokens in the second). Your coins are securely locked by a smart contract at their address until you reclaim them.

To get the original ETH back, you have to burn the wrapped tokens, whereupon the ERC-20 coins are unlocked by the smart contract and returned to the wallet. At the same time, you pay a commission twice on both networks because the transaction uses two smart contracts on Ethereum and on the BNB Chain.

We have figured out the working principles of blockchain bridges. But what are these blockchain bridges for?

Savings on commissions

The Ethereum network became known for the most expensive commissions due to its high transaction activity and low throughput (only 7 transactions per second). Those commissions are more expensive than Bitcoin’s. This does not even take into account that when working with smart contracts, users perform «complex transactions» whose cost sometimes exceeds $150 or even $300 due to gas fees.

For holders who own dozens of ETH and rarely transact, this is not critical. But what about users who regularly conduct small transactions, such as trading on DEXes or yield farming? BNB Chain and Tron are popular with such users because commissions on their networks are often less than $1. BNB Chain’s throughput reaches 65 transactions per second and Tron’s 1,000.

Access to DeFi

Decentralized finance, or DeFi, is an ecosystem of blockchain platforms whose existence was made possible by smart contracts. For a long time, Bitcoin was perceived to belong outside DeFi because it is not a platform and, unlike Ethereum, BNB Chain, Tron, Solana, Cosmos and other smart contract networks, Bitcoin is not characterized by Turing completeness.

In other words, Bitcoin holders can transfer coins only to other Bitcoin users. Thanks to cross-chain bridges, Bitcoin holders now have access to DeFi and Yield Farming. All they need to do is transfer BTC to the Ethereum or BNB chain network, and they can exchange coins for other crypto assets, add them to liquidity pools with ETH, BNB or USDT or put them up as collateral for a crypto loan.

Cross-chain transactions and cost reduction

Imagine you own ETH coins and want to buy or borrow BNB. Then you would first have to transfer ETH from one network to another and then switch to BNB. But in reality, all of this can be completed in a single transaction. Cross-chain bridges enable using cross-chain collateral and cross-chain swaps, which avoids unnecessary transaction costs. However, this option is more complicated, as liquidity pools must be used to meet user demand.

Blockchains themselves cannot exchange data. This function is performed by price oracles and cross-chain bridges. Thanks to them, the transfer of assets and data to another network becomes possible.

What are blockchain bridges?

There are two main types of blockchain bridges:

  • Centralized (federated): in this case, a company or group of people fully controls the operation of a smart contract and also provides a liquidity pool from its own funds. This method requires trust, as the owners can block access to the pool or withdraw all funds from it at any time.
  • Decentralized (trustless): with such cross-chain bridges, anyone is able to become a liquidity provider. All transactions are carried out using a smart contract. It automatically freezes cryptocurrency in one network and generates a corresponding number of similar tokens in another. However, not all supposedly decentralized bridges are really decentralized. Check the source code carefully for backdoors and features that allow sole access to liquidity pool assets.

How to create a blockchain bridge?

All smart contracts and decentralized applications (DApps) based on the Ethereum and BNB blockchains are created using the Solidity programming language. Therefore, you need to learn this language if you want to develop your own DApps, including bridges between BNB Chain and Ethereum. If you want to build a bridge but are not familiar with the Solidity language, the BC team, which has been developing blockchain solutions for over 5 years and provides other services, including consulting and smart contract security audits, will help you.

Choosing a Development Environment (IDE) and Creating a Blockchain Bridge Code

Popular editors for coding on Solidity are Remix IDE and ChainIDE. Both editors work with either Ethereum or BNB Chain. Therefore, they are perfect for creating an ETH <> BNB bridge. The sources for blockchain bridges’ infrastructure can be found online or directly on GitHub. If you don’t find a suitable code and create it yourself, order it from BC team.

Deploying Bridge Components on Ethereum and BNB Chain Networks

Unlike other decentralized applications, a blockchain bridge requires a contract to be used on each network. In our case, these are Ethereum and BNB Chain. Each smart contract is given a unique address, but this can be the same on all networks because Ethereum and BNB Chain use the same address format, which starts with 0x.

Creation and Burning of Custom Tokens 

In a blockchain bridge, one token is used to secure another. To do this, you must first mint the token on an alternative network (BNB chain) and then burn it. The tokens are generated when a smart contract locks a reserve asset on the Ethereum network. After that, you need to program the token migration mechanism.

Create a basic token smart contract

This also needs to be done for both networks, and then you need to add the token migration function.

Deploying the ETH <> BNB bridge

You also need to program the API and add private key and token balance functions for the blockchain bridge. All that remains is to test the operation of the bridge on the test network, and if everything is successful, the bridge can be deployed on the main Ethereum and BNB Chain networks.