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

> ## Agent Instructions
> Before reading these docs, install the relevant Circle Skill to get pre-loaded context — skills are LLM-optimized and cover architecture decisions, correct flows, and common pitfalls. In Claude Code: run /plugin marketplace add circlefin/skills then /plugin install circle-skills@circle. With Vercel Skills CLI: run npx skills add circlefin/skills. Available skills: use-usdc https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-usdc/SKILL.md (balances, transfers, approvals on EVM and Solana); EURC has no skill — see https://developers.circle.com/stablecoins/what-is-eurc.md; bridge-stablecoin https://github.com/circlefin/skills/blob/master/plugins/circle/skills/bridge-stablecoin/SKILL.md (crosschain transfers via CCTP, USDC, EURC, and third-party assets); use-arc https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-arc/SKILL.md (Arc chain config, contract deployment, USDC bridging — Arc docs: https://docs.arc.io/llms.txt); use-circle-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-circle-wallets/SKILL.md (choose wallet type); use-developer-controlled-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-developer-controlled-wallets/SKILL.md (custodial wallets for payouts and treasury); use-user-controlled-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-user-controlled-wallets/SKILL.md (embedded wallets with Web2 login); use-modular-wallets https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-modular-wallets/SKILL.md (smart contract wallets with passkeys and ERC-4337); use-gateway https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-gateway/SKILL.md (unified USDC balance, nanopayments); use-smart-contract-platform https://github.com/circlefin/skills/blob/master/plugins/circle/skills/use-smart-contract-platform/SKILL.md (deploy, interact, monitor contracts). Pair any skill with the Circle MCP server for live SDK signatures, contract addresses, and chain IDs: {"mcpServers":{"circle":{"url":"https://api.circle.com/v1/codegen/mcp"}}}.
> Read the product overview first. Each product has an overview explaining when and why to use it. Read it before quickstarts.
> Pick the right wallet type. Developer-controlled (you hold keys), user-controlled (end user holds keys via PIN/social login), or modular (smart contract wallets with passkeys). See https://developers.circle.com/wallets.md.
> Use CCTP V2 for crosschain transfers. CCTP natively transfers USDC and EURC via burn-and-mint, and supports permissionless wrapping of third-party assets via lock-and-mint. V1 is legacy; always use V2 unless V1 is specified or the chain requires it (Noble, Sui, and Aptos still require V1). Migration guide: https://developers.circle.com/cctp/migration-from-v1-to-v2.md.
> Use Bridge Kit for frontend bridging. Wraps CCTP with a simpler SDK for user-facing apps. Use CCTP directly for backend transfers.
> Gas Station vs Paymaster. Gas Station sponsors gas for Circle Wallet transactions. Paymaster lets users pay gas in USDC. Different use cases — read both overviews.
> Gateway Nanopayments for sub-cent payments. Gasless USDC micropayments down to $0.000001 via x402 and batched settlement. For pay-per-request APIs, AI agent payments, streaming.
> Look up USDC addresses per chain. Never hardcode — use https://developers.circle.com/stablecoins/usdc-contract-addresses.md.
> Prefer SDKs over raw API calls. Node.js and Python SDKs handle auth, retries, and errors.
> API key required. Bearer token in Authorization header. Testnet and mainnet use separate keys and may use different base URLs depending on the product.
> Set up webhooks when available. Most operations are async. Webhooks deliver transaction confirmations and state changes.
> When calling list endpoints, paginate using pageSize and pageAfter until no nextPageAfter cursor is returned—stopping at the first page silently misses records.
> Building an AI agent? Start with the Agent Stack—Circle CLI, agent wallets, and nanopayments built for autonomous use cases: https://developers.circle.com/agent-stack.md.

# Batch and parallel user operations

> Combine multiple actions into a single user operation, or run independent operations in parallel using 2D nonces.

A user operation can carry one call or many. Batching packs several calls into
one operation that the smart account executes atomically. Parallelism uses 2D
nonces to submit independent operations concurrently so a slow one doesn't block
the others. These are two independent patterns, applicable on their own or
together.

The examples below use the `smartAccount` and `bundlerClient` returned by
[Create a modular wallet](/wallets/modular/create-a-modular-wallet).

## Batch calls in a single user operation

Pass multiple `calls` to `sendUserOperation`. The user signs once and the smart
account executes the entire array atomically. A common pattern is to bundle an
ERC-20 `approve` with the call that spends the allowance, so the user never has
a granted-but-unused approval sitting onchain.

<CodeGroup>
  ```typescript Web SDK (TypeScript) theme={null}
  import { encodeFunctionData, parseUnits } from "viem";

  const USDC = "0x..."; // USDC on Arc Testnet
  const spender = "0x..."; // contract that will pull USDC

  const userOpHash = await bundlerClient.sendUserOperation({
    calls: [
      {
        to: USDC,
        data: encodeFunctionData({
          abi: erc20Abi,
          functionName: "approve",
          args: [spender, parseUnits("100", 6)],
        }),
      },
      {
        to: spender,
        data: encodeFunctionData({
          abi: spenderAbi,
          functionName: "pullAndDeposit",
          args: [parseUnits("100", 6)],
        }),
      },
    ],
    paymaster: true,
  });
  ```

  ```swift iOS SDK (Swift) theme={null}
  Task {
      do {
          let userOpHash = try await bundlerClient.sendUserOperation(
              account: smartAccount,
              calls: [
                  EncodeCallDataArg(
                      to: USDC,
                      value: BigInt(0),
                      abiJson: ERC20_ABI,
                      functionName: "approve",
                      args: [spender, BigInt(100_000_000)]
                  ),
                  EncodeCallDataArg(
                      to: spender,
                      value: BigInt(0),
                      abiJson: SPENDER_ABI,
                      functionName: "pullAndDeposit",
                      args: [BigInt(100_000_000)]
                  ),
              ],
              paymaster: Paymaster.True()
          )
      } catch {
          print(error)
      }
  }
  ```

  ```kotlin Android SDK (Kotlin) theme={null}
  CoroutineScope(Dispatchers.IO).launch {
      try {
          val userOpHash = bundlerClient.sendUserOperation(
              context,
              smartAccount,
              arrayOf(
                  EncodeCallDataArg(
                      to = USDC,
                      value = BigInteger.ZERO,
                      functionName = "approve",
                      abiJson = ABI_ERC20,
                      args = arrayOf(spender, parseUnits("100", 6)),
                  ),
                  EncodeCallDataArg(
                      to = spender,
                      value = BigInteger.ZERO,
                      functionName = "pullAndDeposit",
                      abiJson = SPENDER_ABI,
                      args = arrayOf(parseUnits("100", 6)),
                  ),
              ),
              paymaster = Paymaster.True(),
          )
      } catch (e: Exception) {
          e.printStackTrace()
      }
  }
  ```

  ```java Android SDK (Java) theme={null}
  try {
      EncodeCallDataArg approveCall = new EncodeCallDataArg(
          USDC,
          BigInteger.ZERO,
          null,
          AbiConstantsKt.getABI_ERC20(),
          new Object[] { spender, parseUnits("100", 6) },
          "approve"
      );
      EncodeCallDataArg depositCall = new EncodeCallDataArg(
          spender,
          BigInteger.ZERO,
          null,
          SPENDER_ABI,
          new Object[] { parseUnits("100", 6) },
          "pullAndDeposit"
      );

      CompletableFuture<String> userOpHashFuture = new CompletableFuture<>();
      bundlerClient.sendUserOperation(
          context,
          smartAccount,
          new EncodeCallDataArg[] { approveCall, depositCall },
          new UserOperationV07(),
          new Paymaster.True(),
          new CustomContinuation<>(userOpHashFuture)
      );
      String userOpHash = userOpHashFuture.join();
  } catch (Exception e) {
      e.printStackTrace();
  }
  ```
</CodeGroup>

## Run independent operations in parallel

Externally owned accounts process transactions sequentially because each one
consumes the next integer nonce. Smart accounts use 2D nonces, a `nonceKey` plus
a nonce value. Operations with different `nonceKey` values are independent and
can land in any order, so a slow operation doesn't block a fast one.

Use parallel execution when:

* The user operations don't depend on each other's state.
* You want to submit multiple operations without waiting for each receipt.
* The operations are safe to land in any order.

For sequential dependencies (for example, swap A to B then swap B to C), keep
the default linear nonce by omitting `nonceKey` or passing `0`.

<Note>
  To submit operations in parallel, sign each with a distinct `nonceKey` greater
  than `0`, then send them concurrently. Don't `await` each receipt before
  sending the next, or you lose the benefit.
</Note>

<CodeGroup>
  ```typescript Web SDK (TypeScript) theme={null}
  // Each partial user operation specifies the calls it carries. Build the
  // array however your app produces them.
  type PartialUserOperation = Parameters<
    typeof bundlerClient.sendUserOperation
  >[0];
  const userOps: PartialUserOperation[] = [
    {
      calls: [{ to: "0x...", data: "0x..." }],
    },
    {
      calls: [{ to: "0x...", data: "0x..." }],
    },
  ];

  // Sign every user op first. Each gets a distinct nonceKey so they're
  // independent.
  const signedUserOps = await Promise.all(
    userOps.map(async (userOp, index) => {
      const nonce = await smartAccount.getNonce({ key: BigInt(index + 1) });
      const signature = await smartAccount.signUserOperation({
        ...userOp,
        nonce,
      });
      return { ...userOp, nonce, signature };
    }),
  );

  // Submit the signed ops concurrently. Don't await each receipt before
  // sending the next one.
  const hashes = await Promise.all(
    signedUserOps.map((userOp) =>
      bundlerClient.sendUserOperation({ smartAccount, ...userOp }),
    ),
  );
  ```

  ```swift iOS SDK (Swift) theme={null}
  Task {
      var signedUserOps: [UserOperationV07] = []

      for (index, userOp) in userOps.enumerated() {
          do {
              let nonceKey = userOp.nonce ?? BigInt(index + 1)
              let nonce = try await smartAccount.getNonce(key: nonceKey)
              var signedUserOp = userOp
              signedUserOp.nonce = nonce
              signedUserOp.signature = try await smartAccount.signUserOperation(
                  chainId: smartAccount.client.chain.chainId,
                  userOp: signedUserOp
              )
              signedUserOps.append(signedUserOp)
          } catch {
              print("Error signing user operation: \(error)")
          }
      }

      await withTaskGroup(of: Void.self) { group in
          for userOp in signedUserOps {
              group.addTask {
                  do {
                      let sendResult = try await bundlerClient.sendUserOperation(
                          account: smartAccount,
                          calls: nil,
                          partialUserOp: userOp
                      )
                      print(sendResult)
                  } catch {
                      print("Error sending user operation: \(error)")
                  }
              }
          }
      }
  }
  ```

  ```kotlin Android SDK (Kotlin) theme={null}
  val signedUserOps = mutableListOf<UserOperationV07>()

  userOps.forEachIndexed { index, userOp ->
      CoroutineScope(Dispatchers.IO).launch {
          try {
              val chain = ArcTestnet
              val nonceKey = userOp.nonce ?: BigInteger("${index + 1}")
              val nonce = smartAccount.getNonce(key = nonceKey)
              val signature = smartAccount.signUserOperation(
                  context,
                  chain.chainId,
                  userOp.copy(nonce = nonce),
              )
              signedUserOps.add(userOp.copy(nonce = nonce, signature = signature))
          } catch (error: Exception) {
              Log.e(TAG, "Error signing user operation at index $index: ${error.message}")
          }
      }
  }

  CoroutineScope(Dispatchers.IO).launch {
      val sendOperations = signedUserOps.map { userOp ->
          async {
              try {
                  bundlerClient.sendUserOperation(
                      context,
                      smartAccount,
                      calls = null,
                      partialUserOp = userOp,
                  )
              } catch (error: Exception) {
                  Log.e(TAG, "Error sending user operation: ${error.message}")
              }
          }
      }
      sendOperations.awaitAll()
  }
  ```

  ```java Android SDK (Java) theme={null}
  List<UserOperationV07> signedUserOps = new ArrayList<>();

  for (int i = 0; i < userOps.size(); i++) {
      try {
          UserOperationV07 userOp = userOps.get(i);
          BigInteger nonceKey = userOp.getNonce() == null
              ? BigInteger.valueOf(i + 1)
              : userOp.getNonce();

          CompletableFuture<BigInteger> nonceFuture = new CompletableFuture<>();
          smartAccount.getNonce(nonceKey, new CustomContinuation<>(nonceFuture));
          BigInteger nonce = nonceFuture.join();
          userOp.setNonce(nonce);

          CompletableFuture<String> signatureFuture = new CompletableFuture<>();
          smartAccount.signUserOperation(
              context,
              ArcTestnet.INSTANCE.getChainId(),
              userOp,
              new CustomContinuation<>(signatureFuture)
          );
          userOp.setSignature(signatureFuture.join());
          signedUserOps.add(userOp);
      } catch (Exception error) {
          Log.e(TAG, "Error signing user operation at index " + i + ": " + error.getMessage());
      }
  }

  List<CompletableFuture<String>> sendOperations = signedUserOps.stream()
      .map(userOp -> {
          CompletableFuture<String> userOpHashFuture = new CompletableFuture<>();
          try {
              bundlerClient.sendUserOperation(
                  context,
                  smartAccount,
                  null,                       // calls
                  userOp,                     // partialUserOp
                  new Paymaster.True(),
                  new CustomContinuation<>(userOpHashFuture)
              );
          } catch (Exception e) {
              userOpHashFuture.completeExceptionally(e);
          }
          return userOpHashFuture;
      })
      .collect(Collectors.toList());

  CompletableFuture.allOf(sendOperations.toArray(new CompletableFuture[0])).join();
  ```
</CodeGroup>
