Prepared-step simulation
When to simulate
Timing
Correct?
Why
Basic usage
import { simulatePreparedStep } from "@andrewkimjoseph/celina-sdk/simulation";
import { useSendTransaction, usePublicClient } from "wagmi";
const { sendTransactionAsync } = useSendTransaction();
const publicClient = usePublicClient(); // viem PublicClient — or createPublicClient in non-wagmi apps
for (const step of flow.steps) {
await simulatePreparedStep(publicClient!, {
account: address,
step,
});
const hash = await sendTransactionAsync({
to: step.to,
data: step.data,
value: step.value ? BigInt(step.value) : undefined,
});
const receipt = await publicClient!.waitForTransactionReceipt({ hash });
if (receipt.status === "reverted") {
throw new Error(`Transaction reverted: ${hash}`);
}
}Celo fee abstraction (optional)
Layered approach
MCP server
Related
Last updated
Was this helpful?