{"id":13562883,"url":"https://github.com/cosmos/interchain-accounts-demo","last_synced_at":"2025-04-03T19:31:47.721Z","repository":{"id":39634781,"uuid":"341824417","full_name":"cosmos/interchain-accounts-demo","owner":"cosmos","description":"ICA ","archived":true,"fork":true,"pushed_at":"2023-09-20T09:29:59.000Z","size":1735,"stargazers_count":83,"open_issues_count":0,"forks_count":14,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-04T15:51:42.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"charleenfei/ica","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cosmos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-24T08:05:02.000Z","updated_at":"2024-04-02T17:41:29.000Z","dependencies_parsed_at":"2023-02-10T06:16:02.447Z","dependency_job_id":null,"html_url":"https://github.com/cosmos/interchain-accounts-demo","commit_stats":null,"previous_names":["interchainberlin/ica","cosmos/interchain-accounts"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Finterchain-accounts-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Finterchain-accounts-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Finterchain-accounts-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Finterchain-accounts-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosmos","download_url":"https://codeload.github.com/cosmos/interchain-accounts-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247065295,"owners_count":20877753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:01:13.131Z","updated_at":"2025-04-03T19:31:47.093Z","avatar_url":"https://github.com/cosmos.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# ☠️ ARCHIVED ☠️\n\n### ⚠️ This repository is no longer maintained. Use it at your own risk. ☢️\n\n# Interchain Accounts\n\nDevelopers integrating Interchain Accounts may choose to firstly enable host chain functionality, and add authentication modules later as desired.\nDocumentation regarding authentication modules can be found in the [IBC Developer Documentation](https://ibc.cosmos.network/main/apps/interchain-accounts/overview.html).\n\n## Overview \n\nThe following repository contains a basic example of an Interchain Accounts authentication module and serves as a developer guide for teams that wish to use interchain accounts functionality.\n\nThe Interchain Accounts module is now maintained within the `ibc-go` repository [here](https://github.com/cosmos/ibc-go/tree/main/modules/apps/27-interchain-accounts). \nInterchain Accounts is now available in the [`v3.0.0`](https://github.com/cosmos/ibc-go/releases/tag/v3.0.0) release of `ibc-go`.\n\n### Developer Documentation\n\nInterchain Accounts developer docs can be found on the IBC documentation website.\n\nhttps://ibc.cosmos.network/main/apps/interchain-accounts/overview.html\n\n## Setup\n\n1. Clone this repository and build the application binary\n\n```bash\ngit clone https://github.com/cosmos/interchain-accounts-demo.git\ncd interchain-accounts\n\nmake install \n```\n\n2. Download and install an IBC relayer. ([hermes](https://hermes.informal.systems/), [go relayer](https://github.com/cosmos/relayer) or both )\n```bash\n# hermes\ncargo install --version 0.15.0 ibc-relayer-cli --bin hermes --locked\n\n#go relayer (make sure to use v2.0.0-rc4 or later!)\ngit clone https://github.com/cosmos/relayer.git\ncd relayer \u0026\u0026 git checkout v2.0.0-rc4\nmake install\n```\n\n3. Bootstrap two chains, configure the relayer and create an IBC connection (on top of clients that are created as well)\n```bash\n# hermes\nmake init-hermes\n\n# go relayer\nmake init-golang-relayer\n```\n\n:warning: **NOTE:** When you want to use both relayers interchangeably, using both of these `make` commands will set up two seperate connections (which is not needed and can lead to confusion). In the case of using both relayers, perform:\n```bash\nmake init-golang-rly\n./network/hermes/restore-keys.sh\n```\n\n4. Start the relayer\n```bash\n#hermes\nmake start-hermes\n\n#go relayer\nmake start-golang-rly\n```\n\n:exclamation: **NOTE:** It is abstracted away in the script files, but in case you want to manually run `rly start` with interchain accounts, you will need to add this flag: `-p events` to it.\n\n\u003e This is the situation *before* `make init-*`. The blockchains are not live yet.\n![pre-init](./images/pre-init.png)\n\n\u003e This is the situation *after* `make init-*`. The chain binary's have been built and started, and an IBC connection between controller and host chains has been set up.\n![post-init](./images/post-init.png)\n\n## Demo\n\n**NOTE:** For the purposes of this demo the setup scripts have been provided with a set of hardcoded mnemonics that generate deterministic wallet addresses used below.\n\n```bash\n# Store the following account addresses within the current shell env\nexport WALLET_1=$(icad keys show wallet1 -a --keyring-backend test --home ./data/test-1) \u0026\u0026 echo $WALLET_1;\nexport WALLET_2=$(icad keys show wallet2 -a --keyring-backend test --home ./data/test-1) \u0026\u0026 echo $WALLET_2;\nexport WALLET_3=$(icad keys show wallet3 -a --keyring-backend test --home ./data/test-2) \u0026\u0026 echo $WALLET_3;\nexport WALLET_4=$(icad keys show wallet4 -a --keyring-backend test --home ./data/test-2) \u0026\u0026 echo $WALLET_4;\n```\n\n### Registering an Interchain Account via IBC\n\nRegister an Interchain Account using the `intertx register` cmd. \nHere the message signer is used as the account owner.\n\n```bash\n# Register an interchain account on behalf of WALLET_1 where chain test-2 is the interchain accounts host\nicad tx intertx register --from $WALLET_1 --connection-id connection-0 --chain-id test-1 --home ./data/test-1 --node tcp://localhost:16657 --keyring-backend test -y\n\n# Query the address of the interchain account\nicad query intertx interchainaccounts connection-0 $WALLET_1 --home ./data/test-1 --node tcp://localhost:16657\n\n# Store the interchain account address by parsing the query result: cosmos1hd0f4u7zgptymmrn55h3hy20jv2u0ctdpq23cpe8m9pas8kzd87smtf8al\nexport ICA_ADDR=$(icad query intertx interchainaccounts connection-0 $WALLET_1 --home ./data/test-1 --node tcp://localhost:16657 -o json | jq -r '.interchain_account_address') \u0026\u0026 echo $ICA_ADDR\n```\n\n\u003e This is the situation after registering the ICA. A channel has been created and an ICA has been registered on the host.\n![post-register](./images/post-register.png)\n\n#### Funding the Interchain Account wallet\n\nAllocate funds to the new Interchain Account wallet by using the `bank send` cmd.\nNote this is executed on the host chain to provide the account with an initial balance to execute transactions.\n\n```bash\n# Query the interchain account balance on the host chain. It should be empty.\nicad q bank balances $ICA_ADDR --chain-id test-2 --node tcp://localhost:26657\n\n# Send funds to the interchain account.\nicad tx bank send $WALLET_3 $ICA_ADDR 10000stake --chain-id test-2 --home ./data/test-2 --node tcp://localhost:26657 --keyring-backend test -y\n\n# Query the balance once again and observe the changes\nicad q bank balances $ICA_ADDR --chain-id test-2 --node tcp://localhost:26657\n```\n\n\u003e This is the situation after funding the ICA.\n![post-fund](./images/post-fund.png)\n\n#### Sending Interchain Account transactions\n\nSend Interchain Accounts transactions using the `intertx submit` cmd. \nThis command accepts a generic `sdk.Msg` JSON payload or path to JSON file as an arg.\n\n- **Example 1:** Staking Delegation\n\n```bash\n# Output the host chain validator operator address: cosmosvaloper1qnk2n4nlkpw9xfqntladh74w6ujtulwnmxnh3k\ncat ./data/test-2/config/genesis.json | jq -r '.app_state.genutil.gen_txs[0].body.messages[0].validator_address'\n\n# Submit a staking delegation tx using the interchain account via ibc\nicad tx intertx submit \\\n'{\n    \"@type\":\"/cosmos.staking.v1beta1.MsgDelegate\",\n    \"delegator_address\":\"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz\",\n    \"validator_address\":\"cosmosvaloper1qnk2n4nlkpw9xfqntladh74w6ujtulwnmxnh3k\",\n    \"amount\": {\n        \"denom\": \"stake\",\n        \"amount\": \"1000\"\n    }\n}' --connection-id connection-0 --from $WALLET_1 --chain-id test-1 --home ./data/test-1 --node tcp://localhost:16657 --keyring-backend test -y\n\n# Alternatively provide a path to a JSON file\nicad tx intertx submit [path/to/msg.json] --connection-id connection-0 --from $WALLET_1 --chain-id test-1 --home ./data/test-1 --node tcp://localhost:16657 --keyring-backend test -y\n\n# Wait until the relayer has relayed the packet\n\n# Inspect the staking delegations on the host chain\nicad q staking delegations-to cosmosvaloper1qnk2n4nlkpw9xfqntladh74w6ujtulwnmxnh3k --home ./data/test-2 --node tcp://localhost:26657\n```\n\n\u003e This is the situation before after sending the staking tx. The user who is the owner of the ICA has staked funds on the host chain to a validator of choice through an interchain accounts packet.\n![post-sendtx](./images/post-sendtx.png)\n\n- **Example 2:** Bank Send\n\n```bash\n# Submit a bank send tx using the interchain account via ibc\nicad tx intertx submit \\\n'{\n    \"@type\":\"/cosmos.bank.v1beta1.MsgSend\",\n    \"from_address\":\"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz\",\n    \"to_address\":\"cosmos10h9stc5v6ntgeygf5xf945njqq5h32r53uquvw\",\n    \"amount\": [\n        {\n            \"denom\": \"stake\",\n            \"amount\": \"1000\"\n        }\n    ]\n}' --connection-id connection-0 --from $WALLET_1 --chain-id test-1 --home ./data/test-1 --node tcp://localhost:16657 --keyring-backend test -y\n\n# Alternatively provide a path to a JSON file\nicad tx intertx submit [path/to/msg.json] --connection-id connection-0 --from $WALLET_1 --chain-id test-1 --home ./data/test-1 --node tcp://localhost:16657 --keyring-backend test -y\n\n# Wait until the relayer has relayed the packet\n\n# Query the interchain account balance on the host chain\nicad q bank balances $ICA_ADDR --chain-id test-2 --node tcp://localhost:26657\n```\n\n#### Testing timeout scenario\n\n1. Stop the relayer process and send an interchain accounts transaction using one of the examples provided above.\n\n2. Wait for approx. 1 minute for the timeout to elapse.\n\n3. Restart the relayer process\n\n```bash\n#hermes\nmake start-hermes\n\n#go relayer\nmake start-golang-rly\n```\n\n4. Observe the packet timeout and relayer reacting appropriately (issuing a MsgTimeout to testchain `test-1`).\n\n5. Due to the nature of ordered channels, the timeout will subsequently update the state of the channel to `STATE_CLOSED`.\nObserve both channel ends by querying the IBC channels for each node.\n\n```bash\n# inspect channel ends on test chain 1\nicad q ibc channel channels --home ./data/test-1 --node tcp://localhost:16657\n\n# inspect channel ends on test chain 2\nicad q ibc channel channels --home ./data/test-2 --node tcp://localhost:26657\n```\n\n6. Open a new channel for the existing interchain account on the same connection.\n\n```bash\nicad tx intertx register --from $WALLET_1 --connection-id connection-0 --chain-id test-1 --home ./data/test-1 --node tcp://localhost:16657 --keyring-backend test -y\n```\n\n7. Inspect the IBC channels once again and observe a new creately interchain accounts channel with `STATE_OPEN`.\n\n```bash\n# inspect channel ends on test chain 1\nicad q ibc channel channels --home ./data/test-1 --node tcp://localhost:16657\n\n# inspect channel ends on test chain 2\nicad q ibc channel channels --home ./data/test-2 --node tcp://localhost:26657\n```\n\n## Collaboration\n\nPlease use conventional commits  https://www.conventionalcommits.org/en/v1.0.0/\n\n```\nchore(bump): bumping version to 2.0\nfix(bug): fixing issue with...\nfeat(featurex): adding feature...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmos%2Finterchain-accounts-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmos%2Finterchain-accounts-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmos%2Finterchain-accounts-demo/lists"}