Skip to main content
A deposit moves an ERC-20 asset from the user’s wallet into a BoringVault and mints share tokens back. The flow is the same regardless of vault:
  1. Call client.core.authorization.detect(...) to discover whether the deposit asset needs a permit signature, a separate approve transaction, or already has sufficient allowance.
  2. Handle the three response shapes (permit / approval / already_approved).
  3. Call client.amplify.deposit.prepare(...) to get ABI-encoded calldata.
  4. Submit the returned transaction with the user’s wallet.
Throughout this guide, client refers to a singleton AmplifyClient created on the server — see Project setup for the wiring. All token amounts are base-units decimal strings; the SDK does no decimal parsing.
See the AI Coding Reference for the full parameter list on every method shown here.

Step 1: Decide on permit vs. approval

The response is a discriminated union on method:
1

Branch on auth.method

2

2a — Permit path

For permit-supporting tokens (USDC mainnet, DAI, most modern ERC-20s with EIP-2612), sign the typed data with viem and forward the signature to the backend. The primaryType is always 'Permit'.
With wagmi:
3

2b — Approval path

When the token does not support permit (or you want to force a standard ERC-20 flow), the backend returns a ready-to-submit approvalTransaction containing ABI-encoded approve() calldata. Submit it to the deposit asset address and wait for the receipt before calling prepare.
Always wait for the approval receipt before submitting the deposit. If the deposit lands before the approval is mined, the deposit transaction will revert with an ERC20: insufficient allowance style error.
4

2c — Already approved

5

Step 3 — Prepare the deposit

Required fields:
  • vaultAddress — BoringVault contract address.
  • depositAsset — ERC-20 token address you’re depositing.
  • depositAmount — amount in base units (decimal string).
  • userAddress — wallet that signs and submits the deposit. Also the default share recipient when to is omitted.
  • chainId — EVM chain ID.
Optional fields:
  • to — destination address that receives the vault shares. Defaults to userAddress.
  • permitSignature + permitDeadline — required together when you came through the permit branch in Step 2a.
  • responseFormat'encoded' (default), 'full', or 'structured'. Pass 'full' to also receive abi, functionName, and args.
6

Step 4 — Submit the transaction

tx.value is a decimal string (usually "0" for ERC-20 deposits); cast to BigInt before passing to viem/wagmi.

End-to-end example

Converting user input to base units

Error handling

When surfacing errors to the browser, log err.body and err.rawResponse server-side and return a generic message to the client.

Next steps