Repo image

Solana-Swift

Build & Test License: MIT swift-version

Solana Swift SDK (Based off https://docs.solana.com/developing/clients/jsonrpc-api).

This is actively WIP at the moment. PR's welcome! Development happening in the demo app repo

Getting Started

Swift Package Manager (Xcode 11 and above)

  1. Select File/Swift Packages/Add Package Dependency from the menu.
  2. Paste https://github.com/crewshin/solana-swift.git.

Why not CocoaPods, or Carthage?

Supporting multiple dependency managers makes maintaining a library exponentially more complicated and time consuming. Furthermore, with the integration of the Swift Package Manager in Xcode 11 and greater, I expect the need for alternative solutions to fade quickly.

Usage

import Solana

Create an instance of Solana:

let solana = Solana(network: .main)

or (not functional yet)

let solana = SolanaSockets(network: .main)

Then:

solana.getAccountInfo(pubkey: pubkey) { (result) in
    switch result {
    case .failure(let error):
        if case let SolanaAPIError.getAccountInfoError(message) = error {
            print(message)
        }
    case .success(let response):
        if let value = response.value {
            print(value)
        }
    }
}

WIP Status

I'm basically going down the list of methods from the JSON RPC

Right now I've implemented the foundational stuff and am n this commit, I've done a first pass on:

getAccountInfo
getBalance
getBlockCommitment
getBlockTime
getClusterNodes
getConfirmedBlock
getBlockProduction
getConfirmedBlocks
getConfirmedBlocksWithLimit
getConfirmedSignaturesForAddress
getConfirmedSignaturesForAddress2
getConfirmedTransaction
getEpochInfo
getEpochSchedule
getFeeCalculatorForBlockhash
getFeeRateGovernor

Feel free to say hi on Discord: crewshin#3286

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

Last updated: Mon Mar 18 2024 17:10:05 GMT-0900 (Hawaii-Aleutian Daylight Time)