‹ 首页

phantom-connect

@sendaifun · 收录于 1 周前

Build wallet-connected applications with the Phantom Connect SDK for Solana. Use when integrating Phantom wallets into React, React Native, or vanilla JS/TS apps — including wallet connection, social login (Google/Apple), transaction signing, message signing, token-gated access, crypto payments, and NFT minting. Covers @phantom/react-sdk, @phantom/react-native-sdk, and @phantom/browser-sdk.

适合你,如果你正在开发 Solana 应用并需要集成 Phantom 钱包功能

/ 下载安装
phantom-connect.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add sendaifun/skills/phantom-connect
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- sendaifun/skills/phantom-connect
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify sendaifun/skills/phantom-connect
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
116GitHub stars
~1K最小装载
~8.6K含声明引用
~8.6K文本包总量
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · Apache-2.0 · 064d4de

Phantom Connect SDK

Build wallet-connected Solana applications with the Phantom Connect SDK ecosystem.

SDK Selection

| Platform | SDK | Package | |----------|-----|---------| | React web apps | React SDK | @phantom/react-sdk | | React Native / Expo | React Native SDK | @phantom/react-native-sdk | | Vanilla JS / Vue / Angular | Browser SDK | @phantom/browser-sdk |

Prerequisites
  1. Phantom Portal Account — Register at phantom.com/portal
  2. App ID — Get from Portal → App → Set Up
  3. Allowlisted URLs — Add domains and redirect URLs in Portal
Auth Providers

| Provider | Description | Requires appId | |----------|-------------|----------------| | "injected" | Phantom browser extension | No | | "google" | Google OAuth (embedded wallet) | Yes | | "apple" | Apple ID (embedded wallet) | Yes |

Critical Rules
  1. Always use signAndSendTransactionsignTransaction and signAllTransactions are NOT supported for embedded wallets
  2. Always use LAMPORTS_PER_SOL from @solana/web3.js for amount conversion — never hardcode 1000000000
  3. Wrap all async SDK calls in try-catch — users can reject prompts at any time
  4. Check isConnected before signing — verify wallet connection before any operation
  5. React Native: react-native-get-random-values must be the FIRST import — before any other imports
  6. BrowserSDK must be a singleton — create one instance per app, never multiple
  7. Import AddressType from @phantom/browser-sdk only
  8. Use devnet for testing, mainnet-beta for production — never test against mainnet with real funds
  9. Never expose private keys — Phantom handles all signing internally
  10. Embedded wallet spending limit: $1,000 USD per day per app per user
  11. Social login sessions persist 7 days from last auth event — handle expiration gracefully
Quick Start
React SDK
import { PhantomProvider, useModal, usePhantom, darkTheme } from "@phantom/react-sdk";
import { AddressType } from "@phantom/browser-sdk";

function App() {
  return (
    <PhantomProvider
      config={{
        providers: ["google", "apple", "injected"],
        appId: "your-app-id",
        addressTypes: [AddressType.solana],
        authOptions: { redirectUrl: "https://yourapp.com/callback" },
      }}
      theme={darkTheme}
    >
      <YourApp />
    </PhantomProvider>
  );
}
React Native SDK
// CRITICAL: Must be first import
import "react-native-get-random-values";
import { PhantomProvider, AddressType, darkTheme } from "@phantom/react-native-sdk";

// Requires app.json: { "expo": { "scheme": "myapp", "plugins": [...] } }
Browser SDK
import { BrowserSDK, AddressType } from "@phantom/browser-sdk";

const sdk = new BrowserSDK({
  providers: ["google", "apple", "injected"],
  appId: "your-app-id",
  addressTypes: [AddressType.solana],
  autoConnect: true,
});
Reference Docs

For detailed implementation patterns, read these files:

  • [references/react-sdk.md](references/react-sdk.md) — Complete React SDK reference (hooks, components, theming)
  • [references/react-native-sdk.md](references/react-native-sdk.md) — Mobile setup, Expo config, deep links
  • [references/browser-sdk.md](references/browser-sdk.md) — Vanilla JS patterns, events, wallet discovery
  • [references/transactions.md](references/transactions.md) — Solana transaction patterns (SOL, SPL tokens)
  • [references/payments.md](references/payments.md) — Crypto payment flows (SOL, USDC, backend verification)
  • [references/token-gating.md](references/token-gating.md) — Token-gated access (client-side, server-side, NFT)
  • [references/nft-minting.md](references/nft-minting.md) — NFT mint pages, Metaplex Core, compressed NFTs
Common Issues

| Issue | Solution | |-------|----------| | "appId required" | Add appId from Phantom Portal when using google/apple providers | | Redirect not working | Allowlist redirectUrl in Phantom Portal | | React Native crashes | Import react-native-get-random-values as FIRST import | | Extension not detected | Use waitForPhantomExtension() with timeout | | signTransaction error | Use signAndSendTransaction instead — embedded wallets don't support signTransaction |

Resources
按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。