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/payments.md
View on GitHub# Crypto Payments
Accept cryptocurrency payments in your applications.
## Simple SOL Payment
```tsx
import { useSolana, useAccounts } from "@phantom/react-sdk";
import { Connection, PublicKey, SystemProgram, VersionedTransaction, TransactionMessage } from "@solana/web3.js";
function PayButton({ recipient, amountSol }: { recipient: string; amountSol: number }) {
const { solana } = useSolana();
const { isConnected } = useAccounts();
const [status, setStatus] = useState<"idle" | "paying" | "success" | "error">("idle");
async function handlePay() {
setStatus("paying");
try {
const connection = new Connection("https://api.mainnet-beta.solana.com");
const { blockhash } = await connection.getLatestBlockhash();
const wallet = await solana.getPublicKey();
const message = new TransactionMessage({
payerKey: new PublicKey(wallet),
recentBlockhash: blockhash,
instructions: [
SystemProgram.transfer({
fromPubkey: new PublicKey(wallet),
toPubkey: new PublicKey(recipient),
lamports: Math.floor(amountSol * 1e9),
}),
],
}).compileToV0Message();
const tx = new VersionedTransaction(message);
await solana.signAndSendTransaction(tx);
setStatus("success");
} catch {
setStatus("error");
}
}
return (
<button onClick={handlePay} disabled={!isConnected || status === "paying"}>
{status === "paying" ? "Processing..." : `Pay ${amountSol} SOL`}
</button>
);
}
```
## SPL Token Payment (USDC)
```tsx
import { getAssociatedTokenAddress, createTransferInstruction, createAssociatedTokenAccountInstruction, getAccount } from "@solana/spl-token";
const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
async function payWithUSDC(solana: any, recipient: string, amount: number) {
const connection = new Connection("https://api.mainnet-beta.solana.com");
const { blockhash } = await connection.getLatestBlockhash();
const wallet = await solana.getPublicKey();
const mint = new PublicKey(USDC_MINT);
const from = new PublicKey(wallet);
const to = new PublicKey(recipient);
const fromAta = await getAssociatedTokenAddress(mint, from);
const toAta = await getAssociatedTokenAddress(mint, to);
const instructions = [];
// Create recipient's token account if needed
try {
await getAccount(connection, toAta);
} catch {
instructions.push(createAssociatedTokenAccountInstruction(from, toAta, to, mint));
}
// Transfer (USDC has 6 decimals)
instructions.push(createTransferInstruction(fromAta, toAta, from, amount * 1e6));
const message = new TransactionMessage({
payerKey: from,
recentBlockhash: blockhash,
instructions,
}).compileToV0Message();
return await solana.signAndSendTransaction(new VersionedTransaction(message));
}
```
## Checkout with Backend Verification
### Client
```tsx
async function checkout(orderId: string, solana: any) {
// 1. Create payment on backend
const { paymentId, transaction } = await fetch("/api/payments/create", {
method: "POST",
body: JSON.stringify({ orderId }),
}).then(r => r.json());
// 2. Sign and send
const { hash } = await solana.signAndSendTransaction(
Buffer.from(transaction, "base64")
);
// 3. Confirm with backend
const { success } = await fetch("/api/payments/confirm", {
method: "POST",
body: JSON.stringify({ paymentId, txHash: hash }),
}).then(r => r.json());
return success;
}
```
### Server
```ts
// /api/payments/create.ts
export async function POST(req: Request) {
const { orderId } = await req.json();
// Get order, calculate amount
const order = await db.orders.findUnique({ where: { id: orderId } });
const solAmount = order.total / await getSolPrice();
// Create payment record
const payment = await db.payments.create({
data: { orderId, solAmount, status: "pending" }
});
// Build transaction (partial - user will sign)
// Return serialized transaction
return Response.json({ paymentId: payment.id, transaction: "..." });
}
// /api/payments/confirm.ts
export async function POST(req: Request) {
const { paymentId, txHash } = await req.json();
// Verify transaction on-chain
const connection = new Connection("https://api.mainnet-beta.solana.com");
const tx = await connection.getTransaction(txHash, { commitment: "confirmed" });
if (!tx) return Response.json({ success: false });
// Verify amount and recipient match
// Update payment status
// Fulfill order
return Response.json({ success: true });
}
```
## Price Display with Live Rates
```tsx
function PriceDisplay({ usdAmount }: { usdAmount: number }) {
const [solPrice, setSolPrice] = useState(0);
useEffect(() => {
async function fetchPrice() {
const res = await fetch("https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd");
const data = await res.json();
setSolPrice(data.solana.usd);
}
fetchPrice();
const interval = setInterval(fetchPrice, 60000);
return () => clearInterval(interval);
}, []);
const solAmount = solPrice ? (usdAmount / solPrice).toFixed(4) : "...";
return (
<div>
<p>${usdAmount} USD</p>
<p>≈ {solAmount} SOL</p>
</div>
);
}
```
## Best Practices
1. **Always verify on-chain** - Don't trust client-side alone
2. **Use unique payment IDs** - Track each payment
3. **Handle price volatility** - Lock prices or use stablecoins
4. **Set expiration** - Payment requests should expire
5. **Wait for confirmations** - Confirm before fulfilling
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 |