Introducing the Inter-Blockchain Communication Protocol

An overview of how the IBC allows token transfers between Cosmos blockchains.

In a recent [Bankless interview]([^1], David Hoffman asked “What are the tools that listeners need to explore the Cosmos?” to which Sunny Aggarwal responded “Get a Keplr wallet... buy ATOM, IBC it to Osmosis, do a swap for STARS, IBC that to Stargaze, and go buy yourself your first Bad Kids NFT”. [^1]: Bankless – Episode 140 – The Cosmos Thesis with Sunny Agarwal and Zaki Manian, There’s a lot to digest in those words. If you’re very new to the Cosmos, you might find it useful to read through our introductory Cosmos article [here](, but this sequence of events will allow us to unpack a lot of elegant details about how the **Inter-Blockchain Communication** (IBC) protocol works. Allow me to briefly summarize some important concepts: # Setup ## Keplr [Keplr]([^2] is the most popular wallet for accessing the Cosmos ecosystem & managing assets. With it installed, you can easily send and receive Cosmos assets and use Cosmos apps. [^2]: Keplr wallet official website: ## Osmosis Osmosis is an app built on a dedicated Cosmos blockchain (or *appchain*). The app that it runs is a *decentralized exchange* (DEX), which means that you can trade one asset for another there with no 3rd party involved. Remember, the core job of a blockchain is to keep track of which addresses own what assets, and most blockchains have a single *native* asset that is central to its own microeconomy. The native asset of the Cosmos Hub is the ATOM token, and the native asset of Osmosis is the OSMO token. ## Stargaze Stargaze is also an appchain. It keeps track of its native asset, the STARS token, but it is also a marketplace for NFTs or *non-funglible tokens*. This means that users can buy, sell, and create NFTs here. It also means that the Stargaze blockchain has to keep track of which addresses own which NFTs. Since both Osmosis and Stargaze have IBC enabled, they can transfer tokens and other data between them. At the time of writing, STARS cannot easily be purchased outside of Osmosis, which is why Sunny’s answer feels a bit complicated. Finally, Bad Kids is a collection of NFTs that was created on Stargaze and they can only be bought and sold there using STARS. ## Breakdown Now that we have the basics cleared up, I would like to take Sunny’s canonical Cosmos experience from the interview and use it as a baseline to explain the movement of assets between Cosmos chains through IBC. The full sequence looks like: 1. Depositing ATOM onto the Osmosis blockchain 1. Trade ATOM for STARS on the Osmosis exchange 1. Withdraw STARS to the Stargaze blockchain 1. Purchase an NFT (maybe a Bad Kid…) with the newly acquired STARS In this article I will focus only on Steps (1) and (3), since these are the only steps that require IBC. Let’s start at the beginning… Congratulations! You’ve purchased some ATOM on your favourite exchange, withdrawn it to your Keplr wallet, and you’re excited to get some STARS and purchase your first Stargaze NFT. # Deposit $ATOM in Osmosis Your heart is pumping. You navigate to the Assets page on Osmosis, search for ATOM, and click deposit. A beautiful popup shows that ATOM will travel from your Cosmos Hub address at lightning speeds and land gently and safely in your Osmosis address. But how? ![osmosis deposit screen]( ## Good Actors and IBC Packets In order for this to be possible at all, Osmosis and the Cosmos Hub must form (a) a *connection* and (b) a *channel*. Both of these are made possible by a *relayer* – this is a separate computer (ie. not a validator on either chain) who sends information packets back and forth between the two chains. In this article, we will skip over the details of how two chains can form connections and channels, but for a deeper dive you can read [this article]([^3]. The most important thing is to keep track of the players involved: 1. A validator on the Cosmos Hub 1. A validator on Osmosis 1. A relayer to send data between the two You click 'Send'. First, your transaction gets broadcast to the Cosmos Hub validators, one of whom will make sure that your transaction obeys the basic rules of the protocol and subsequently add it to the blockchain. Your ATOM will then be sent to and locked in a special address called an *escrow address*. This address contains all of the ATOM that will travel through the channel to the relayer and end up on Osmosis. Each escrow address has a unique endpoint – in this case, Osmosis – and once your ATOM arrives there, an *IBC packet* will get created. This packet contains information about how much $ATOM you are sending to Osmosis. A beautiful dance unfolds. The packet is forwarded to the relayer who bounces it to the corresponding escrow address on Osmosis. Here, *voucher tokens* are created. Voucher tokens are the digital representation of ATOM on the Osmosis blockchain and the number of voucher tokens created will match the amount of ATOM specified in the IBC packet. The Osmosis blockchain then sends a confirmation that the voucher tokens have been created back to the Cosmos Hub (via the relayer!) and the original packet is destroyed. The ATOM voucher tokens can now move freely between addresses on the Osmosis blockchain, be traded, or anything else allowed by the Osmosis protocol. Magic! ![cosmos hub -> osmosis IBC]( ## Bad Actors and Light Clients “But wait a moment!”, a particularly astute reader may wonder. “What if the validator on the Cosmos Hub is dishonest? Must Osmosis simply TRUST (perhaps the dirtiest word in crypto...) that the amount of ATOM being delivered is not being double spent?” To address this important concern we must understand what a *light client* is. I will only provide the basics here, but you can check [this article]([^4] for an extremely clear and detailed overview. A light client in Cosmos is software that downloads a portion of a blockchain – called the *block headers*. These headers are like a summary – they contain some information about the entire blockchain, but not all of it. This allows a light client to keep track of a blockchain’s *state* (which addresses own what assets) without downloading the entire chain. Here is where some sexy cryptography sneaks in: Before Osmosis mints the voucher tokens for the incoming $ATOM, it will request the balance of the outgoing address from a Cosmos Hub validator. Even though it must make this request, it can use the downloaded block headers to verify that the response is accurate. So, if the Cosmos Hub validator did send an untruthful balance for the outgoing address, the light client running on Osmosis would catch this inconsistency and the voucher tokens would never be minted! Damn… that’s some good crypto. When a connection is formed between two IBC-enabled chains, each must download a light client for the other so that they can continuously monitor each other in a trust-minimized way. On [Map of Zones]([^5] (at the time of writing) you can see that Osmosis currently has 50 connections between other Cosmos blockchains. This means that the Osmosis blockchain currently has 50 light clients running on it, each monitoring the state of one of those chains. # Withdraw $STARS to Stargaze Your ATOM is now on Osmosis, safe and sound, and you triumphantly trade it for STARS using the Osmosis DEX. Now, you wish to complete this grand mission by withdrawing STARS to their home chain, Stargaze. If you think carefully, you'll realize that the STARS on Osmosis are also voucher tokens. They were created by the escrow address at the Osmosis end of the Stargaze-Osmosis channel after an IBC transfer just like the one we covered above. Now, we are going to send them home. You click “Withdraw”, and the dance begins again but in reverse. First, an Osmosis validator sends your STARS voucher tokens to the escrow address, and an IBC packet is created. This packet contains the number of STARS you wish to withdraw. It is fired off to a relayer (the one managing the Osmosis-Stargaze channel), who bounces it over to a validator on Stargaze. The Stargaze validator checks that everything is in order using the Osmosis light client, and forwards the packet to the Osmosis escrow address on Stargaze. Once the packet is received, the intended number of STARS tokens are unlocked from the escrow address and released back into their native blockchain. A confirmation message is relayed back to Osmosis, and once it is confirmed, the original voucher tokens there are *burned* - erased from existence. You, dear reader, are now free to use your STARS in the NFT marketplace and purchase whatever degen nonsense your heart desires. ![osmosis -> stargaze IBC]( # Conclusion I hope you have enjoyed this cosmic voyage through the interchain! To summarize: - All IBC-enabled blockchains can form connections and channels, which are managed by a relayer. - At either end of the channels is a special escrow address which: - locks native tokens that are leaving the chain - releases native tokens that are re-entering the chain - burns voucher tokens (non-native assets) that are leaving the chain - creates voucher tokens that are entering the chain - Light clients allow chains to minimize the amount of trust required in a connected blockchain. - Tokens are transferred via IBC packets through channels which connect two escrow addresses. A few final thoughts: 1. I have attempted to provide only a sketch of the basic IBC mechanism. Many details have been left out, but I hope that for an average user this summary will provide a sufficient foundation for further learning. Informed users are powerful users. 2. Token transfers as I have described here are really just scratching the surface of what IBC is potentially capable of. IBC packets can contain arbitrary information, not JUST information how many tokens are being moved. This means they can send other kinds of data between chains, and even execute transactions on other chains! For a deeper dive on IBC’s future applications I recommend [this article]([^6]. IBC is already enabling blockchain use-cases that have never been possible before and there is no obvious end in sight. Welcome to the interchain. Thanks for reading <3 Robin Tunley Twitter: [@the5thforce0_0]( [^3]: Datachain, How Cosmos’ IBC Works to Achieve Interoperability Between Blockchains, [^4]: Sardan, T., What is a Light Client and Why You Should Care?, Parity Blog, [^5]: Map of Zones, [^6]: Fei, C. Welcome to the IBC Gang, Let’s Talk,