KiChain: How to use the Ki Bridge

Tarek Awwad
Ki Foundation
Published in
9 min readJun 3, 2021

Welcome to the Ki-steps series, a sequence of how-to posts where we explain the detailed steps to perform more or less advanced tasks on the KiChain. In this post, we will visit the recently released Ki Bridge, its functionalities and usage.

⚠️ Disclaimer : The Ki Bridge is still in beta, please beware of the risks related to using it.

⚠️ Disclaimer : The screen captures in this tutorial are shown for pedagogical purposes, please only use addresses and information found in the text and on the Ki Bridge.

What is a Bridge?

A blockchain is a data structure that allows to store and track the state of an asset system. In the context of cryptocurrencies, the asset is one or multiple tokens and the state of the blockchain consists of the set of accounts and their balances. The validity and integrity of the blockchain state is guaranteed by the consensus mechanism. The specifications and implementation of this consensus mechanism as well as those of the token itself varies from one blockchain to another. This variance makes it technically unfeasible to directly move native assets from one blockchain to another.

A bridge is a translation layer that enables transparent transfer of tokens from one blockchain to another. Generally speaking, a bridge transfers the asset by locking or burning a given amount of assets on the source chain (using a trusted tier or in a decentralized manner at protocole level) and creating an equivalent amount on the destination chain. This transfer is also known as Swapping.

Swapping tokens between chains allows the user to use the value of their tokens with different chain specific functionalities, products and services such as governance voting, staking, yield farming, etc…

🤓 Note: two sovereign blockchains are not necessarily incompatible. In some cases, asset transfer can be possible without a bridge. This is the case of the Cosmos ecosystem where the IBC (Inter Blockchain Communication) protocol acts like a native bridge for Cosmos SDK based chains.

How does the Ki Bridge Work?

The Ki Bridge allows to transfer XKI tokens from the KiChain to the Ethereum chain ( for now 👀 ) and vice versa. It achieves this by using a trusted tier on the KiChain and a Smart Contract on the Ethereum chain. The figure below summarizes the end to end process for a two-way swap: the green workflow illustrates a swap from Native XKI to ERC20 XKI (a.k.a wrapping) while the purple workflow depicts the opposite swap (a.k.a unwrapping).

In a nutshell, when wrapping XKI, the trusted tier receives a transaction from the user with the amount of native XKIs to swap, it locks this amount and interacts with the contract to mint an equivalent amount of ERC20 XKIs into the counterpart Ethereum address provided by the user. When unwrapping, the user interacts directly with the smart contract asking to swap a given amount of ERC20 XKIs. The contract will then burn these tokens and the trusted tier releases an equivalent amount of native XKIs to the counterpart KiChain address provided by the user.

How to use the Ki Bridge?

As mentioned earlier, the bridge can be used to swap Native XKI (transferable and stakeable on the KiChain) to ERC20 XKI (usable with defi tools on the Ethereum blockchain). Hereafter, we detail the steps to swap XKI tokens in both directions. The figure below depicts a detailed list of the user interface elements. For convenience, we will be referring to these elements by their badge numbers when needed.

⚠️ Always ensure that you are using the official Ki Bridge at the following link: https://bridge.ki/. The token contract can be found at the following address: 0x4f6103bad230295bacf30f914fda7d4273b7f585.

Prerequisites:

To use the Ki Bridge you will need the following:

  • An XKI wallet on the KiChain which can be created and managed in the Ki Desktop Wallet or the Cosmostation Mobile Wallet. A full tutorial on how to use the Ki Desktop Wallet can be found here.
  • Metamask installed and enabled in the borwser. If MetaMask is not installed, the bridge will prompt you to install it at every step that requires an interaction with an Ethereum address.
  • An Ethereum address which you can create with Metamask.
  • Depending on the swap direction, a positive balance of ETH to pay for transaction fees.

Connecting MetaMask to the Bridge

Let's start by learning how to connect the Ki Bridge to MetaMask. While this is required for swapping ERC20 XKIs to Native XKIs, it only enables optional features in the other swap direction. Head to the Ki Bridge page and click on Connect wallet on the top right corner to connect your MetaMask if it is not already connected. MetaMask will popup and you will be able to enter your password to unlock it (if it is locked). Choose the wallet you want to connect, and click on connect. The connected chain (3), connected wallet (4) and its ETH balance (5) are now visible in the top right corner. You should be connected to the Mainnet chain. If this is not the case, a popup will ask you to do so. You can simply switch the connected chain using the dropdown list in MetaMask directly.

MetaMask do not automatically add all the existing ERC20 tokens (Thankfully!). However, whether you are swapping from ERC20 XKI or to ERC20 XKI, it is practical to have access to your ERC20 XKI balance at a glance within MetaMask. To import the XKI token to MetaMask simply click on Add the XKI token to MetaMask (15). This will open MetaMask for you to confirm the import action.

Swap Native XKI to ERC20 XKI

If you've bought XKI tokens during the private sales or after the listing on Liquid, you now own Native XKIs. Those can be transferred and staked natively on the KiChain. You might however want to send them to Ethereum in order to use them in Uniswap and other compatible defi tools. Therefor, you will first need to swap them to ERC20 XKI Tokens. Here is how to proceed.

Head to the Ki Bridge and fill in the amount of Native XKI tokens you would like to swap in the source input field (8). The equivalent amount of ERC20 XKI tokens are computed and shown in the destination field (10). The Native and ERC20 tokens are equivalent in value. The difference in the computed amount is due to the fees. For Native to ERC20 swaps, fees are paid in XKI. The estimated amount of fees is also shown in the fee container (14).

The bridge needs to know the address to which it should send the swapped tokens (i.e. ERC20 XKIs). We call this address the counterpart address. This is an address of yours on the Ethereum chain, ideally imported in MetaMask and connected to the bridge. To provide the counterpart address, fill in the dedicated Ethereum address field (11) manually or using the autofill MetaMask logo.

The latter will work only if your MetaMask is already connected to the Bridge and will fill in the current connected address. If MetaMask is not connected, clicking the auto-fill button will prompt you to connect your wallet. Please note that if the counterpart address is invalid the swap won’t be successful.

In case of problems the swap is reverted and the native tokens are sent to the original KiChain wallet address. This might take a while. Please be patient!

Once the data is entered correctly, the Swap button is enabled and the swap form should look something like this:

Click on Swap, a popup showing the summary of the transaction and a set of instructions shows up.

First verify the transaction data and then follow the provided instructions thoroughly: head to a compatible KiChain wallet, create a transfer transaction with the info shown in the confirmation popup, that is, the amount, the recipient address (i.e., the bridge address) and the counterpart address in the memo. Double check and send the transaction. If any of these information is wrong, risks ranges from swapping the wrong amount of tokens or paying refund fees if you are lucky, to loosing your tokens (if the counterpart address is wrong). Please be careful.

Once the transaction is sent go back to the Ki Bridge, click on Confirm Swap and then on Transaction Done. This will prompt you to a message with a link to your wallet address on Etherscan. Click on the link to ensure you have received your tokens. Note that it might take up to 30 minutes before the swap is complete and your balance is updated.

Swap ERC20 XKI to Native XKI:

Let's suppose that you bought 1000 XKI on Uniswap. Since the latter is an Ethereum tool, the XKIs you now own are ERC20 XKI. Consequently, you cannot directly stake them on the KiChain and start generating yield. You need to swap them to native XKIs first. This is a typical — yet not the only — use case for using the Ki Bridge in this direction. Here is how you would proceed.

Start by connecting your MetaMask to the Bridge by following the process explained earlier. Now that you are connected, click on the arrow (9) to select the swap direction. The source token should be the XKI ERC20 (7) and the destination token should be the XKI Native (10).

Fill in the amount of ERC20 tokens you want to swap. Your can see your ERC20 XKI balance in the bottom of the input field (8) and you can click on max to swap all of the available balance. The equivalent amount of Native XKI is computed and shown in the destination input field (10) and in the fee container (13). An estimation of the bridge fees is also shown in the fee container (14). Please note that these are the bridge fees in Native XKI and not the Ethereum fees which you can see and adjust in Meta mask directly.

As for the wrapping process detailed in the previous section, it is crucial to provide a counterpart address that should receive the resulting swapped XKIs. To do so, fill in the counterpart input field (11) with a valid KiChain address. After filling all the required inputs, your form should something like this:

If everything is entered correctly the Swap button will be enabled. Click on Swap, a popup with the transaction summary will show up. Ensure the correctness of the entered data, check the verification message and click on Confirm Swap.

After confirming the swap, MetaMask will popup. Confirm and sign the transaction in MetaMask as you do usually and wait until the transaction is broadcasted and confirmed on Ethereum. After a while the status popup shows the transaction as confirmed. Depending on the fees you have decided to pay, the confirmation might take a long time to be confirmed. This is related to the Ethereum chain and not to the Ki Bridge itself.

When closing the status popup, you will be prompted to a message with a link to your wallet address on the KiChain explorer.

Click on the link to ensure you have received your tokens. Note that it might take a couple of minutes before your balance is updated.

The end to end swap can take up to 30 minutes. Please be patient!

In this post we detailed the functionalities and usage of the Ki Bridge. In the future more feature will be supported (e.g., other chains) and further improvements of the user experience will be made. Meanwhile, if you have an issue while using the bridge, please contact us by mail with ‘Bridge’ as subject and providing the hash of your transaction: contact@foundation.ki.

--

--

Tarek Awwad
Ki Foundation

Computer Scientist - PhD - Chief Blockchain Architect @Ki_Foundation - #Blockchain #DistributedSystems #Crowdsourcing #MachineLearning #DataMining