solana-rpc-swift

Implement typed Solana JSON-RPC clients in Swift using URLSession and Codable.

2|Updated Sep 13, 2022
One-click install
npx skills add https://github.com/horizontalsystems/solana-kit-ios --skill solana-rpc-swift
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: solana-rpc-swift
Source: https://github.com/horizontalsystems/solana-kit-ios/tree/main/.claude/skills/solana-rpc-swift
Command: npx skills add https://github.com/horizontalsystems/solana-kit-ios --skill solana-rpc-swift

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Solana RPC tasks require typed, maintainable Swift code; this skill provides a structured approach with typed request/response models, a generic RpcClient, and clear patterns for common RPC methods.

Core Features & Use Cases

  • Typed request/response models (RpcRequest, RpcResponse, RpcError)
  • Generic RpcClient with an RpcSource and support for commitments, blockhash handling, and error decoding
  • Convenience methods for major Solana RPC calls (getBalance, getLatestBlockhash, getTokenAccountsByOwner, getTransaction, sendTransaction, simulateTransaction, getSlot, getBlockHeight)

Quick Start

Instantiate RpcClient with a RpcSource and call methods like getBalance or sendTransaction to interact with Solana RPC.

Frequently Asked Questions about solana-rpc-swift

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call Solana JSON-RPC methods in Swift without third-party libraries?

You can call Solana JSON-RPC methods in Swift using URLSession and Codable. This approach provides a typed RpcClient with request/response models to handle balance checks and transaction submissions natively.

How do I get a Solana blockhash and submit a transaction in Swift?

To get a Solana blockhash and submit a transaction in Swift, use a typed RpcClient to call getLatestBlockhash for the blockhash, then pass the transaction to sendTransaction for submission.

Can I query SPL token accounts by owner on Solana using Swift Codable?

Yes, you can query SPL token accounts by owner on Solana using Swift Codable. The client provides a getTokenAccountsByOwner method with typed request and response models for decoding.

What's the best way to handle Solana RPC errors and commitment levels in an iOS app?

Handling Solana RPC errors and commitment levels in an iOS app is done using a typed RpcError model and configurable commitment parameters passed directly to the generic RpcClient methods.

Does a native Swift Solana RPC client support transaction simulation?

A native Swift Solana RPC client supports transaction simulation through the simulateTransaction method. This allows you to test transaction execution against the network using URLSession before actual submission.