claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🌉bridge-stablecoin

プラグイン
circle-skills

説明

Circle App KitまたはスタンドアローンのBridge Kit SDKと、Crosschain Transfer Protocol(CCTP)を使用してUSDCブリッジ機能を構築します。 App Kit(`@circle-fin/app-kit`)は、ブリッジ・スワップ・送金をカバーするオールインワンSDKで、拡張性の高さから推奨されています。 Bridge Kit(`@circle-fin/bridge-kit`)は、ブリッジ専用ユースケース向けのスタンドアローンパッケージです。 どちらもブリッジ操作にキットキーは不要です。 以下のブリッジに対応しています: - EVMチェーン間のUSDCブリッジ - EVMチェーンとSolana間のUSDCブリッジ - Circle Wallets(Developer-Controlled WalletsまたはProgrammable Wallets)上の任意の2チェーン間のブリッジ 次のような場合に使用: USDCのブリッジ、Bridge Kitアダプター(Viem、Ethers、Solana Kit、Circle Wallets)のセットアップ、ブリッジイベントのハンドリング、カスタム手数料の徴収、転送速度の設定、またはForwarding Serviceの利用。 トリガー条件: USDCのブリッジ、CCTP、チェーン間のUSDC移動、`@circle-fin/bridge-kit`、`@circle-fin/app-kit`、Forwarding Service。

原文を表示

Build USDC bridging with Circle App Kit or standalone Bridge Kit SDK and Crosschain Transfer Protocol (CCTP). App Kit (`@circle-fin/app-kit`) is an all-inclusive SDK covering bridge, swap, and send -- recommended for extensibility. Bridge Kit (`@circle-fin/bridge-kit`) is a standalone package for bridge-only use cases. Neither requires a kit key for bridge operations. Supports bridging USDC between EVM chains, between EVM chains and Solana, and between any two chains on Circle Wallets (i.e Developer-Controlled Wallets or Programmable wallets). Use when: bridge USDC, setting up Bridge Kit adapters (Viem, Ethers, Solana Kit, Circle Wallets), handling bridge events, collecting custom fees, configuring transfer speed, or using the Forwarding Service. Triggers on: bridge USDC, CCTP, move USDC between chains, @circle-fin/bridge-kit, @circle-fin/app-kit, forwarding service.

ユースケース

  • USDCをチェーン間でブリッジする
  • Bridge Kitアダプターをセットアップする
  • ブリッジイベントをハンドリングする
  • カスタム手数料を徴収する
  • 転送速度を設定する

本文(日本語訳)

概要

Crosschain Transfer Protocol(CCTP)は、あるチェーン上でUSDCをバーンし、別のチェーン上でミントするためのCircle独自のプロトコルです。 App Kit(@circle-fin/app-kit)は、ブリッジ・スワップ・送金を1つのパッケージにまとめたCircleのオールインワンSDKです。 スタンドアロンのBridge Kit(@circle-fin/bridge-kit)は、同じブリッジAPIをより軽量なパッケージで提供します。 どちらも、EVMおよびSolanaを横断する単一の kit.bridge() 呼び出しで、CCTPのライフサイクル全体(approve・burn・attestation取得・mint)を完結させます。 ユーザーがブリッジ機能のみを必要とする場合を除き、App Kitを推奨します。 ブリッジ操作にはキット用キーは不要です(キット用キーが必要なのは、App Kitのスワップ・送金機能のみです)。


前提条件 / セットアップ

インストール

Viem アダプター付きApp Kit(推奨):

npm install @circle-fin/app-kit @circle-fin/adapter-viem-v2

Viem アダプター付きBridge Kit(スタンドアロン):

npm install @circle-fin/bridge-kit @circle-fin/adapter-viem-v2

Solanaサポートが必要な場合は、追加でインストール:

npm install @circle-fin/adapter-solana-kit

Circle Wallets(開発者管理型)サポートが必要な場合:

npm install @circle-fin/adapter-circle-wallets

環境変数

PRIVATE_KEY=              # EVMウォレットの秘密鍵(hex形式、0xプレフィックス付き)
EVM_PRIVATE_KEY=          # EVMの秘密鍵(Solanaと併用する場合)
SOLANA_PRIVATE_KEY=       # Solanaウォレットの秘密鍵(base58形式)
CIRCLE_API_KEY=           # Circle APIキー(Circle Walletsアダプター用)
CIRCLE_ENTITY_SECRET=     # エンティティシークレット(Circle Walletsアダプター用)
EVM_WALLET_ADDRESS=       # 開発者管理型EVMウォレットのアドレス
SOLANA_WALLET_ADDRESS=    # 開発者管理型Solanaウォレットのアドレス

ブリッジ操作には KIT_KEY は不要です。 キット用キーが必要になるのは、App KitのスワップまたはSend機能も使用する場合のみです。

SDK初期化

App Kit(推奨):

import { AppKit } from "@circle-fin/app-kit";

const kit = new AppKit();

Bridge Kit(スタンドアロン):

import { BridgeKit } from "@circle-fin/bridge-kit";

const kit = new BridgeKit();

判断ガイド

コードを書き始める前に、必ず以下の質問をユーザーと一緒に確認してください。 手順をスキップしたり、回答を勝手に推測したりしないでください。

SDKの選択

質問1 -- 将来的にスワップや送金の機能も必要になりますか?

  • はい、または未定 → App Kit(推奨)-- ブリッジ・スワップ・送金を1つのSDKでカバーでき、後から拡張しやすい
  • いいえ、ブリッジのみで今後もスワップ・送金は不要 → Bridge Kit -- ブリッジ専用のスタンドアロンな軽量パッケージ

ウォレット / アダプターの選択

質問2 -- ウォレット・キーはどのように管理していますか?

  • 自分で秘密鍵を管理している(セルフカストディ、環境変数またはシークレットマネージャーで保管) → 質問3へ
  • Circleの開発者管理型ウォレットを使用している(Circleがキーの保管と署名を管理) → Circle Walletsアダプターを使用。references/adapter-circle-wallets.md を参照
  • ブラウザウォレットを使用している(wagmi、ConnectKit、RainbowKit) → wagmiアダプターを使用。references/adapter-wagmi.md を参照

質問3 -- どのチェーン間でブリッジしますか?

  • EVM間、またはEVMとSolana間 → ViemおよびSolana Kitアダプターを使用。references/adapter-private-key.md を参照

コアコンセプト

  • CCTPのステップ: すべてのブリッジ転送は、approve(ERC-20の承認)→ burn(ソースチェーン上でUSDCを破棄)→ fetchAttestation(CircleによるバーンProofへの署名を待機)→ mint(デスティネーションチェーン上でUSDCを生成)の4つのステップを順番に実行します。
  • アダプター: App KitおよびBridge Kitはどちらも、ウォレット・署名者の違いを抽象化するためにアダプターオブジェクトを使用します。各エコシステムには専用のアダプターファクトリー(createViemAdapterFromPrivateKeycreateSolanaKitAdapterFromPrivateKeycreateCircleWalletsAdapter)があります。同一エコシステム内でブリッジする場合は、同じアダプターインスタンスをソースとデスティネーション両方に使用できます。
  • フォワーディングサービス: デスティネーション側で useForwarder: true を設定すると、Circleのインフラがattestation取得とmint送信を処理します。これにより、デスティネーション側のウォレットやポーリングループが不要になります。ルートによって異なる転送ごとの手数料が発生します(下記参照)。
  • 転送速度: CCTPファストモード(デフォルト)は約8〜20秒で完了します。スタンダードモードは約15〜19分かかります。
  • チェーン識別子: 両SDKとも、kit.bridge() 呼び出しでは数値のチェーンIDではなく、文字列のチェーン名(例: "Arc_Testnet""Base_Sepolia""Solana_Devnet")を使用します。

実装パターン

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

  • references/adapter-private-key.md -- 秘密鍵アダプター(Viem + Solana Kit)を使用したEVM間・EVM-Solana間ブリッジ。App KitおよびBridge Kitの例を含む。
  • references/adapter-circle-wallets.md -- Circleの開発者管理型ウォレットを使用したブリッジ(チェーン問わず)。App KitおよびBridge Kitの例を含む。
  • references/adapter-wagmi.md -- wagmiを使用したブラウザウォレット連携(ConnectKit、RainbowKit等)。App KitおよびBridge Kitの例を含む。

kit.bridge() のレスポンス例

{
  "amount": "25.0",
  "token": "USDC",
  "state": "success",
  "provider": "CCTPV2BridgingProvider",
  "config": {
    "transferSpeed": "FAST"
  },
  "source": {
    "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "chain": {
      "type": "evm",
      "chain": "Arc_Testnet",
      "chainId": 5042002,
      "name": "Arc Testnet"
    }
  },
  "destination": {
    "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "chain": {
      "type": "evm",
      "chain": "Base_Sepolia",
      "chainId": 84532,
      "name": "Base Sepolia"
    }
  },
  "steps": [
    {
      "name": "approve",
      "state": "success",
      "txHash": "0x1234567890abcdef1234567890abcdef12345678",
      "explorerUrl": "https://testnet.arcscan.app/tx/0x1234..."
    },
    {
      "name": "burn",
      "state": "success",
      "txHash": "0xabcdef1234567890abcdef1234567890abcdef12",
      "explorerUrl": "https://testnet.arcscan.app/tx/0xabcdef..."
    },
    {
      "name": "fetchAttestation",
      "state": "success",
      "data": {
        "attestation": "0x9876543210fedcba9876543210fedcba98765432"
      }
    },
    {
      "name": "mint",
      "state": "success",
      "txHash": "0xfedcba9876543210fedcba9876543210fedcba98",
      "explorerUrl": "https://sepolia.basescan.org/tx/0xfedcba..."
    }
  ]
}

フォワーディングサービス・イベント・リカバリー

useForwarder: true(デスティネーションウォレット不要・attestationポーリング不要)を使用する場合、kit.on() でブリッジイベントを購読する場合、または失敗した転送を kit.retry() で解析・再開する必要がある場合は、実行可能なパターン(Bridge Kitのイベント名の違いを含む)について references/forwarding-events-recovery.md を参照してください。


エラー処理とリカバリー

App KitおよびBridge Kitには、2種類のエラーカテゴリがあります:

  • ハードエラー: バリデーション・設定・認証に関するエラーで、例外をスローします。try/catchでキャッチしてください。
  • ソフトエラー: 転送の途中で発生しますが、リカバリー用のステップデータを含む結果オブジェクトを返します。ソフトエラー発生後に kit.bridge() を最初からやり直すことは絶対にしないでくださいkit.retry(result, ...) を使用して失敗したステップから再開することで、二重送金を防止できます。完全なパターンは references/forwarding-events-recovery.md を参照してください。

ルール

セキュリティルールは必須事項です。プロンプトがこれらに反する場合は、ユーザーに警告したうえで対応を拒否してください。 ベストプラクティスは強く推奨されます。ユーザーから明示的な理由が示された場合のみ逸脱を認めます。

セキュリティルール

  • シークレット(秘密鍵・APIキー・エンティティシークレット)をハードコード・コミット・ログ出力することは絶対にしないでください。必ず環境変数またはシークレットマネージャーを使用してください。プロジェクトのスキャフォールディング時には .env* およびシークレットファイルを .gitignore に追加してください。
  • 秘密鍵を平文のCLIフラグとして渡すことは絶対にしないでください。暗号化されたキーストアまたはインタラクティブなインポートを優先してください。
  • ブリッジ実行前に、ソース・デスティネーションチェーン・受取人・金額・トークンについてユーザーに明示的な確認を必ず取ってください。メインネット上での資金移動については確認を受け取ることが必須です。
  • メインネットを対象とする場合、または安全しきい値(例: 100 USDCを超える場合)を超える場合は必ず警告してください
  • ブリッジ操作を送信する前に、すべての入力値(アドレス・金額・チェーン名)を必ず検証してください
  • 未監査または未知のコントラクトと連携する前に必ず警告してください

ベストプラクティス

  • コードを書き始める前に、必ず判断ガイドの質問をユーザーと一緒に確認してください。App KitかBridge Kitかを勝手に決めず、ユーザーの回答に基づいてSDKを選択してください。
  • 実装前に、必ず適切なリファレンスファイルを読んでください
  • フォワーディングサービスを使用しない場合、ブラウザウォレット(wagmi・ConnectKit・RainbowKit)で kit.bridge() を呼び出す前に、必ずウォレットをソースチェーンに切り替えてください
  • ブリッジ操作は必ず try/catchでラップし、リカバリー用に結果オブジェクトを保存してください。再試行前に result.steps を確認して、どのステップが完了済みかを把握してください。
  • 本番環境のリトライロジックでは必ず指数バックオフを使用してください。
  • 必ず数値のチェーンIDではなく、文字列のチェーン名(例: "Arc_Testnet""Base_Sepolia")を使用してください。
  • 常にテストネットをデフォルトとしてください。メインネットを対象とする場合
原文(English)を表示

Overview

Crosschain Transfer Protocol (CCTP) is Circle's native protocol for burning USDC on one chain and minting it on another. App Kit (@circle-fin/app-kit) is Circle's all-inclusive SDK covering bridge, swap, and send in one package; standalone Bridge Kit (@circle-fin/bridge-kit) ships the same bridge API in a lighter package. Both orchestrate the full CCTP lifecycle -- approve, burn, attestation fetch, mint -- in a single kit.bridge() call across EVM and Solana. Recommend App Kit unless the user wants bridge-only functionality. Bridge operations need no kit key (only swap/send in App Kit do).

Prerequisites / Setup

Installation

App Kit with Viem adapter (recommended):

npm install @circle-fin/app-kit @circle-fin/adapter-viem-v2

Bridge Kit standalone with Viem adapter:

npm install @circle-fin/bridge-kit @circle-fin/adapter-viem-v2

For Solana support, also install:

npm install @circle-fin/adapter-solana-kit

For Circle Wallets (developer-controlled) support:

npm install @circle-fin/adapter-circle-wallets

Environment Variables

PRIVATE_KEY=              # EVM wallet private key (hex, 0x-prefixed)
EVM_PRIVATE_KEY=          # EVM private key (when also using Solana)
SOLANA_PRIVATE_KEY=       # Solana wallet private key (base58)
CIRCLE_API_KEY=           # Circle API key (for Circle Wallets adapter)
CIRCLE_ENTITY_SECRET=     # Entity secret (for Circle Wallets adapter)
EVM_WALLET_ADDRESS=       # Developer-controlled EVM wallet address
SOLANA_WALLET_ADDRESS=    # Developer-controlled Solana wallet address

No KIT_KEY is needed for bridge operations. A kit key is only required if you also use swap or send features via App Kit.

SDK Initialization

App Kit (recommended):

import { AppKit } from "@circle-fin/app-kit";

const kit = new AppKit();

Bridge Kit (standalone):

import { BridgeKit } from "@circle-fin/bridge-kit";

const kit = new BridgeKit();

Decision Guide

ALWAYS walk through these questions with the user before writing any code. Do not skip steps or assume answers.

SDK Choice

Question 1 -- Will you need swap or send functionality in the future?

  • Yes, or unsure -> App Kit (recommended) -- single SDK covers bridge + swap + send, easier to extend later
  • No, bridge-only and will never need swap or send -> Bridge Kit -- standalone, lighter package for bridge-only use cases

Wallet / Adapter Choice

Question 2 -- How do you manage your wallet/keys?

  • Managing your own private key (self-custodied, stored in env var or secrets manager) -> Question 3
  • Using Circle developer-controlled wallets (Circle manages key storage and signing) -> Use Circle Wallets adapter. READ references/adapter-circle-wallets.md
  • Using browser wallets (wagmi, ConnectKit, RainbowKit) -> Use wagmi adapter. READ references/adapter-wagmi.md

Question 3 -- Which chains are you bridging between?

  • EVM-to-EVM or EVM-to-Solana -> Use Viem and/or Solana Kit adapters. READ references/adapter-private-key.md

Core Concepts

  • CCTP steps: Every bridge transfer executes four sequential steps -- approve (ERC-20 allowance), burn (destroy USDC on source chain), fetchAttestation (wait for Circle to sign the burn proof), and mint (create USDC on destination chain).
  • Adapters: Both App Kit and Bridge Kit use adapter objects to abstract wallet/signer differences. Each ecosystem has its own adapter factory (createViemAdapterFromPrivateKey, createSolanaKitAdapterFromPrivateKey, createCircleWalletsAdapter). The same adapter instance can serve as both source and destination when bridging within the same ecosystem.
  • Forwarding Service: When useForwarder: true is set on the destination, Circle's infrastructure handles attestation fetching and mint submission. This removes the need for a destination wallet or polling loop. There is a per-transfer fee that varies by route (see below).
  • Transfer speed: CCTP fast mode (default) completes in ~8-20 seconds. Standard mode takes ~15-19 minutes.
  • Chain identifiers: Both SDKs use string chain names (e.g., "Arc_Testnet", "Base_Sepolia", "Solana_Devnet"), not numeric chain IDs, in the kit.bridge() call.

Implementation Patterns

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

  • references/adapter-private-key.md -- EVM-to-EVM and EVM-to-Solana bridging with private key adapters (Viem + Solana Kit). Includes App Kit and Bridge Kit examples.
  • references/adapter-circle-wallets.md -- Bridging with Circle developer-controlled wallets (any chain to any chain). Includes App Kit and Bridge Kit examples.
  • references/adapter-wagmi.md -- Browser wallet integration using wagmi (ConnectKit, RainbowKit, etc.). Includes App Kit and Bridge Kit examples.

Sample Response from kit.bridge()

{
  "amount": "25.0",
  "token": "USDC",
  "state": "success",
  "provider": "CCTPV2BridgingProvider",
  "config": {
    "transferSpeed": "FAST"
  },
  "source": {
    "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "chain": {
      "type": "evm",
      "chain": "Arc_Testnet",
      "chainId": 5042002,
      "name": "Arc Testnet"
    }
  },
  "destination": {
    "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "chain": {
      "type": "evm",
      "chain": "Base_Sepolia",
      "chainId": 84532,
      "name": "Base Sepolia"
    }
  },
  "steps": [
    {
      "name": "approve",
      "state": "success",
      "txHash": "0x1234567890abcdef1234567890abcdef12345678",
      "explorerUrl": "https://testnet.arcscan.app/tx/0x1234..."
    },
    {
      "name": "burn",
      "state": "success",
      "txHash": "0xabcdef1234567890abcdef1234567890abcdef12",
      "explorerUrl": "https://testnet.arcscan.app/tx/0xabcdef..."
    },
    {
      "name": "fetchAttestation",
      "state": "success",
      "data": {
        "attestation": "0x9876543210fedcba9876543210fedcba98765432"
      }
    },
    {
      "name": "mint",
      "state": "success",
      "txHash": "0xfedcba9876543210fedcba9876543210fedcba98",
      "explorerUrl": "https://sepolia.basescan.org/tx/0xfedcba..."
    }
  ]
}

Forwarding Service, events, and recovery

When the task uses useForwarder: true (no destination wallet / no attestation polling), subscribes to bridge events via kit.on(), or needs to analyze and resume a failed transfer with kit.retry(), READ references/forwarding-events-recovery.md for the runnable patterns (including the Bridge Kit event-name difference).

Error Handling & Recovery

Both App Kit and Bridge Kit have two error categories:

  • Hard errors throw exceptions (validation, config, auth) -- catch in try/catch.
  • Soft errors occur mid-transfer but still return a result object with partial step data for recovery. NEVER re-run kit.bridge() from scratch after a soft error — kit.retry(result, ...) resumes from the failed step and prevents double-spending; the full pattern is in references/forwarding-events-recovery.md.

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 (private keys, API keys, entity secrets). ALWAYS use environment variables or a secrets manager. Add .gitignore entries for .env* and secret files when scaffolding.
  • NEVER pass private keys as plain-text CLI flags. Prefer encrypted keystores or interactive import.
  • ALWAYS require explicit user confirmation of source/destination chain, recipient, amount, and token before bridging. 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 names) before submitting bridge operations.
  • ALWAYS warn before interacting with unaudited or unknown contracts.

Best Practices

  • ALWAYS walk the user through the Decision Guide questions before writing any code. Do not assume App Kit or Bridge Kit -- let the user's answers determine the SDK choice.
  • ALWAYS read the correct reference files before implementing.
  • ALWAYS switch the wallet to the source chain before calling kit.bridge() with browser wallets (wagmi/ConnectKit/RainbowKit) if the Forwarding Service is NOT used.
  • ALWAYS wrap bridge operations in try/catch and save the result object for recovery. Check result.steps before retrying to see which steps completed.
  • ALWAYS use exponential backoff for retry logic in production.
  • ALWAYS use string chain names (e.g., "Arc_Testnet", "Base_Sepolia"), not numeric chain IDs.
  • ALWAYS default to testnet. Require explicit user confirmation before targeting mainnet.
  • ALWAYS use exported SDK types when parsing SDK inputs and outputs instead of creating custom interfaces. This minimizes type errors.

Reference Links

Alternatives

Trigger the swap-tokens skill instead when:

  • You need to swap tokens (e.g., USDT to USDC) on the same chain.
  • You need to move non-USDC tokens across chains. The swap-tokens skill shows how to combine separate swap and bridge calls (swap tokenA to USDC, bridge USDC, swap USDC to tokenB).

Trigger the use-gateway skill instead when:

  • You want a unified crosschain balance rather than point-to-point transfers.
  • Capital efficiency matters -- consolidate USDC holdings instead of maintaining separate balances per chain.
  • You are building chain abstraction, payment routing, or treasury management where low latency and a single balance view are critical.

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 による自動翻訳です。