• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdevelopment

use-modular-wallets

プラグイン
circle-skills
ソース
GitHub で見る ↗
説明

Circle Modular Wallets SDK(モジュール型暗号資産ウォレットのツール)を使用して、パスキー認証(生体認証や端末固有の認証)、手数料無料トランザクション(ガス代を払わずに処理を実行)、拡張可能なモジュール構造に対応したウォレットを構築します。 **次のような場合に使用:** - パスキーベース(WebAuthn/ウェブ標準の認証技術)での登録とログインでウォレットを作成する - Circle Gas Station(手数料負担サービス)のペイマスター機能を使ってガス代無料のトランザクションを送信する - 複数のトランザクションをひとつのユーザー操作にまとめて実行する - BIP-39ニーモニックフレーズ(バックアップ用の復旧フレーズ)を使ったパスキー復旧を実装する - マルチシグ(複数署名)、サブスクリプション、セッションキー(一時的なアクセス権限)などのカスタムモジュールで高度なオンチェーン(ブロックチェーン上の)ウォレットを構築する **トリガー対応:** MSCA、パスキー認証、WebAuthn、ペイマスター、Gas Station、ERC-4337、ERC-6900、toCircleSmartAccount、toModularTransport、sendUserOperation、2D nonce、パスキー復旧、EIP-1193プロバイダー

原文を表示

Build crypto wallets using Circle Modular Wallets SDK with passkey authentication, gasless transactions, and extensible module architecture. Use when: creating crypto wallets with passkey-based (WebAuthn) registration and login, sending gasless transactions using Circle Gas Station paymaster, batching multiple transactions into a single user operation, implementing passkey recovery using BIP-39 mnemonic phrases, building advanced onchain wallets with custom modules (multisig, subscriptions, session keys). Triggers on: MSCA, passkey authentication, WebAuthn, paymaster, Gas Station, ERC-4337, ERC-6900, toCircleSmartAccount, toModularTransport, sendUserOperation, 2D nonce, passkey recovery, EIP-1193 provider.

ユースケース
  • パスキー認証でウォレットを作成・ログインする
  • ガス代無料のトランザクションを送信する
  • 複数トランザクションを一度に実行する
  • パスキーのバックアップ・復旧を実装する
  • マルチシグなどのカスタムモジュール機能を構築する
本文(日本語訳)

モジュラーウォレット(Modular Wallets)

概要

モジュラーウォレットは、インストール可能なモジュールによって機能を拡張できる柔軟なスマートコントラクト账(MSCA)です。ERC-4337(アカウント抽象化:ユーザーが複数の認証方式を選べる仕組み)とERC-6900(モジュール型スマートコントラクト枠組み)に基づいており、パスキー認証、ガス代不要の取引、複数の操作をまとめて実行する機能、およびカスタムロジックモジュール(マルチシグ、サブスクリプション、セッションキー)に対応しています。MSCAは遅延デプロイ方式で実装されているため、アカウント作成にかかるガス代は最初の送信取引が実行されるまで先延ばしされます。

前提条件とセットアップ

インストール

npm install @circle-fin/modular-wallets-core viem

パスキー復旧機能を使う場合は、以下もインストール:

npm install bip39

環境変数

モジュラーウォレットをセットアップする際、プロジェクトの環境ファイルに以下を記入または追加してください:

# .env.local (Next.js) または .env (Vite)
# Console → Keys → Client Keys から Client Key をコピーして貼り付け(一度だけ表示; TEST_API_KEY: で始まる)
NEXT_PUBLIC_CLIENT_KEY=
NEXT_PUBLIC_CLIENT_URL=https://modular-sdk.circle.com/v1/rpc/w3s/buidl
VITE_CLIENT_KEY=
VITE_CLIENT_URL=https://modular-sdk.circle.com/v1/rpc/w3s/buidl

Next.js を使う場合は NEXT_PUBLIC_* のペアを、Vite を使う場合は VITE_* のペアを使用してください。両方を使わないでください。Client URL は固定値です。ユーザーに Console からコピーするよう求めないでください。チェーン固有のパス(例: /arcTestnet)は、環境変数ではなくコード内の toModularTransport で追加します。

SDK を使う前に、Console のセットアップを完了してください:

  1. Console → Keys → Client Keys で Client Key を作成
  2. パスキードメイン(パスキーはドメインに紐付く)を設定

クイックリファレンス

対応しているブロックチェーン

チェーン メインネット テストネット
Arc 非対応 対応
Arbitrum 対応 対応
Avalanche 対応 対応
Base 対応 対応
Monad 対応 対応
Optimism 対応 対応
Polygon 対応 対応
Unichain 対応 対応

最新の対応ブロックチェーン一覧: https://developers.circle.com/wallets/account-types.md (MSCA のチェーン制限は下記ルールを参照)

Transport(通信経路)の URL パスセグメント

toModularTransport の URL にはクライアント URL にチェーン固有のパスセグメントを追加する必要があります:

チェーン メインネットパス テストネットパス
Arbitrum /arbitrum /arbitrumSepolia
Arc -- /arcTestnet
Avalanche /avalanche /avalancheFuji
Base /base /baseSepolia
Monad /monad /monadTestnet
Optimism /optimism /optimismSepolia
Polygon /polygon /polygonAmoy
Unichain /unichain /unichainSepolia

例: Polygon Amoy テストネットの場合は toModularTransport(\${clientUrl}/polygonAmoy`, clientKey)`

中核となる概念

  • MSCA(モジュール型スマートコントラクト账) -- インストール可能なモジュールで機能を拡張したスマートコントラクト账(スマートフォンのアプリのようなもの)。オーナーシップは単一オーナー、複数オーナー、パスキー、またはマルチシグ方式に対応。

  • パスキー transport 対 モジュラー transport -- toPasskeyTransport は WebAuthn 認証情報操作(登録・ログイン)を処理します。toModularTransport は特定チェーンのバンドラー(トランザクションをまとめる仲介役)およびパブリック RPC 呼び出しを処理します。用途が異なる独立した通信経路です。

  • ガススポンサーシップ -- ユーザー操作の呼び出しで paymaster: true を渡すと、Circle ガスステーション経由でガス代を肩代わりできます。エンドユーザーはガス代を負担しません。

  • 複数操作のバッチ処理 -- 複数の呼び出しを sendUserOperation の calls パラメータに配列として渡すことで、単一のユーザー操作にまとめられます。

  • 2次元ノンス -- 異なるノンス値を使って、独立したユーザー操作の並列実行を可能にします。

  • USDC は 6 桁 -- USDC 送金額をエンコードする場合は parseUnits(value, 6) を使用してください(18 ではなく)。

  • 認証情報の永続化 -- パスキー認証情報(P256Credential)はセッション保持のため永続保存(例:httpOnly クッキー)され、リロード時に復元される必要があります。

実装パターン

注記: リファレンスコードの例では、動作確認用に localStorage を使用しています。本番環境では localStorage を使用しないでください。

ユーザーのリクエストに応じて、対応するリファレンスを読んでください:

  • references/circle-smart-account.md -- パスキー登録・ログイン、スマートアカウント作成、ガス代不要の USDC 送金、複数操作のバッチ処理

  • references/passkey-recovery.md -- BIP-39 ニーモニック(復旧用フレーズ)による復旧セットアップと、パスキーを紛失した場合の復旧実行

ユーザー操作のライフサイクル

sendUserOperation で送信されたユーザー操作は、非同期の状態遷移に従います。SDK の waitForUserOperationReceipt は自動的にポーリング処理を行います。状態を直接クエリする場合は、List User Operations APIを使用してください。

正常な流れ: SENT → CONFIRMED → COMPLETE

状態:

  • SENT -- バンドラーに送信され、ブロック内への含有を待機中。
  • CONFIRMED -- ブロック内に含有され、確定を待機中。
  • COMPLETE -- ブロックチェーン上で確定。
  • FAILED -- ユーザー操作が失敗したか、回復不可能なエラーが発生。errorReason と revertReason を確認してください。

FAILED 時のエラー理由:

  • FAILED_ON_CHAIN -- ブロックチェーン実行中にトランザクションが戻った。
  • FAILED_REPLACED -- ユーザー操作が置き換わった(例:同じノンス値の高ガス代操作による)。

エラーハンドリング

エラーコード 意味 対処法
NotAllowedError ユーザーがパスキープロンプトをキャンセルした、またはタイムアウト ユーザーに再度促す。ログイン時は、このドメイン向けの認証情報が存在することを確認
SecurityError パスキードメイン不一致 -- 異なるオリジンに紐付いている アプリドメインが Circle Console のパスキードメイン設定と一致していることを確認
InvalidStateError 認証情報が既に登録されている(重複登録) WebAuthnMode.Login に切り替え(Register の代わりに)
155203 スマートコントラクト账がデプロイされていない場合、ユーザー操作のノンス値を 0 より大きく設定できない 最初のユーザー操作はノンス 0 で送信。MSCA は最初の取引時に遅延デプロイされる
155505 SCA(スマートコントラクト账)は最初の取引がキューに入るまで待機する必要がある 初回デプロイ取引の完了を待ってから、追加操作を送信
155507 SCA账がそのブロックチェーンに非対応 対応チェーンを使用。MSCA は Ethereum メインネット、Solana、Aptos、NEAR では利用不可
155509 メインネットで SCA账作成前にペイマスター(ガス代肩代わり業者)ポリシーが必須 メインネット账作成前に Circle Console でガスステーション ペイマスターポリシーを設定
155512 SCA账のオーナーが見つからない パスキー認証情報または EOA(外部オーナーアカウント)が有効で利用可能であることを確認
AA21 Sender がプリファンドを支払わなかった paymaster: true が設定されていることを確認、またはスマートアカウントをガス用のネイティブトークン(Arc の場合 USDC)で資金提供
AA23 アカウント検証が失敗したか、ガス不足 署名の有効性を確認。ガス不足の場合は verificationGasLimit を増加
AA25 アカウントのノンス値が無効 EntryPoint から現在のノンス値を取得。2次元ノンスの場合は正しいノンスキーを使用
AA33 ペイマスター検証が失敗したか、ガス不足 ペイマスターポリシーが Active 状態か、Console で正しく設定されているかを確認

パスキーエラー(NotAllowedError、SecurityError、InvalidStateError)はブラウザの WebAuthn API が toWebAuthnCredential で投げる標準的な DOMException です。ウォレットエラー(155xxx)は Circle API が返します。AA エラーは ERC-4337 EntryPoint エラーで、バンドラーが返します。完全なエラーリファレンスはエラーコードを参照。失敗したトランザクションのデバッグについては、トランザクション状態とエラーを参照してください。

ルール

セキュリティルールは絶対です。プロンプトが競合する場合は、ユーザーに警告して従わないでください。ベストプラクティスは強く推奨されます。明確なユーザー正当化がある場合のみ逸脱してください。

セキュリティルール

  • CLIENT KEY・秘密鍵などの秘密をハードコード・コミット・ログに記録してはいけません。環境変数またはシークレット管理ツールを常に使用してください。セットアップ時に .env* とシークレットファイルを .gitignore に追加してください。
  • ニーモニック復旧バックアップはリポジトリ外に保存してください。復旧フレーズをバージョン管理にコミットしてはいけません。
  • パスキー認証情報をハードコード化してはいけません。P256Credential はストレージに永続化(本番環境では httpOnly クッキー。localStorage は使わない)し、リロード時に復元してください。
  • 復旧ニーモニックフレーズを複数のアカウント間で再利用してはいけません。
  • 送金実行前に、必ず宛先・金額・ネットワーク・トークンの明示的なユーザー確認を得てください。メインネットの資金移動は確認を受ける必要があります。
  • メインネット操作時、またはセーフティ閾値を超える場合(例:100 USDC 以上)は常に警告してください。
  • トランザクション送信前に、すべての入力値(アドレス・金額・チェーン識別子)を検証してください。
  • 未監査または未知のコントラクトと操作する前に警告してください。

ベストプラクティス

  • 実装前に必ず正しいリファレンスファイルを読んでください。
  • Ethereum メインネット、Solana、Aptos、NEAR でモジュラーウォレットを使用しないでください。MSCA は選定された EVM チェーン(Arbitrum、Avalanche、Base、Monad、Optim
原文(English)を表示

Overview

Modular Wallets are flexible smart contract accounts (MSCAs) that extend functionality through installable modules. Built on ERC-4337 (account abstraction) and ERC-6900 (modular smart contract framework), they support passkey authentication, gasless transactions, batch operations, and custom logic modules (multisig, subscriptions, session keys). MSCAs are lazily deployed -- gas fees for account creation are deferred until the first outbound transaction.

Prerequisites / Setup

Installation

npm install @circle-fin/modular-wallets-core viem

For passkey recovery, also install:

npm install bip39

Environment Variables

Write or merge into the project's env file when scaffolding Modular Wallets:

# .env.local (Next.js) or .env (Vite)
# Paste your Client Key from Console → Keys → Client Keys (shown once; starts with TEST_API_KEY:)
NEXT_PUBLIC_CLIENT_KEY=
NEXT_PUBLIC_CLIENT_URL=https://modular-sdk.circle.com/v1/rpc/w3s/buidl
VITE_CLIENT_KEY=
VITE_CLIENT_URL=https://modular-sdk.circle.com/v1/rpc/w3s/buidl

Use the NEXT_PUBLIC_* pair for Next.js or the VITE_* pair for Vite — not both. Client URL is fixed — do not ask the user to copy it from Console. Chain paths (e.g. /arcTestnet) are appended in code via toModularTransport, not in the env var.

Before using the SDK, complete the Console Setup:

  1. Console → Keys → Client Keys — create a Client Key
  2. Configure the Passkey Domain (passkeys are domain-bound)

Quick Reference

Supported Chains

Chain Mainnet Testnet
Arc No Yes
Arbitrum Yes Yes
Avalanche Yes Yes
Base Yes Yes
Monad Yes Yes
Optimism Yes Yes
Polygon Yes Yes
Unichain Yes Yes

For the latest supported blockchains: https://developers.circle.com/wallets/account-types.md (MSCA chain restrictions are in Rules below.)

Transport URL Path Segments

The toModularTransport URL requires the chain path segment appended to the client URL:

Chain Mainnet Path Testnet Path
Arbitrum /arbitrum /arbitrumSepolia
Arc -- /arcTestnet
Avalanche /avalanche /avalancheFuji
Base /base /baseSepolia
Monad /monad /monadTestnet
Optimism /optimism /optimismSepolia
Polygon /polygon /polygonAmoy
Unichain /unichain /unichainSepolia

Example: toModularTransport(\${clientUrl}/polygonAmoy`, clientKey)` for Polygon Amoy testnet.

Core Concepts

  • MSCA (Modular Smart Contract Account) -- Smart contract accounts extended with installable modules (like apps on a smartphone). Ownership can be single owner, multi-owner, passkeys, or multi-sig.
  • Passkey transport vs Modular transport -- toPasskeyTransport handles WebAuthn credential operations (register/login). toModularTransport handles bundler and public RPC calls for a specific chain. They are separate transports with different purposes.
  • Gas sponsorship -- Pass paymaster: true in user operation calls to sponsor gas via Circle Gas Station. End users pay zero gas fees.
  • Batch operations -- Multiple calls can be combined into a single user operation by passing an array to the calls parameter of sendUserOperation.
  • 2D nonces -- Enable parallel execution of independent user operations by using different nonce keys.
  • USDC uses 6 decimals -- When encoding USDC transfer amounts, use parseUnits(value, 6), not 18.
  • Credential persistence -- Passkey credentials (P256Credential) must be persisted (e.g., httpOnly cookies) and restored on reload to maintain the user session.

Implementation Patterns

Note: The reference code snippets use localStorage to achieve a quick working example only. Do not use localStorage in production.

READ the corresponding reference based on the user's request:

  • references/circle-smart-account.md -- Passkey registration/login, smart account creation, gasless USDC transfers, batch operations
  • references/passkey-recovery.md -- BIP-39 mnemonic recovery setup and execution when a passkey is lost

User Operation Lifecycle

User operations submitted via sendUserOperation follow an asynchronous state machine. The SDK's waitForUserOperationReceipt handles polling automatically. To query states directly, use the List User Operations API.

Happy path: SENT -> CONFIRMED -> COMPLETE

States:

  • SENT -- Submitted to the bundler, awaiting inclusion in a block.
  • CONFIRMED -- Included in a block, awaiting finality.
  • COMPLETE -- Finalized on-chain.
  • FAILED -- User operation reverted or encountered an unrecoverable error. Check errorReason and revertReason.

Error reasons on FAILED:

  • FAILED_ON_CHAIN -- Transaction reverted during blockchain execution.
  • FAILED_REPLACED -- User operation was replaced (e.g., by a higher-fee operation with the same nonce).

Error Handling

Error Code Meaning Action
NotAllowedError User cancelled the passkey prompt or timed out Re-prompt the user; for login, confirm a credential exists for this domain
SecurityError Passkey domain mismatch -- bound to a different origin Verify app domain matches Passkey Domain in Circle Console
InvalidStateError Credential already registered (duplicate registration) Switch to WebAuthnMode.Login instead of Register
155203 User op nonce cannot be >0 when smart contract wallet hasn't been deployed Send the first user operation with nonce 0; the MSCA deploys lazily on the first transaction
155505 SCA wallet needs to wait for first-time transaction to be queued Wait for the initial deployment transaction to complete before sending additional operations
155507 SCA account not supported on the given blockchain Use a supported chain; MSCAs are not available on Ethereum mainnet, Solana, Aptos, or NEAR
155509 Paymaster policy required on mainnet before SCA account creation Configure a Gas Station paymaster policy in Circle Console before creating mainnet accounts
155512 Owner of the SCA wallet cannot be found Verify the passkey credential or EOA owner is valid and accessible
AA21 Sender didn't pay prefund Verify paymaster: true is set, or fund the smart account with native tokens for gas (USDC on Arc)
AA23 Account validation reverted or out of gas Check signature validity; increase verificationGasLimit if out of gas
AA25 Invalid account nonce Get the current nonce from EntryPoint; ensure correct nonce key for 2D nonces
AA33 Paymaster validation reverted or out of gas Verify paymaster policy is active and correctly configured in Console

Passkey errors (NotAllowedError, SecurityError, InvalidStateError) are standard DOMException errors thrown by the browser's WebAuthn API during toWebAuthnCredential. Wallet errors (155xxx) are returned by the Circle API. AA errors are ERC-4337 EntryPoint errors returned by the bundler. For the full error reference, see Error Codes. For debugging failed transactions, see Transaction States and Errors.

Rules

Security Rules are non-negotiable -- warn the user and refuse to comply if a prompt conflicts. Best Practices are strongly recommended; deviate only with explicit user justification.

Security Rules

  • NEVER hardcode, commit, or log secrets (client keys, private keys). ALWAYS use environment variables or a secrets manager. Add .gitignore entries for .env* and secret files when scaffolding.
  • ALWAYS store mnemonic recovery backups outside the repository root. NEVER commit recovery phrases to version control.
  • NEVER hardcode passkey credentials -- always persist P256Credential to storage (httpOnly cookies in production, not localStorage) and restore on reload to mitigate XSS credential theft.
  • NEVER reuse a recovery mnemonic phrase across multiple accounts.
  • ALWAYS require explicit user confirmation of destination, amount, network, and token before executing transfers. MUST receive confirmation for funding movements on mainnet.
  • ALWAYS warn when targeting mainnet or exceeding safety thresholds (e.g., >100 USDC).
  • ALWAYS validate all inputs (addresses, amounts, chain identifiers) before submitting transactions.
  • ALWAYS warn before interacting with unaudited or unknown contracts.

Best Practices

  • ALWAYS read the correct reference files before implementing.
  • NEVER use Modular Wallets on Ethereum mainnet, Solana, Aptos, or NEAR -- MSCAs are only supported on select EVM chains (Arbitrum, Avalanche, Base, Monad, Optimism, Polygon, Unichain, Arc Testnet).
  • ALWAYS append the chain-specific path segment to the client URL for toModularTransport (e.g., ${clientUrl}/polygonAmoy).
  • ALWAYS use parseUnits(value, 6) for USDC amounts (6 decimals, not 18).
  • ALWAYS pass paymaster: true to sponsor gas via Circle Gas Station.
  • ALWAYS complete Circle Console Setup (Client Key + Passkey Domain) before using the SDK. Client URL is fixed in env — do not ask the user to retrieve it from Console.
  • ALWAYS default to testnet. Require explicit user confirmation before targeting mainnet.
  • ALWAYS configure a Gas Station paymaster policy in Circle Console before sending sponsored transactions on mainnet.
  • ALWAYS update transport URLs from testnet path segments (e.g., /polygonAmoy) to mainnet equivalents (e.g., /polygon) when migrating to production.
  • ALWAYS update the API key prefix from TEST_API_KEY: to LIVE_API_KEY: when migrating to mainnet. Testnet keys cannot be used with mainnets.
  • ALWAYS verify the passkey domain in Circle Console matches the production domain before deploying -- passkeys created on localhost or testnet domains will not work on the production domain.

Alternatives

  • Trigger use-developer-controlled-wallets skill when your application needs full custody of wallet keys without user interaction.
  • Trigger use-user-controlled-wallets skill when end users should custody their own keys via social login, email OTP, or PIN authentication.

Reference Links

  • Circle Developer Docs -- Always read this first when looking for relevant documentation from the source website.

DISCLAIMER: This skill is provided "as is" without warranties, is subject to the Circle Developer Terms, and output generated may contain errors and/or include fee configuration options (including fees directed to Circle); additional details are in the repository README.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。