Binance Chain's BEP3 atomic pegs [Explained]
Binance Chain, like any other decentralized exchange, faces the eternal problem that has been plaguing DEXs for ages:
Exchanges thrive on allowing users to trade a wide variety of tokens/coins, but how can a DEX list tokens from other chains while remaining decentralized?
So far the following solutions to this problem have been implemented:
- Custodian Model: Using wrapped tokens maintained by a custodian
- Atomic Swaps
A new foe has appeared: Introducing BEP3 Atomic Pegs
Overall, these previous solutions are not perfect, as they either require a high level of trust in a centralized entity (Custodian Model) or have many drawbacks (Atomic Swaps).
For these reasons, Binance came up with the BEP3 peg, a new kind of peg for tokens that come from Smart contract enabled chains, such as Ethereum, EOS or NEO.
BEP3 pegs draw inspiration from atomic swaps to construct a mechanism that takes the Custodian Model and strips away the trust required in some parts of the system.
If you’d like to learn more about atomic swaps and how they work check out this article, but no knowledge of them is required to understand the rest of this article.
But enough talking, let’s look at the mechanism itself:
Porting tokens to Binance Chain
BEP3 maintains the figure of a deputy, who is in charge of initially creating a new token inside Binance Chain and deploying a smart contract in the other chain. Afterwards, whenever a user wants to port their tokens over to Binance Chain the following steps are taken:
- The user locks their original tokens inside the smart contract along with a hash of a secret only known to the user, these tokens then remain locked unless the secret is not revealed in under X minutes, in which case they will get sent back to the user.
- The deputy discovers that some tokens have been locked and sends a message to Binance Chain saying “User has locked Y tokens, if his secret is revealed before this deadline hand him the equivalent amount in pegged tokens”.
- The user reveals the secret in Binance Chain and retrieves the pegged tokens.
- Deputy relays the secret to the smart contract and locks the tokens permanently.
Redeeming Pegged Tokens
Once the user wants to redeem their pegged tokens for real ones the process can be reverted, the steps are reproduced here for the sake of completion but if this is trivial for you feel free to skip to the next section or just look at the diagram:
- The user locks some pegged tokens on Binance Chain using a special transaction that allows the deputy to retrieve them if the user’s secret is revealed before a deadline and, if that does not happen, they are sent back to the user.
- Deputy relays this information to the smart contract, which unlocks some tokens temporarily and allows the user to claim these upon revelation of his secret.
- The user reveals his secret and claims the smart contract’s unlocked tokens.
- Deputy relays the secret to Binance Chain and retrieves the user’s tokens.
To learn more about BEP3 check out the original BEP and it’s official documentation page
Subscribe to get your daily round-up of top tech stories!