# Verify the calldata before you sign: the check that refuses a changed swap

> Canonical: https://blazephoenix.xyz/learn/verify-the-calldata-before-you-sign/
> License: CC BY-NC-ND 4.0 (attribution + link) · © 2026 BlazePhoenix
> Updated: 2026-11-20

Run verifySwapExactIn from the BlazePhoenix SDK on the calldata you are about to sign. It decodes the bytes and compares them with your request. A changed recipient or a lowered minimum is refused with calldata_mismatch.

Short answer: verifySwapExactIn, exported by the BlazePhoenix SDK, decodes a swapExactIn call with the Router ABI and compares each field with the request you pass in. If anything differs, it throws a BlazeError with the code calldata_mismatch and lists every difference. It is a pure function: no network, no key.

This page shows what it compares, a real run on Base mainnet in which the calldata was edited twice and refused twice (10 USDC to AAPLc; nothing signed, nothing sent, no key), where the SDK calls it for you, and what it does not do.

## What the check compares

You give it the calldata and a SwapExpectation: what you asked for. It decodes the calldata and checks these fields, and it collects every mismatch before it throws.

## The test: change one field

Build a plan on your own RPC, build the expectation from your own request and the plan, and check the honest bytes. Then edit the recipient word inside plan.tx.data and check again. The recipient and the demo address below are placeholders, and nothing is sent.

Lowering the encoded minimum to 1 is refused in the same way. Each edit changes exactly one 32-byte word of the calldata, which is the kind of change a tampered frontend or a swapped payload would make.

```
import { BlazePhoenix, verifySwapExactIn } from '@blazephoenix/sdk';

const USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
const AAPLc = '0xb200000000000000000000C2e324d24d7eEcd1fb';
const RECIPIENT = '0x1111111111111111111111111111111111111111'; // demo address

const blaze = new BlazePhoenix({ rpc: { base: 'YOUR_RPC' } });

const plan = await blaze.buildSwap({
  chain: 'base',
  tokenIn: USDC,
  tokenOut: AAPLc,
  amountIn: '10000000',          // 10 USDC, 6 decimals
  version: '1',
  recipient: RECIPIENT,
  from: 'YOUR_ADDRESS',
  simulate: true,
  slippageBps: 50,
  blockNumber: 59967185n,        // pin the read to one block
});

const want = {
  tokenIn: USDC,
  tokenOut: AAPLc,
  amountIn: 10000000n,
  recipient: RECIPIENT,
  deadline: plan.deadline,
  minOutAtLeast: plan.minOut,
};

verifySwapExactIn(plan.tx.data, want); // honest bytes: passes

// change the recipient word inside the calldata
const tampered = plan.tx.data.replace(
  RECIPIENT.slice(2),
  '2222222222222222222222222222222222222222',
);

try {
  verifySwapExactIn(tampered, want);
} catch (e) {
  console.log(e.code, e.message); // calldata_mismatch
}
```

## What came back

The output below is from the published SDK 1.6.0 on Base mainnet, on a public RPC, with the read pinned to block 59967185. The plan quoted amountOut 2840251 (0.02840251 AAPLc, which has 8 decimals) and minOut 2826050.

## Where it runs by itself, and where you run it

buildSwap calls the same check on its own only on the Quoter 2.x path, where the Quoter encodes the calldata and the SDK checks it field by field against what you asked. In this run the version was 1, the only generation deployed on Base that day (asking for version 2 returns not_deployed, deployed: 1.0.0). On that path the SDK encodes the calldata itself, and the plan reports encodedBy sdk.

So in the run above, the check was called by hand. Its error text begins with Quoter calldata refused even when the SDK did the encoding, because the text is fixed. Run it before you sign, on the calldata you hold.

## What it does not do

It compares the calldata with the request you give it, and nothing else. If you leave minOutAtLeast out of the expectation, a low minimum taken from the plan itself passes, so set your own floor. It does not simulate the swap and it does not say whether the swap is a good one.

Run it on the exact string you are about to sign, immediately before you sign it. If it throws, do not sign: it fails closed. To try it, npm i @blazephoenix/sdk, and see /agents for the rest of the toolkit.

**Verify it yourself:** Install @blazephoenix/sdk, build a plan on your own RPC, change the recipient word in plan.tx.data, then call verifySwapExactIn(data, want). Expect calldata_mismatch with a line naming the recipient. Lower the encoded minimum to 1 and expect calldata_mismatch with userMinOut 1 < required. Run it on the exact bytes you will sign.

Related: https://blazephoenix.xyz/learn/two-entry-points-calldata-trust/ · https://blazephoenix.xyz/learn/signing-vs-sending/ · https://blazephoenix.xyz/learn/minimum-output-explained/ · https://blazephoenix.xyz/learn/api-sdk-mcp/
