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
- Select
File
/Swift Packages
/Add Package Dependency
from the menu. - 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.
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)
}
}
}
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