Bridge

Interface

/**
 * Parameters for preparing a cross-chain bridge transaction
 * @interface PrepareBridgeTransactionParams
 * @property {VaultKey} vaultKey - Unique identifier for the vault
 * @property {bigint} bridgeAmount - Amount of shares to bridge (in base units)
 * @property {ChainId} sourceChainId - Chain ID where shares currently exist
 * @property {ChainId} destinationChainId - Chain ID where shares will be bridged to
 * @property {Address} userAddress - Ethereum address of the user initiating the bridge
 */
interface PrepareBridgeTransactionParams {
  vaultKey: VaultKey;
  bridgeAmount: bigint;
  sourceChainId: ChainId;
  destinationChainId: ChainId;
  userAddress: Address;
}

/**
 * Transaction data for executing a cross-chain bridge operation
 * @interface BridgeTransactionData
 * @property {typeof CrossChainTellerBaseAbi} abi - ABI for the CrossChainTeller contract
 * @property {Address} address - Address of the CrossChainTeller contract
 * @property {string} functionName - Name of the function to call on the contract
 * @property {[bigint, BridgeContractArg]} args - Arguments for the bridge function:
 *   [amount, bridgeArgs]
 * @property {number} chainId - ID of the chain where the transaction should be executed
 * @property {bigint} value - Amount of native token to send with the transaction
 */
interface BridgeTransactionData {
  abi: typeof CrossChainTellerBaseAbi;
  address: Address;
  functionName: string;
  args: [bigint, BridgeContractArg];
  chainId: number;
  value: bigint;
}

Function Overview

import { prepareBridgeTransactionData, TokenKeys } from '@molecularlabs/nucleus-frontend';

const VAULT_KEY = VaultKey.BOBAETH;

// Prepare bridge transaction data
const bridgeData = await prepareBridgeTransactionData({
  vaultKey: VAULT_KEY,
  bridgeAmount: BigInt('1000000000000000000'), // 1 token in base units
  sourceChainId: arbitrum.id, // Arbitrum
  destinationChainId: mainnet.id, // Ethereum mainnet
  userAddress: '0x1234...' // User's address that will receive the bridged tokens
});

// Bridge transaction configuration
const {
  abi, // CrossChainTellerBaseAbi
  address, // Teller contract address
  functionName, // 'bridge'
  args, // [bridgeAmount, bridgeContractArg]
  chainId, // Chain ID for the transaction
  value // Bridge fee in native token (calculated via getPreviewFee)
} = bridgeData;

Last updated