Granite Upgrade Activates in06d:02h:04m:27s
Interchain Messaging

Methods

sendMsg

Sends a cross-chain message to the specified destination chain.

Parameters

ParameterTypeRequiredDescription
messagestringYesMessage content to send
sourceChainChainConfigYes*Source chain configuration
destinationChainChainConfigYes*Destination chain configuration
recipientAddress0x${string}NoRecipient address (defaults to zero address)
feeInfo{ feeTokenAddress: string, amount: bigint }NoFee token and amount
requiredGasLimitbigintNoGas limit for execution (default: 100000)
allowedRelayerAddressesstring[]NoAllowed relayer addresses

* Required if not set in client constructor

Returns

TypeDescription
Promise<string>Transaction hash

Example

import { createICMClient } from "@avalanche-sdk/interchain";
import { avalancheFuji, dispatch } from "@avalanche-sdk/interchain/chains";

const icm = createICMClient(wallet);

// Simple message
const hash = await icm.sendMsg({
  sourceChain: avalancheFuji,
  destinationChain: dispatch,
  message: "Hello from Avalanche!",
});

// With options
const hash = await icm.sendMsg({
  sourceChain: avalancheFuji,
  destinationChain: dispatch,
  message: "Hello from Avalanche!",
  recipientAddress: "0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6",
  feeInfo: {
    feeTokenAddress: "0x0000000000000000000000000000000000000000",
    amount: 0n,
  },
  requiredGasLimit: 200000n,
});

Is this guide helpful?