Home

Awesome

near-ibc

This is an implementation of the IBC protocol (IBC/TAO) in the NEAR protocol, which includes additional applications such as ICS-20, written by Octopus Network.

Implementation of IBC/TAO

The near-ibc crate is a NEAR smart contract that contains the implementation of interfaces (traits) defined in ibc-rs. These interfaces are essential for IBC/TAO processes. The smart contract also offers view functions for IBC relayer hermes. These functions enable querying of the state of hosted clients, connections, channels and other necessary IBC data.

Implementation of ICS-20

The near-ibc crate also includes the implementation of the transfer module (ICS-20) to reduce the impact of current ibc-rs implementation.

Our implementation of the BankKeeper trait uses sub-accounts mechanism of NEAR protocol. The general design is as the following:

NEAR IBC accounts

Root account

The root account will be deployed by the wasm of the near-ibc crate. It includes the whole implementation of IBC/TAO and application module transfer (ICS-20).

The contract near-ibc will at least provide the following interfaces (functions):

Sub account transfer

Full account id: transfer.<root account>.

The sub-accounts at this level are reserved for applications (modules) in IBC protocol. In our implementation of ICS-20, this sub-account doesn't require any smart contract code deployment, as it is only acting as a placeholder.

Sub account token-factory

Full account id: tf.transfer.<root account>.

This account is for deploying token contracts for assets from other chains. The contract in this account is implemented by the token-factory crate.

The contract token-factory will at least provide the following interfaces (functions):

Sub accounts for assets from other chains

Full account id: <asset id>.tf.transfer.<root account>, where the asset id is the leftmost 128 bits of sha256 hash of the denomination of a certain cross-chain asset, in hex format. Thus, the length of the whole account id will be 32 + 13 + (length of root account id), which can be controlled not longer than 64.

This account is for minting and burning cross-chain assets that are NOT native in NEAR protocol. The contract in this account is implemented by the wrapped-token crate.

The contract wrapped-token will at least provide the following interfaces (functions):

Sub account escrow-factory

Full account id: ef.transfer.<root account>.

This account is for deploying escrow contracts for assets native in NEAR protocol. The contract in this account is implemented by the escrow-factory crate.

The contract escrow-factory will at least provide the following interfaces (functions):

Sub accounts for channel escrows

Full account id: <channel id>.ef.transfer.<root account>.

This account is for receiving/locking NEP-141 assets that are native in NEAR protocol when they are transferred out of the NEAR protocol. It is also responsible for transferring/unlocking these NEP-141 assets when they are transferred back to the NEAR protocol. The contract in this account is implemented by the channel-escrow crate.

The contract channel-escrow will at least provide the following interfaces (functions):

General process of ICS20 implementation

Transfer asset from other chain to NEAR protocol

3-1

Redeem cross-chain asset from NEAR protocol back to the source chain

3-2

Transfer asset from NEAR protocol to other chains

4-1

Redeem cross-chain asset from other chains back to NEAR protocol

4-2

Supporting features

Please refer to release notes for details.

Auditing

These contracts had completed auditing by: