Pre-1.0 Notice: This SDK is under active development. The API may change between minor versions until 1.0.
A high-level Swift client for the Algorand blockchain. Built on swift-algorand with Swift 6 and async/await.
- Effortless Setup - Connect to testnet, mainnet, or localnet with a single line
- Simplified Transactions - Send payments without manual parameter fetching
- Asset Management - Create, transfer, and manage ASAs with intuitive methods
- Application Support - Deploy and interact with smart contracts
- Atomic Transactions - Build transaction groups with a fluent DSL
- Actor-Based - Thread-safe by design using Swift concurrency
- Multi-Platform - iOS 15+, macOS 11+, tvOS 15+, watchOS 8+, visionOS 1+, Linux
Add AlgoKit to your Package.swift:
dependencies: [
.package(url: "https://github.com/CorvidLabs/swift-algokit.git", from: "0.0.1")
]
// Add the dependency to your target:
.target(
name: "YourApp",
dependencies: [
.product(name: "AlgoKit", package: "swift-algokit")
]
)Or add it via Xcode:
- File > Add Package Dependencies
- Enter:
https://github.com/CorvidLabs/swift-algokit.git
- Getting Started - Step-by-step guide for your first transaction
- Quick Start - Test the SDK in 5 minutes
- Testing Guide - Comprehensive testing instructions
- Security - Best practices for production use
- Contributing - How to contribute to the project
import AlgoKit
// Connect to a network
let algokit = AlgoKit(network: .testnet)
// Generate or recover an account
let account = try algokit.generateAccount()
// or: let account = try algokit.account(from: "your mnemonic...")
// Check balance
let balance = try await algokit.balance(of: account.address)
print("Balance: \(balance.algos) ALGO")
// Send a payment
let result = try await algokit.sendAndWait(
from: account,
to: receiver,
amount: .algos(1.5),
note: "Hello Algorand!"
)
print("Confirmed in round \(result.confirmedRound!)")// Predefined networks
let testnet = AlgoKit(network: .testnet)
let mainnet = AlgoKit(network: .mainnet)
let localnet = AlgoKit(network: .localnet)
// Custom endpoint
let custom = AlgoKit(configuration: .custom(
algodURL: URL(string: "https://my-node.com")!,
indexerURL: URL(string: "https://my-indexer.com")!,
apiToken: "my-api-token"
))// Create a fungible token
let assetID = try await algokit.createAsset(
from: creator,
name: "My Token",
unitName: "MTK",
total: 1_000_000,
decimals: 6
)
// Opt-in to receive the asset
_ = try await algokit.optIn(account: receiver, toAsset: assetID)
// Transfer tokens
_ = try await algokit.transferAsset(
assetID,
from: sender,
to: receiver.address,
amount: 1000
)
// Check holdings
let holdings = try await algokit.assetHoldings(of: account.address)try await algokit.atomic()
.pay(from: alice.address, to: bob.address, amount: .algos(5))
.transferAsset(assetID, from: bob.address, to: alice.address, amount: 1000)
.build()
.signedBy([alice, bob])
.submit()// Create an application
let appID = try await algokit.createApplication(
from: creator,
approvalProgram: approvalBytecode,
clearStateProgram: clearBytecode,
globalStateSchema: StateSchema(numUints: 1, numByteSlices: 1),
localStateSchema: StateSchema(numUints: 0, numByteSlices: 0)
)
// Call the application
_ = try await algokit.callApplication(
appID,
from: caller,
arguments: [Data("hello".utf8)]
)
// Opt-in to the application
_ = try await algokit.optInToApplication(appID, from: user)Access the underlying clients for custom transaction building:
// Direct access to AlgodClient
let params = try await algokit.algodClient.transactionParams()
// Build custom transaction
let tx = PaymentTransaction(
sender: account.address,
receiver: receiver,
amount: .algos(1),
firstValid: params.firstRound,
lastValid: params.firstRound + 1000,
genesisID: params.genesisID,
genesisHash: params.genesisHash
)
// Submit via wrapper
let txid = try await algokit.submit(tx, signedBy: account)generateAccount()- Create a new random accountaccount(from:)- Recover an account from mnemonicbalance(of:)- Get account balanceaccountInfo(_:)- Get full account information
send(from:to:amount:note:)- Send AlgossendAndWait(from:to:amount:note:timeout:)- Send and wait for confirmation
createAsset(from:name:unitName:total:decimals:...)- Create an ASAoptIn(account:toAsset:)- Opt into an assettransferAsset(_:from:to:amount:)- Transfer an assetassetHoldings(of:)- Get asset holdingscloseOutAsset(_:from:to:)- Close out of an assetfreezeAsset(_:from:target:frozen:)- Freeze/unfreeze asset holdingsconfigureAsset(_:from:manager:reserve:freeze:clawback:)- Update asset configdestroyAsset(_:from:)- Destroy an assetclawbackAsset(_:from:target:to:amount:)- Claw back assets
createApplication(from:approvalProgram:clearStateProgram:...)- Create an appcallApplication(_:from:arguments:...)- Call an appoptInToApplication(_:from:arguments:)- Opt into an appcloseOutApplication(_:from:arguments:)- Close out from an appupdateApplication(_:from:approvalProgram:clearStateProgram:...)- Update an appdeleteApplication(_:from:arguments:)- Delete an app
transactionParams()- Get suggested transaction parameterswaitForConfirmation(_:timeout:)- Wait for transaction confirmationpendingTransaction(_:)- Get pending transaction statussubmit(_:signedBy:)- Sign and submit a transactionsubmitGroup(_:signedBy:)- Sign and submit an atomic group
searchTransactions(for:limit:)- Search transactionssearchAssets(name:limit:)- Search assetsgetAsset(_:)- Get asset informationgetApplication(_:)- Get application information
The SDK supports testing against three networks:
# Start local Algorand network with Docker
docker-compose up -d
# Run integration tests
ALGORAND_NETWORK=localnet swift test
# Manual testing
ALGORAND_NETWORK=localnet swift run algokit-example# Create account and get test funds
ALGORAND_NETWORK=testnet swift run algokit-example
# Fund at: https://bank.testnet.algorand.network/
# Test with your account
export ALGORAND_MNEMONIC="your 25 word mnemonic"
ALGORAND_NETWORK=testnet SEND_TRANSACTION=1 swift run algokit-example# Read-only queries (safe)
ALGORAND_NETWORK=mainnet swift run algokit-exampleSee Testing Guide for detailed testing instructions.
- Swift 6.0+
- iOS 15.0+ / macOS 11.0+ / tvOS 15.0+ / watchOS 8.0+ / visionOS 1.0+
- Linux (with Swift 6.0+)
- Docker (optional, for localnet testing)
MIT License - See LICENSE file for details
The repository includes runnable examples:
- Payment transaction examples
- Asset creation and management
- Application deployment and interaction
- Atomic transaction groups
Run the examples:
# Run with TestNet
ALGORAND_NETWORK=testnet swift run algokit-example
# Run with LocalNet
docker-compose up -d
ALGORAND_NETWORK=localnet swift run algokit-exampleContributions are welcome! See CONTRIBUTING.md for guidelines.
- Algorand Developer Portal
- Algorand REST API
- Indexer API
- swift-algorand - The underlying SDK
Built with inspiration from the Swift Algorand SDK ecosystem and modern Swift best practices.