ICA

How to integrate Nomos V1 with interchain accounts

ICS-27

Interchain Accounts, as defined in ICS-27, facilitate a cross-chain account management protocol utilizing IBC. This protocol allows a blockchain (controller chain) to create and manage accounts on another blockchain (host chain) without using private keys for transactions. Instead, control is exerted via IBC packets.

Key Concepts:

  • Host Chain: The blockchain where the interchain account is created and managed.

  • Controller Chain: The blockchain that creates and controls an account on the host chain.

  • Interchain Account: An account on the host chain that is controlled by the controller chain. It possesses capabilities akin to a regular account (like staking, sending, voting).

Main Features:

  • Permissionless Creation: Any entity can create an interchain account without third-party permissions.

  • Fault Isolation: Actions of one controller chain cannot affect accounts controlled by another.

  • Transaction Ordering: Transactions by an interchain account are executed in the order they are sent from the controller chain.

  • Channel Closure Handling: If a channel closes, the controller chain can regain access to the interchain account by opening a new channel.

  • Role Enforcement: Each interchain account has a single owner on the controller chain, and only this owner can control the account.

ICA Controller

The CosmWasm ICA Controller Contract is a smart contract that enables communication with an ica/host module on a counterparty chain to create and manage a single interchain account. This contract allows for the execution of callbacks based on the outcomes of interchain account transactions.

It's significant because it provides this functionality even on chains that do not have the ICA controller module enabled. It also provides an easy-to-use interface to interact with an ICA account.

Main Features:

  • Creation of an Interchain Account: The contract offers methods (InstantiateMsg and ExecuteMsg::CreateChannel) to initiate the creation of an interchain account.

  • Transaction Execution: Via the ExecuteMsg::SendCosmosMsgs, the contract can commit packets to be sent to the host chain, allowing for transaction execution on the host chain using the interchain account.

  • Callback Execution: Supports executing callbacks in external contracts based on the result of interchain account transactions.

  • Channel Management: The contract provides mechanisms for channel closing and reopening, allowing continuous use of the interchain account even if the ICA channel is closed.

We use the ICA controller to allow a multisig to control multiple accounts on different chains. This can be extended and used by any contract or account.

Integration with Nomos

The question is how to enable ICA accounts on Multisigs? This is achieved with a combination of smart contract accounts (multisigs) and the ICA controller. To get started, first you will need to create a multisig with nomosjs or in our application.

import {Nomos} from "nomosjs";

const nomos = new Nomos();

await nomos.init(signingCosmosClient);

const channelOptions = {
  connection: "connection-1", //connection id of src chain to create ica
  counterpartyConnection: "connection-2362", //target chain connection id
}
const {icaController,transactionHash,events} = await nomos.createICA({
    from: '<user signer>',
    owner: '<user multisig>', // if not specified the sender is the owner
    channel:channelOption
});

Then you will need to create a proposal in your multisig. This proposal should be a normal smart contract transaction

import {buildIcaMessage,Multisig,CosmosMsgForArchwayMsg} from "nomosjs";

const multisig = new Multisig();
//on this example we are sending tokens from our ICA account
//for this to work you must have funds on your ICA account
const messages: CosmosMsgForArchwayMsg[] = [
  {
    bank: {
      send: {
        amount: [
          {
            amount: "<amount to send>",
            denom: "uosmo", //the connections above are from archway to osmosis
          },
        ],
        to_address: "<where you want to send the funds>",
      },
    },
  },
]
const icaControllerMsg = buildIcaMessage({
    '<icaController address>',
    messages,
})

//after this we must approve the proposal to transfer the funds. 
await multisig.init(signingCosmosClient,'<multisig address'>)
await multisig.createProposal({
    messages: [icaControllerMsg],
    description: "test ica",
    from: '<signer address>',
})

On this example, you are sending a transaction to move funds from your ICA account on osmosis from archway. The controller of your ICA account must be your multisig. The following diagram shows the flow of actions:

Last updated