Quick Start
Actions

Transfer Actions

4min

TransferAction

With TransferAction in the definition of the metadata, you have the flexibility to transfer native tokens. You can specify the receiving address, define the amount to be transferred, or leave it undefined, allowing the user to input a value through the mini-app.

The interface is designed as follows:

TypeScript

  • label: A string that specifies the text to be displayed on the button.
  • recipientAddress (optional): A string prefixed with 0x, representing the default receiving address. If not specified, an input field will be rendered for the user to enter the address.
  • amount (optional): A number representing the amount to transfer. This can be whole numbers or decimals (e.g., 1, 1.2, or 0.1). The amount will be converted to wei using the transform function provided by Wagmi.
  • Chains: An interface representing the context of the chains involved in a transaction, replacing the previous use of a chainId enum. This interface, called ChainContext, includes two main properties:
    • source: The source chain where the transaction originates. Currently, all transactions originate from the Avalanche chain. This field is mandatory.
    • destination (optional): The destination chain to which assets will be transferred. If a destination chain different from the source is specified (e.g., Celo), the transfer becomes a cross-chain operation powered by Wormhole, incurring higher gas costs due to the complexity of the bridge between chains. If no destination is specified, the transaction will occur solely on the source chain.

Important Considerations

  • Chain Compatibility: Both source and destination must belong to compatible networks. For example, mixing a mainnet (such as Avalanche Mainnet) with a testnet (such as Celo Alfajores) is invalid and will result in an error. Ensure that both chains are of the same network type (mainnet or testnet) to avoid failures.
  • Gas Costs: Single-chain operations (where no destination is specified or where destination matches source) have lower gas costs. Cross-chain transfers using Wormhole will incur significantly higher gas costs due to the bridging process.

Import Interface

Interface can be imported as follows

TypeScript