/solana-rpc
Direct Solana blockchain interaction via JSON-RPC — account lookups, token balances, transaction submission, and program queries
$ npx -y skills add agiprolabs/claude-trading-skills --skill solana-rpc --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/solana-rpc
Context preview
The summary Claude sees to decide when to auto-load this skill.
Direct Solana blockchain interaction via JSON-RPC — account lookups, token balances, transaction submission, and program queries
SKILL.md
solana-rpc.SKILL.mdname: solana-rpc
description: Direct Solana blockchain interaction via JSON-RPC — account lookups, token balances, transaction submission, and program queries
Solana RPC — Direct Blockchain Interaction
The Solana JSON-RPC API provides direct read/write access to the blockchain. Use it for account state queries, token balance lookups, transaction building and submission, and program account enumeration. This is the low-level foundation when higher-level APIs (Birdeye, Helius, SolanaTracker) don't have the data you need.
Quick Start
import httpx
RPC = os.getenv("SOLANA_RPC_URL", "https://api.mainnet-beta.solana.com")
def rpc_call(method: str, params: list = None) -> dict:
resp = httpx.post(RPC, json={
"jsonrpc": "2.0", "id": 1,
"method": method, "params": params or [],
}, timeout=30.0)
return resp.json()
# Get SOL balance
result = rpc_call("getBalance", ["WALLET_PUBKEY"])
sol_balance = result["result"]["value"] / 1e9
# Get latest blockhash
result = rpc_call("getLatestBlockhash")
blockhash = result["result"]["value"]["blockhash"]RPC Providers
| Provider | Free Tier | Paid | Notes | |----------|-----------|------|-------| | Helius | 50K credits/day | $49+/mo | Enhanced RPCs, DAS API | | QuickNode | Limited | $49+/mo | Multi-chain, WebSocket | | Triton | No free tier | ~$300+/mo | Yellowstone gRPC bundled | | Shyft | Limited | $49+/mo | Yellowstone gRPC bundled | | Alchemy | 300M CU/mo | Scaling | Good free tier | | Public (mainnet-beta) | Free | — | Rate limited, unreliable |
**Recommendation**: Use Helius or QuickNode for development. Never use public RPC for production trading.
Core Read Methods
Account & Balance
# SOL balance (in lamports, divide by 1e9 for SOL)
getBalance(pubkey, {commitment: "confirmed"})
# Full account info (data, owner, lamports, executable)
getAccountInfo(pubkey, {encoding: "jsonParsed"})
# Multiple accounts in one call
getMultipleAccounts([pubkey1, pubkey2], {encoding: "jsonParsed"})Token Accounts
# All SPL token accounts owned by a wallet
getTokenAccountsByOwner(wallet_pubkey, {
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}, {"encoding": "jsonParsed"})
# Token balance for a specific token account
getTokenAccountBalance(token_account_pubkey)
# Largest token accounts (top holders)
getTokenLargestAccounts(mint_pubkey)
# Total supply of a token
getTokenSupply(mint_pubkey)Transaction Data
# Get parsed transaction by signature
getTransaction(signature, {
"encoding": "jsonParsed",
"maxSupportedTransactionVersion": 0,
})
# Recent transaction signatures for an address
getSignaturesForAddress(pubkey, {
"limit": 20,
"before": "optional_signature", # pagination cursor
})
# Transaction status
getSignatureStatuses([sig1, sig2])Block & Slot
# Current slot
getSlot({commitment: "confirmed"})
# Block data
getBlock(slot, {
"encoding": "jsonParsed",
"transactionDetails": "full",
"maxSupportedTransactionVersion": 0,
})
# Latest blockhash (needed for tx building)
getLatestBlockhash({commitment: "confirmed"})
# Slot leader schedule
getLeaderSchedule()Program Accounts
# All accounts owned by a program (with filters)
getProgramAccounts(program_pubkey, {
"encoding": "jsonParsed",
"filters": [
{"dataSize": 165}, # Filter by account data size
{"memcmp": { # Filter by data content
"offset": 32,
"bytes": "base58_encoded_value",
}},
],
})**Warning**: `getProgramAccounts` without filters can return millions of results and timeout. Always use `dataSize` and/or `memcmp` filters.
Priority Fees
# Recent priority fee estimates
getRecentPrioritizationFees([account_pubkey])
# Returns array of { slot, prioritizationFee } for recent slots
# Minimum rent for account
getMinimumBalanceForRentExemption(data_length)Write Methods
Send Transaction
# Send a signed, serialized transaction
sendTransaction(base64_tx, {
"encoding": "base64",
"skipPreflight": False,
"preflightCommitment": "confirmed",
"maxRetries": 3,
})
# Simulate before sending
simulateTransaction(base64_tx, {
"encoding": "base64",
"sigVerify": False,
"commitment": "confirmed",
})Transaction Confirmation
import time
def confirm_transaction(rpc_url: str, signature: str, timeout: float = 30.0) -> bool:
"""Poll for transaction confirmation."""
start = time.time()
while time.time() - start < timeout:
result = rpc_call("getSignatureStatuses", [[signature]])
statuses = result.get("result", {}).get("value", [None])
if statuses[0] is not None:
status = statuses[0]
if status.get("err"):
return False
if status.get("confirmationStatus") in ("confirmed", "finalized"):
return True
time.sleep(0.5)
return FalseCommitment Levels
| Level | Description | Use When | |-------|-------------|----------| | `processed` | Single node confirmation | Speed over safety | | `confirmed` | Supermajority (2/3+) | **Default for trading** | | `finalized` | Maximum supermajority + 31 slots | Critical operations |
Always specify commitment explicitly. Default varies by provider.
Common Patterns
Get All Token Holdings for a Wallet
def get_wallet_tokens(wallet: str) -> list[dict]:
"""Get all SPL token holdings with metadata."""
result = rpc_call("getTokenAccountsByOwner", [
wallet,
{"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},
{"encoding": "jsonParsed"},
])
tokens = []
for acct in result["result"]["value"]:
info = acct["account"]["data"]["parsed"]["info"]
tokens.append({
"mint": info["mint"],
"amount": int(info["tokenAmount"]["amount"]),
"dRead more
name: solana-rpc description: Direct Solana blockchain interaction via JSON-RPC — account lookups, token balances, transaction submission, and program queries
Solana RPC — Direct Blockchain Interaction
The Solana JSON-RPC API provides direct read/write access to the blockchain. Use it for account state queries, token balance lookups, transaction building and submission, and program account enumeration. This is the low-level foundation when higher-level APIs (Birdeye, Helius, SolanaTracker) don't have the data you need.
Quick Start
import httpx
RPC = os.getenv("SOLANA_RPC_URL", "https://api.mainnet-beta.solana.com")
def rpc_call(method: str, params: list = None) -> dict:
resp = httpx.post(RPC, json={
"jsonrpc": "2.0", "id": 1,
"method": method, "params": params or [],
}, timeout=30.0)
return resp.json()
# Get SOL balance
result = rpc_call("getBalance", ["WALLET_PUBKEY"])
sol_balance = result["result"]["value"] / 1e9
# Get latest blockhash
result = rpc_call("getLatestBlockhash")
blockhash = result["result"]["value"]["blockhash"]RPC Providers
| Provider | Free Tier | Paid | Notes | |----------|-----------|------|-------| | Helius | 50K credits/day | $49+/mo | Enhanced RPCs, DAS API | | QuickNode | Limited | $49+/mo | Multi-chain, WebSocket | | Triton | No free tier | ~$300+/mo | Yellowstone gRPC bundled | | Shyft | Limited | $49+/mo | Yellowstone gRPC bundled | | Alchemy | 300M CU/mo | Scaling | Good free tier | | Public (mainnet-beta) | Free | — | Rate limited, unreliable |
**Recommendation**: Use Helius or QuickNode for development. Never use public RPC for production trading.
Core Read Methods
Account & Balance
# SOL balance (in lamports, divide by 1e9 for SOL)
getBalance(pubkey, {commitment: "confirmed"})
# Full account info (data, owner, lamports, executable)
getAccountInfo(pubkey, {encoding: "jsonParsed"})
# Multiple accounts in one call
getMultipleAccounts([pubkey1, pubkey2], {encoding: "jsonParsed"})Token Accounts
# All SPL token accounts owned by a wallet
getTokenAccountsByOwner(wallet_pubkey, {
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}, {"encoding": "jsonParsed"})
# Token balance for a specific token account
getTokenAccountBalance(token_account_pubkey)
# Largest token accounts (top holders)
getTokenLargestAccounts(mint_pubkey)
# Total supply of a token
getTokenSupply(mint_pubkey)Transaction Data
# Get parsed transaction by signature
getTransaction(signature, {
"encoding": "jsonParsed",
"maxSupportedTransactionVersion": 0,
})
# Recent transaction signatures for an address
getSignaturesForAddress(pubkey, {
"limit": 20,
"before": "optional_signature", # pagination cursor
})
# Transaction status
getSignatureStatuses([sig1, sig2])Block & Slot
# Current slot
getSlot({commitment: "confirmed"})
# Block data
getBlock(slot, {
"encoding": "jsonParsed",
"transactionDetails": "full",
"maxSupportedTransactionVersion": 0,
})
# Latest blockhash (needed for tx building)
getLatestBlockhash({commitment: "confirmed"})
# Slot leader schedule
getLeaderSchedule()Program Accounts
# All accounts owned by a program (with filters)
getProgramAccounts(program_pubkey, {
"encoding": "jsonParsed",
"filters": [
{"dataSize": 165}, # Filter by account data size
{"memcmp": { # Filter by data content
"offset": 32,
"bytes": "base58_encoded_value",
}},
],
})**Warning**: `getProgramAccounts` without filters can return millions of results and timeout. Always use `dataSize` and/or `memcmp` filters.
Priority Fees
# Recent priority fee estimates
getRecentPrioritizationFees([account_pubkey])
# Returns array of { slot, prioritizationFee } for recent slots
# Minimum rent for account
getMinimumBalanceForRentExemption(data_length)Write Methods
Send Transaction
# Send a signed, serialized transaction
sendTransaction(base64_tx, {
"encoding": "base64",
"skipPreflight": False,
"preflightCommitment": "confirmed",
"maxRetries": 3,
})
# Simulate before sending
simulateTransaction(base64_tx, {
"encoding": "base64",
"sigVerify": False,
"commitment": "confirmed",
})Transaction Confirmation
import time
def confirm_transaction(rpc_url: str, signature: str, timeout: float = 30.0) -> bool:
"""Poll for transaction confirmation."""
start = time.time()
while time.time() - start < timeout:
result = rpc_call("getSignatureStatuses", [[signature]])
statuses = result.get("result", {}).get("value", [None])
if statuses[0] is not None:
status = statuses[0]
if status.get("err"):
return False
if status.get("confirmationStatus") in ("confirmed", "finalized"):
return True
time.sleep(0.5)
return FalseCommitment Levels
| Level | Description | Use When | |-------|-------------|----------| | `processed` | Single node confirmation | Speed over safety | | `confirmed` | Supermajority (2/3+) | **Default for trading** | | `finalized` | Maximum supermajority + 31 slots | Critical operations |
Always specify commitment explicitly. Default varies by provider.
Common Patterns
Get All Token Holdings for a Wallet
def get_wallet_tokens(wallet: str) -> list[dict]:
"""Get all SPL token holdings with metadata."""
result = rpc_call("getTokenAccountsByOwner", [
wallet,
{"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},
{"encoding": "jsonParsed"},
])
tokens = []
for acct in result["result"]["value"]:
info = acct["account"]["data"]["parsed"]["info"]
tokens.append({
"mint": info["mint"],
"amount": int(info["tokenAmount"]["amount"]),
"dA comprehensive collection of 67 ready-to-use trading, DeFi, and quantitative finance Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, and 30+ other tools.
Repo: agiprolabs/claude-trading-skills
Other skills on trading-skills.
- /backtrader
Event-driven backtesting with bar-by-bar execution, complex order types, multiple analyzers, and custom indicators
Open skill - /birdeye-api
Solana token market data via Birdeye — prices, OHLCV, trades, token metadata, security checks, and trader activity
Open skill - /coingecko-api
Broad crypto market data from CoinGecko covering 13,000+ tokens. Global market stats, historical price data going back years, exchange volumes, trending tokens, and category filters. Best for macro analysis and long-term historical data.
Open skill - /cointegration-analysis
Cointegration testing for pairs trading using Engle-Granger, Johansen, and rolling stability analysis
Open skill - /copy-trading
Wallet evaluation, monitoring, and copy-trade strategy design for Solana DEX trading
Open skill - /correlation-analysis
Cross-asset correlation analysis including rolling correlation, hierarchical clustering, tail dependence, and regime-dependent correlation
Open skill

