> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dzap.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Approve

> approve(), grant an on-chain ERC20 or Permit2 approval.

Once [Check Allowance](/sdk/approvals/check-allowance) determines a token needs an on-chain approval, call `approve()`:

```ts theme={null}
if (needsApproval) {
  await dzap.approve({
    chainId: 42161,
    signer: walletClient,
    sender: '0xUser',
    tokens: [{ address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', amount: '1000000' }],
    service: Services.trade,
    mode: ApprovalModes.AutoPermit,
    approvalTxnCallback: async ({ txnDetails, address }) => {
      // txnDetails: { txnHash: string; code: StatusCodes; status: TxnStatus }
      console.log('approval', address, txnDetails.status, txnDetails.txnHash);
    },
  });
}
```

`approvalTxnCallback` fires once per token (viem `WalletClient` signers only). If it returns a `TxnStatus` other than `success`, remaining tokens in the batch are skipped.

## Next steps

* [Check Allowance](/sdk/approvals/check-allowance), modes reference and recommended flow
* [Sign (gasless permits)](/sdk/approvals/sign)
