Encode for External Wallets
When to use encode methods
encodeFillOrder()
import { ethers } from 'ethers';
import { ThetanutsClient } from '@thetanuts-finance/thetanuts-client';
const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');
const client = new ThetanutsClient({ chainId: 8453, provider });
// Fetch the order (no signer needed for this part)
const orders = await client.api.fetchOrders();
const order = orders[0];
// Encode the fill (no signer needed)
const { to, data } = client.optionBook.encodeFillOrder(
order,
10_000000n, // 10 USDC (optional — omit for max fill)
'0x92b8ac05b63472d1D84b32bDFBBf3e1887331567', // optional referrer
);Sending with viem/wagmi
Sending with ethers.js signer directly
encodeSwapAndFillOrder()
Approval encoding for external wallets
Referrer in encode methods
See Also
Last updated

