For the complete documentation index, see llms.txt. This page is also available as Markdown.

wagmi integration

Celina SDK prepares unsigned transactions. wagmi signs and broadcasts them from the user's wallet.

Why sendTransactionAsync?

Use sendTransactionAsync from useSendTransaction(), not sendTransaction. Celina prepared flows are often multi-step (approve → action), and each step needs:

  • an awaitable hash to track progress and pass to viem publicClient.waitForTransactionReceipt

  • sequential signing — wait for confirmation before the next step

  • try/catch when the user rejects in their wallet

sendTransaction (non-async) is callback/state-oriented and does not return a hash from the call site, so it is a poor fit for looping over flow.steps.

If you use viem directly (no wagmi hook), the same step shape maps to walletClient.sendTransaction — see viem without wagmi below.

Basic pattern

import { createCelinaClient } from "@andrewkimjoseph/celina-sdk";
import { useSendTransaction, useAccount } from "wagmi";

const celina = createCelinaClient();

async function executePreparedFlow(
  sendTransactionAsync: ReturnType<typeof useSendTransaction>["sendTransactionAsync"],
  flow: Awaited<ReturnType<typeof celina.transaction.prepareSend>>,
) {
  for (const step of flow.steps) {
    const hash = await sendTransactionAsync({
      to: step.to,
      data: step.data,
      value: step.value ? BigInt(step.value) : undefined,
    });
    // Wait for confirmation before next step — see Multi-step flows below
    console.log(`Submitted: ${hash}`);
  }
}

React hook example

Multi-step flows

Some prepare methods return multiple steps (approve + action):

Method
Steps when approval needed

mentoFx.prepareFx

approve → swap

uniswap.prepareSwap

approve → Permit2 approve → swap

aave.prepareSupply

approve → supply

Sign steps in order. Wait for each transaction to confirm before sending the next — the swap/supply will fail if the approval is not yet mined.

Simulate each step immediately before signing to avoid gas spent on reverts. See Prepared-step simulation.

Estimates before prepare

Use estimate methods to show gas costs before the user commits:

Error handling

  • User rejects signature — wagmi throws; catch and show a friendly message.

  • Insufficient balance — prepare methods may throw during balance checks; simulatePreparedStep catches reverts before the wallet opens.

  • Wrong from address — always pass the connected wallet address as from.

viem without wagmi

If you use viem directly with a wallet client:

Last updated

Was this helpful?