Skip to main content

Step-by-Step Guides for Beginners

Executing a Basic Cross-Chain Transaction​

This tutorial contains one of the basic function of the sourdough module which is x/icauth. The purpose of this tutorial is to showcase how a basic cross chain transaction works.

Cross-Chain Transaction using submit-tx​

  1. Get the chain binary from interchain-auth. You can also build your own using make localnet-build and it should be accessible in cmd folder.

  2. Start two chain to test submit-tx between those chain. We will refer these two chain as alpha and beta moving forward. Execute make localnet-start-alpha and make localnet-start-beta in a new terminal.

  3. Start a relayer to relay messages between those chains. We are using hermes relayer for this tutorial.

  4. Add alpha and beta hermes configuration as you like. This is an example for the config that you can follow. Feel free to modify according to your own settings.

    .... other hermes configuration

    [[chains]]
    id = "alpha-1"
    type = "CosmosSdk"
    rpc_addr = "http://127.0.0.1:28657"
    grpc_addr = "http://127.0.0.1:9290"
    event_source = { mode = "push", url = "ws://127.0.0.1:28657/websocket", batch_delay = "500ms" }
    rpc_timeout = "10s"
    trusted_node = false
    account_prefix = "cosmos"
    key_name = "default"
    key_store_type = "Test"
    store_prefix = "ibc"
    default_gas = 100000
    max_gas = 3000000
    gas_price = { price = 0.01, denom = "ualpha" }
    gas_multiplier = 1.2
    max_msg_num = 30
    max_tx_size = 180000
    max_grpc_decoding_size = 33554432
    clock_drift = "3h"
    max_block_time = "30s"
    ccv_consumer_chain = false
    memo_prefix = "Chain alpha"
    sequential_batch_tx = false
    trusting_period = "86400s"
    trust_threshold = { numerator = "1", denominator = "3" }
    address_type = { derivation = "cosmos" }

    [[chains]]
    id = "beta-1"
    type = "CosmosSdk"
    rpc_addr = "http://127.0.0.1:27657"
    grpc_addr = "http://127.0.0.1:9190"
    event_source = { mode = "push", url = "ws://127.0.0.1:27657/websocket", batch_delay = "500ms" }
    rpc_timeout = "10s"
    trusted_node = false
    account_prefix = "cosmos"
    key_name = "default"
    key_store_type = "Test"
    store_prefix = "ibc"
    default_gas = 100000
    max_gas = 3000000
    gas_price = { price = 0.01, denom = "ubeta" }
    gas_multiplier = 1.2
    max_msg_num = 30
    max_tx_size = 180000
    max_grpc_decoding_size = 33554432
    clock_drift = "3h"
    max_block_time = "30s"
    ccv_consumer_chain = false
    memo_prefix = "Chain beta"
    sequential_batch_tx = false
    trusting_period = "86400s"
    trust_threshold = { numerator = "1", denominator = "3" }
    address_type = { derivation = "cosmos" }
  5. Ensure the hermes config are correct and connected with hermes health-check . Then execute hermes start

  6. Let’s do a recap. In this point of the tutorial, we already have: alpha chain running, beta chain running, hermes relayer loaded with alpha chain and beta chain configuration running. Now we create a channel to facilitate x/icauth IBC operation, the port are icauth. Execute the create channel command for hermes.

    hermes create channel --a-chain alpha-1 --b-chain beta-1 --a-port icauth --b-port icauth --channel-version icauth-1 --new-client-connection --yes
  7. The setup phase is complete. Before we test the execution, let us see the format of the command of submit-tx.

    [chain_binary] tx icauth submit-tx [channel-id] [path/to/sdk_msg.json]

    We need to provide:

    • chain binary: self explanatory, this should be interchain-auth-cd depending on your setting or if you want to rename it.
    • channel-id: we can get these from our previous create channel command in hermes (see output or query channel).
    • path/to/sdk_msg.json: this can be the JSON itself or path to your JSON file. We prefer to use file for easy debugging if there is an issue.
  8. Create the needed messages by executing transaction message with —generate-only flag or you can construct it by hand. Remember that the supported messages are determined by the receiver chain and what were registered and allowed by that chain. For this tutorial, we will go with a simple bank transfer from account A to account B. The account A should already be included in genesis.json.

    [
    {
    "@type": "/cosmos.bank.v1beta1.MsgSend",
    "from_address": "cosmos1zypqa76je7pxsdwkfah6mu9a583sju6xqt3mv6",
    "to_address": "cosmos1mgp7qnvumhlcq6e4z2q05r29dchcyug0z3zxeg",
    "amount": [
    {
    "denom": "ubeta",
    "amount": "3333333"
    }
    ]
    }
    ]
  9. After saving the JSON content to a file located in ~/test-msg.json and assuming that the channel created previously was named channel-0, we can construct the command like this:

    ./build/interchain-auth-cd tx icauth submit-tx channel-0 ~/test-msg.json --home ~/.alphad --node tcp://localhost:28657 --from alice --keyring-backend test --chain-id alpha-1
  10. We can verify that the submit-tx execution are successful through balance query.

    ./build/interchain-auth-cd q bank balances cosmos1mgp7qnvumhlcq6e4z2q05r29dchcyug0z3zxeg --node tcp://localhost:27657

Setting Up Your First Smart Account​

This tutorial guides on how to set up Smart Account contract.

Preparation​

  1. Get the chain binary from interchain-auth. You can also build your own using make localnet-build and it should be accessible in cmd folder.

  2. Start a local chain make localnet-start-alpha in a new terminal.

  3. Start a relayer to relay messages between alpha chain and neutron testnet (pion-1). We are using hermes relayer for this tutorial.

  4. Add alpha and pion-1 hermes configuration as you like. This is an example for the config that you can follow. Feel free to modify according to your own settings.

    • config.toml

      .... other hermes configuration

      [[chains]]
      id = "alpha-1"
      type = "CosmosSdk"
      rpc_addr = "http://127.0.0.1:28657"
      grpc_addr = "http://127.0.0.1:9290"
      event_source = { mode = "push", url = "ws://127.0.0.1:28657/websocket", batch_delay = "500ms" }
      rpc_timeout = "10s"
      trusted_node = false
      account_prefix = "cosmos"
      key_name = "default"
      key_store_type = "Test"
      store_prefix = "ibc"
      default_gas = 100000
      max_gas = 3000000
      gas_price = { price = 0.01, denom = "ualpha" }
      gas_multiplier = 1.2
      max_msg_num = 30
      max_tx_size = 180000
      max_grpc_decoding_size = 33554432
      clock_drift = "3h"
      max_block_time = "30s"
      ccv_consumer_chain = false
      memo_prefix = "Chain alpha"
      sequential_batch_tx = false
      trusting_period = "86400s"
      trust_threshold = { numerator = "1", denominator = "3" }
      address_type = { derivation = "cosmos" }

      [[chains]]
      id = "pion-1"
      type = "CosmosSdk"
      rpc_addr = "https://rpc-falcron.pion-1.ntrn.tech:443"
      grpc_addr = "https://grpc.pion.ics-testnet.polypore.xyz:443"
      event_source = { mode = "push", url = "wss://rpc-falcron.pion-1.ntrn.tech:443/websocket", batch_delay = "500ms" }
      rpc_timeout = "10s"
      trusted_node = false
      account_prefix = "neutron"
      key_name = "default"
      key_store_type = "Test"
      store_prefix = "ibc"
      default_gas = 100000
      max_gas = 3000000
      gas_price = { price = 0.0053, denom = "untrn" }
      gas_multiplier = 1.5
      max_msg_num = 30
      max_tx_size = 180000
      max_grpc_decoding_size = 33554432
      clock_drift = "3h"
      max_block_time = "30s"
      ccv_consumer_chain = true
      memo_prefix = "Chain neutron testnet"
      sequential_batch_tx = false
      trusting_period = "86400s"
      trust_threshold = { numerator = "1", denominator = "3" }
      address_type = { derivation = "cosmos" }
  5. Ensure the hermes config are correct and connected with hermes health-check . Then execute hermes start

  6. Let’s do a recap. In this point of the tutorial, we already have:

    • alpha chain running
    • hermes relayer loaded with alpha chain and pion-1 chain configuration running

    Now we create a channel to facilitate IBC Transfer operation. Execute the create channel command for hermes.

    hermes create channel --a-chain alpha-1 --b-chain pion-1 --a-port transfer --b-port transfer --new-client-connection --yes
  7. Instantiate GMP Forwarder contract on Neutron testnet

    The GMP Forwarder contract has been stored on the code-id 8010. Replace CHANNEL_ID_PION_TO_ALPHA with channel id that has been created before.

    neutrond tx wasm instantiate 8010 '{"source_channel_id":"CHANNEL_ID_PION_TO_ALPHA", "axelar_channel_id":"channel-8"}' --label "gmp_forwarder" --gas 300000 --admin alice --amount 10000untrn --from wallet -y
  8. Ensure that the contract is successfully created and save the contract address

Account Creation​

We will create Smart Account contract from Alpha chain using Neutron testnet as forwarder to Axelar GMP. The EntryPoint cotract has been deployed to Sepolia testnet:

EntryPoint contract address: 0xcF3ef2578E4b7eE10c34C0D03359B35E6247A4e2
  1. Execute create account CLI to Ethereum Sepolia from alpha chain

    interchain-auth-cd \
    --home .alphad/ \
    --node [http://0.0.0.0:28657](http://0.0.0.0:28657/) \
    tx gmp create-account CHANNEL_ID_ALPHA_TO_NEUTRON "ethereum-sepolia" \
    ENTRYPOINT_CONTRACT_ADDRESS \
    AXELAR_RELAYER_FEE \
    --receiver NEUTRON_FORWARDER_CONTRACT_ADDRESS \
    --from wallet \
    -y
  2. If the transaction is successfully sent, we can monitor the GMP progress on Axelar Scan

Executing Smart Account Transaction​

After creating the Smart Account contract address, we can top up some balances to the address to be able to transfer token from account contract to the receiver address.

  1. Execute send account transaction to Ethereum Sepolia from alpha chain

    interchain-auth-cd \
    --home .alphad/ \
    --node [http://0.0.0.0:28657](http://0.0.0.0:28657/) \
    tx gmp send-account-tx CHANNEL_ID_ALPHA_TO_NEUTRON "ethereum-sepolia" \
    ENTRYPOINT_CONTRACT_ADDRESS \
    AXELAR_RELAYER_FEE \
    SMART_ACCOUNT_CONTRACT_ADDRESS \
    PAYLOAD_TX \
    --receiver NEUTRON_FORWARDER_CONTRACT_ADDRESS \
    --from wallet \
    -y

    Example PAYLOAD_TX for transfering token to receiver address:

    000000000000000000000000aa25aa7a19f9c426e07dee59b12f944f4d9f1dd3000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000
  2. If the transaction is successfully sent, we can monitor the GMP progress on Axelar Scan