internet-court/internet-court-skill / vendored/dflow/dflow-phantom-connect
dflow-phantom-connect
VerifiedBuild Solana wallet-connected apps with Phantom Connect SDKs and DFlow spot trading. Use when user asks to connect a Phantom wallet, integrate Phantom in React, React Native, or vanilla JS, sign messages or transactions, build token-gated pages, mint NFTs, accept crypto payments, or swap/stream tokens with DFlow. Covers @phantom/react-sdk, @phantom/react-native-sdk, @phantom/browser-sdk, and DFlow spot trading and market-data streaming. Do NOT use for Ethereum or EVM wallet integrations, or non-DFlow DEX routing.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 1.0 KB |
| SKILL.md | skill md | 7.0 KB |
| references/browser-sdk.md | markdown | 8.1 KB |
| references/dflow-crypto-trading.md | markdown | 4.9 KB |
| references/dflow-websockets.md | markdown | 4.3 KB |
| references/nft-minting.md | markdown | 4.6 KB |
| references/payments.md | markdown | 5.5 KB |
| references/react-native-sdk.md | markdown | 7.2 KB |
| references/react-sdk.md | markdown | 7.1 KB |
| references/token-gating.md | markdown | 4.9 KB |
| references/transactions.md | markdown | 5.1 KB |
references/react-native-sdk.md
View on GitHub# React Native SDK Reference
Complete reference for `@phantom/react-native-sdk`.
## Prerequisites
All Phantom Connect integrations require:
1. **Phantom Portal Account** — Register at phantom.com/portal/login
2. **App ID** — Get from Portal (required when using Google or Apple auth providers)
3. **Allowlisted URLs** — Add your redirect URLs in Portal settings
## Auth Providers
| Provider | Description | Requires appId |
| ------------ | ------------------------------- | -------------- |
| `"google"` | Google OAuth (embedded wallet) | Yes |
| `"apple"` | Apple ID (embedded wallet) | Yes |
| `"deeplink"` | Phantom mobile app via deeplink | Yes |
React Native does not support the `"injected"` provider (no browser extension on mobile). Use `"google"` and/or `"apple"` for social login, or `"deeplink"` to connect to the Phantom mobile app directly.
## Installation
```bash
npm install @phantom/react-native-sdk
# Expo peer dependencies
npx expo install expo-secure-store expo-web-browser expo-auth-session expo-router react-native-svg
# Required polyfill
npm install react-native-get-random-values
# For Solana support
npm install @solana/web3.js
```
## Critical Setup
### 1. Polyfill (MUST BE FIRST IMPORT)
```tsx
// App.tsx or _layout.tsx - THIS MUST BE THE VERY FIRST IMPORT
import "react-native-get-random-values";
import { PhantomProvider } from "@phantom/react-native-sdk";
// ... other imports
```
### 2. Configure app.json (Expo)
```json
{
"expo": {
"name": "My Wallet App",
"slug": "my-wallet-app",
"scheme": "mywalletapp",
"plugins": [
"expo-router",
"expo-secure-store",
"expo-web-browser",
"expo-auth-session"
]
}
}
```
## PhantomProvider Configuration
```tsx
import "react-native-get-random-values";
import { PhantomProvider, AddressType, darkTheme } from "@phantom/react-native-sdk";
export default function App() {
return (
<PhantomProvider
config={{
providers: ["google", "apple"],
appId: "your-app-id",
scheme: "mywalletapp",
addressTypes: [AddressType.solana],
authOptions: {
redirectUrl: "mywalletapp://phantom-auth-callback",
},
}}
theme={darkTheme}
appIcon="https://yourapp.com/icon.png"
appName="Your App"
>
<App />
</PhantomProvider>
);
}
```
## Available Hooks
| Hook | Purpose | Returns |
| -------------- | ------------------------ | -------------------------------------- |
| `useModal` | Control connection modal | `{ open, close, isOpened }` |
| `usePhantom` | Access wallet/user state | `{ isConnected, isLoading }` |
| `useConnect` | Connect to wallet | `{ connect, isConnecting, error }` |
| `useAccounts` | Get wallet addresses | `{ addresses, isConnected, walletId }` |
| `useDisconnect`| Disconnect wallet | `{ disconnect, isDisconnecting }` |
| `useSolana` | Solana operations | `{ solana, isAvailable }` |
## Hook Examples
### useModal (Recommended Approach)
```tsx
import { View, Button, Text } from "react-native";
import { useModal, useAccounts } from "@phantom/react-native-sdk";
export function WalletScreen() {
const { open, close, isOpened } = useModal();
const { isConnected, addresses } = useAccounts();
if (!isConnected) {
return (
<View style={{ padding: 20 }}>
<Button title="Connect Wallet" onPress={open} />
</View>
);
}
return (
<View style={{ padding: 20 }}>
<Text>Connected!</Text>
{addresses.map((addr, i) => (
<Text key={i}>{addr.addressType}: {addr.address}</Text>
))}
<Button title="Manage Wallet" onPress={open} />
</View>
);
}
```
### useConnect (Direct Connection)
```tsx
import { View, Button, Text, Alert } from "react-native";
import { useConnect, useAccounts, useDisconnect } from "@phantom/react-native-sdk";
export function WalletScreen() {
const { connect, isConnecting, error } = useConnect();
const { addresses, isConnected } = useAccounts();
const { disconnect } = useDisconnect();
const handleConnect = async () => {
try {
await connect({ provider: "google" });
Alert.alert("Success", "Wallet connected!");
} catch (err) {
Alert.alert("Error", err.message);
}
};
if (!isConnected) {
return (
<View>
<Button
title={isConnecting ? "Connecting..." : "Connect with Google"}
onPress={handleConnect}
disabled={isConnecting}
/>
{error && <Text style={{ color: "red" }}>{error.message}</Text>}
</View>
);
}
return (
<View>
{addresses.map((addr, i) => (
<Text key={i}>{addr.addressType}: {addr.address}</Text>
))}
<Button title="Disconnect" onPress={disconnect} />
</View>
);
}
```
### useSolana
```tsx
import { Alert } from "react-native";
import { useSolana } from "@phantom/react-native-sdk";
function SolanaActions() {
const { solana, isAvailable } = useSolana();
if (!isAvailable) return null;
const signMessage = async () => {
try {
const { signature } = await solana.signMessage("Hello from Solana!");
Alert.alert("Signed!", signature.slice(0, 20) + "...");
} catch (err) {
Alert.alert("Error", err.message);
}
};
const sendTransaction = async (transaction) => {
try {
const result = await solana.signAndSendTransaction(transaction);
Alert.alert("Sent!", `TX: ${result.hash}`);
} catch (err) {
Alert.alert("Error", err.message);
}
};
return <Button title="Sign Message" onPress={signMessage} />;
}
```
## Authentication Flow
1. User taps "Connect Wallet"
2. System browser opens (Safari iOS / Chrome Android)
3. User authenticates with Google or Apple
4. Browser redirects back via custom URL scheme
5. SDK processes auth result automatically
6. Wallet connected and ready
### Redirect URL Format
```
{scheme}://phantom-auth-callback?wallet_id=...&session_id=...
```
## Security Features
- **iOS**: Keychain Services with hardware security
- **Android**: Android Keystore with hardware-backed keys
- Uses system browser (not in-app webview)
- Verifies redirect origins automatically
## Debug Configuration
```tsx
<PhantomProvider
config={config}
debugConfig={{
enabled: true,
}}
>
...
</PhantomProvider>
```
## Solana Configuration
```tsx
<PhantomProvider
config={{
providers: ["google", "apple"],
appId: "your-app-id",
scheme: "mycompany-wallet",
addressTypes: [AddressType.solana],
authOptions: {
redirectUrl: "mycompany-wallet://auth/success",
},
}}
theme={darkTheme}
>
...
</PhantomProvider>
```
## Supported Solana Networks
| Network | Cluster |
| ------- | ------------ |
| Mainnet | mainnet-beta |
| Devnet | devnet |
| Testnet | testnet |
## Common Issues
### App crashes on startup
Ensure `react-native-get-random-values` is imported FIRST, before any other imports.
### Auth redirect not working
1. Verify `scheme` in app.json matches config
2. Ensure all Expo plugins are configured
3. Run `npx expo prebuild` after changes
### "appId required" error
Add your appId from Phantom Portal when using google/apple providers.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |