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/transactions.md
View on GitHub# Transaction Patterns Reference
Detailed transaction patterns for Solana with Phantom Connect SDKs.
## Solana Transactions
### Dependencies
```bash
npm install @solana/web3.js
# OR for newer @solana/kit
npm install @solana/kit
```
### SOL Transfer with @solana/web3.js
```ts
import {
Connection,
PublicKey,
SystemProgram,
VersionedTransaction,
TransactionMessage,
} from "@solana/web3.js";
async function transferSol(solana, recipient: string, lamports: number) {
const connection = new Connection("https://api.mainnet-beta.solana.com");
const { blockhash } = await connection.getLatestBlockhash();
const fromAddress = await solana.getPublicKey();
const message = new TransactionMessage({
payerKey: new PublicKey(fromAddress),
recentBlockhash: blockhash,
instructions: [
SystemProgram.transfer({
fromPubkey: new PublicKey(fromAddress),
toPubkey: new PublicKey(recipient),
lamports,
}),
],
}).compileToV0Message();
const transaction = new VersionedTransaction(message);
const result = await solana.signAndSendTransaction(transaction);
return result.hash;
}
// Usage: 0.001 SOL = 1,000,000 lamports
const txHash = await transferSol(solana, "recipient-address", 1000000);
```
### SOL Transfer with @solana/kit
```ts
import {
createSolanaRpc,
pipe,
createTransactionMessage,
setTransactionMessageFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
address,
compileTransaction,
} from "@solana/kit";
async function transferSolKit(solana, recipient: string) {
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
const userPublicKey = await solana.getPublicKey();
const transactionMessage = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(address(userPublicKey), tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)
);
const transaction = compileTransaction(transactionMessage);
const result = await solana.signAndSendTransaction(transaction);
return result.hash;
}
```
### SPL Token Transfer
```ts
import {
Connection,
PublicKey,
VersionedTransaction,
TransactionMessage,
} from "@solana/web3.js";
import {
getAssociatedTokenAddress,
createTransferInstruction,
} from "@solana/spl-token";
async function transferToken(
solana,
mint: string,
recipient: string,
amount: number,
decimals: number
) {
const connection = new Connection("https://api.mainnet-beta.solana.com");
const { blockhash } = await connection.getLatestBlockhash();
const fromAddress = await solana.getPublicKey();
const fromPubkey = new PublicKey(fromAddress);
const mintPubkey = new PublicKey(mint);
const toPubkey = new PublicKey(recipient);
const fromAta = await getAssociatedTokenAddress(mintPubkey, fromPubkey);
const toAta = await getAssociatedTokenAddress(mintPubkey, toPubkey);
const transferAmount = amount * Math.pow(10, decimals);
const message = new TransactionMessage({
payerKey: fromPubkey,
recentBlockhash: blockhash,
instructions: [
createTransferInstruction(fromAta, toAta, fromPubkey, transferAmount),
],
}).compileToV0Message();
const transaction = new VersionedTransaction(message);
return await solana.signAndSendTransaction(transaction);
}
```
### Sign Without Sending
```ts
// Sign only (for offline signing, multi-sig, etc.)
const signedTx = await solana.signTransaction(transaction);
// Then send later
const connection = new Connection("https://api.mainnet-beta.solana.com");
const signature = await connection.sendRawTransaction(signedTx.serialize());
```
### Network Switching
```ts
// Switch networks before transactions
await solana.switchNetwork("devnet");
// Options: "mainnet-beta", "devnet", "testnet"
```
## Message Signing
```ts
// Sign a message
const message = "Hello World";
const { signature } = await solana.signMessage(message);
console.log("Signature:", signature);
```
## Error Handling
```ts
try {
const result = await solana.signAndSendTransaction(transaction);
console.log("Success:", result.hash);
} catch (error) {
if (error.message.includes("User rejected")) {
console.log("User cancelled the transaction");
} else if (error.message.includes("insufficient funds")) {
console.log("Not enough balance");
} else {
console.error("Transaction failed:", error);
}
}
```
## Transaction Status Checking
```ts
import { Connection } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
// Wait for confirmation
const confirmation = await connection.confirmTransaction(signature, "confirmed");
// Get transaction details
const txDetails = await connection.getTransaction(signature);
```
## Fee Estimation
```ts
import { Connection } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com");
// Get recent prioritization fees
const fees = await connection.getRecentPrioritizationFees();
// Get minimum balance for rent exemption
const minBalance = await connection.getMinimumBalanceForRentExemption(dataSize);
```
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 |