executeQuote
interface ExecuteTransactionParams {
quote: Quote;
// For EVM chains (Ethereum, BSC, Polygon, etc.)
provider?: Provider | WalletClient; // Supports ethers.js BrowserProvider or viem WalletClient (including wagmi's getWalletClient)
// For Solana chain
walletAdapter?: WalletAdapter; // Compatible with @solana/web3.js and @solana/wallet-adapter-base wallets
// For Cosmos-based chains
cosmosClient?: any; // Compatible with @cosmjs/stargate and @cosmjs/cosmwasm-stargate clients
// Optional callback for tracking transaction status
onStatusUpdate?: (status: TransactionStatus, data?: ExecuteTransactionResult) => void;
onCreateTxComplete?: (tx: CreateTransactionResponse) => void;
onNextTxComplete?: (tx: TransactionDataResponse) => void;
onSignComplete?: (txDetail: { stepId: string; txHash: string }) => void;
solanaRpcUrl?: string;
}// 1. EVM Chains Examples
// Using ethers.js BrowserProvider
import { BrowserProvider } from "ethers";
const provider = new BrowserProvider(window.ethereum);
const evmResult = await executeTransaction({
quote: quotes.data.quotes[0],
provider: provider,
});
// Using viem WalletClient
import { createWalletClient, custom } from "viem";
const walletClient = createWalletClient({
transport: custom(window.ethereum),
});
const evmViemResult = await executeTransaction({
quote: quotes.data.quotes[0],
provider: walletClient,
});
// Using wagmi's getWalletClient
import { getWalletClient } from "@wagmi/core";
const wagmiClient = await getWalletClient();
const evmWagmiResult = await executeTransaction({
quote: quotes.data.quotes[0],
provider: wagmiClient,
});
// 2. Solana Examples
// Using Phantom Wallet
import { PhantomWalletAdapter } from "@solana/wallet-adapter-phantom";
const phantomWallet = new PhantomWalletAdapter();
await phantomWallet.connect();
const solanaResult = await executeTransaction({
quote: quotes.data.quotes[0],
walletAdapter: phantomWallet,
});
// Using Solana Wallet Adapter
import { useWallet } from "@solana/wallet-adapter-react";
const { wallet } = useWallet();
const solanaAdapterResult = await executeTransaction({
quote: quotes.data.quotes[0],
walletAdapter: wallet,
});
// 3. Cosmos Examples
// Using CosmJS with Keplr
import { SigningStargateClient } from "@cosmjs/stargate";
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
// For standard Cosmos chains
const getStargateClient = async () => {
if (!window.keplr) throw new Error("Keplr not installed");
await window.keplr.enable("cosmoshub-4"); // or your chain ID
const offlineSigner = window.keplr.getOfflineSigner("cosmoshub-4");
const client = await SigningStargateClient.connectWithSigner(
"https://rpc.cosmos.network", // your RPC endpoint
offlineSigner
);
return client;
};
const cosmosResult = await executeTransaction({
quote: quotes.data.quotes[0],
cosmosClient: await getStargateClient(),
});
// For CosmWasm chains (e.g., Terra, Secret Network)
const getCosmWasmClient = async () => {
if (!window.keplr) throw new Error("Keplr not installed");
await window.keplr.enable("phoenix-1"); // or your chain ID
const offlineSigner = window.keplr.getOfflineSigner("phoenix-1");
const client = await SigningCosmWasmClient.connectWithSigner(
"https://terra-rpc.example.com", // your RPC endpoint
offlineSigner
);
return client;
};
const cosmWasmResult = await executeTransaction({
quote: quotes.data.quotes[0],
cosmosClient: await getCosmWasmClient(),
});onStatusUpdate
onCreateTxComplete
Create TransactiononNextTxComplete
Get Raw Transaction To ExecuteonSignComplete
Last updated