# Custom delegate (sponsorCall)

If you use your **own** 7702 delegate (not `KryardDelegate`), build the calldata and
any inner delegate signature yourself, then use `sponsorCall`. The SDK signs only the
7702 authorization and submits — it makes no assumption about the delegate.

::: tip
`sponsorExecute` is just `sponsorCall` with the `KryardDelegate` calldata built for
you. Reach for `sponsorCall` when you have a bespoke delegate (for example, a sweep
delegate with its own typed-data signature scheme).
:::

## Usage

```ts
import { sponsorCall } from "@kryard/sdk";
import { encodeFunctionData } from "viem";

// You build the call to your delegate (e.g. SweepDelegate.sweep(order, sweepSig)).
const sweepData = encodeFunctionData({
  abi: SWEEP_DELEGATE_ABI,
  functionName: "sweep",
  args: [order, sweepSig],
});

const tx = await sponsorCall({
  client, signer,                  // signer only needs { address, signAuthorization }
  chainId, signWith,
  delegateAddress: SWEEP_DELEGATE, // the 7702 target the user authorizes
  data: sweepData,                 // your pre-built calldata
  // optional ERC-20 accounting (if your call reimburses the relayer in token):
  // gasToken: USDC, gasTokenAmount: skimmedGasInToken,
});
```

The relayer org's policy must **allowlist** your delegate address before it will
sponsor calls to it.

## Lower-level building blocks

For full control, the SDK also exposes pure helpers:

- `delegateDigest(...)` — the 32-byte digest the user personal-signs (mirrors the contract).
- `encodeExecute` / `encodeExecuteWithGasReimbursement` — `KryardDelegate` calldata.
- `buildSponsoredExecute(...)` / `buildSponsoredCall(...)` — assemble a relay submit
  body from already-signed pieces (pure, no network).
- `KryardRelayClient.submit` / `.get` — the raw relay route, X-Stamp authed.
