This CW ICQ Controller is cosmwasm contract to enable ICQ to host chain from chain that doesn't support ICQ as controller chain.
Cosmos Interchain Queries (ICQ) is a feature of the Inter-Blockchain Communication (IBC) protocol that enables smart contracts on one Cosmos chain (controller) to read data from another chain (host). It acts as a cross-chain read mechanism, allowing developers to query remote chain states—such as account balances—without needing oracle services.
This contract provides two ways to create an ICQ channel:
- Using InstantiateMsg
- Using ExecuteMsg::CreateChannel
- Contract will create ICQ channel on instantiation/create channel call
- Query the channel to get channel number and state using get_channel
- Call send_balance_query to query address balance on other chain using specific channel_id and denom, on callback it will update contract state balance for the address
- Query the address balances using balances query
archwayd tx wasm instantiate codeid '{"channel_open_init_options":{"connection_id": "connection-120","counterparty_port_id": "icqhost","channel_ordering": "ORDER_UNORDERED"}}' --label icq-1 --from name --admin name
This instantiation will create new channel using connection-120 with counterparty_port_id set to icqhost
archwayd query wasm contract-state smart cw-icq-contract '{ "get_channel": {}}'
archwayd tx wasm execute archway1wak8sp9ksjk39h4slcvu3q7t7da055nz6wtfsh592jg4snr69upq0gnkxl '{ "send_balance_query": { "channel_id": "channel-239", "address": "osmo1vnglhewf3w66cquy6hr7urjv3589srhelhn6df", "denom": "uosmo" }}'
archwayd query wasm contract-state smart archway1wak8sp9ksjk39h4slcvu3q7t7da055nz6wtfsh592jg4snr69upq0gnkxl '{"balances":{"address": "osmo1vnglhewf3w66cquy6hr7urjv3589srhelhn6df"}}'