I'm excited to introduce SpaceKit, the first smart contract framework built for Swift! After 10 months of development, SpaceKit is now in beta, making it possible to write and test blockchain smart contracts using Swift.
It enables Swift developers to build decentralized applications natively on all SpaceVM-compatible blockchains, especially on MultiversX. This works by compiling Swift code into WebAssembly.
What is SpaceKit?
SpaceKit is a developer-first framework designed to make smart contract development intuitive and efficient while taking advantage of Swiftβs expressiveness.
Key Features
Swift-Powered Smart Contracts β No need for Rust, Solidity, or other languages
High-Level Abstractions β Work with
BigUInt
, Vector
, Buffer
, and more
Seamless Storage Management β Use
@Storage
, @Event
, and custom mappers
Async Calls & Callbacks β Easily manage inter-contract calls
Secure Randomness β Generate random numbers with SpaceVM's built-in features
Full ESDT Support β Issue, mint, burn, and manage fungible & non-fungible tokens
Cross-Platform Support β Works on macOS, Linux, and Windows (via WSL)
Developer-Friendly CLI β Compile contracts, generate ABIs, and deploy with ease
Rust Compatibility β Swift contracts can interact with Rust contracts
import SpaceKit
@Init func initialize(initialValue: BigUint) {
var controller = AdderController()
controller.sum = initialValue
}
@Controller public struct AdderController {
@Storage(key: "sum") var sum: BigUint
public mutating func add(value: BigUint) {
self.sum = self.sum + value
}
public func getSum() -> BigUint {
return self.sum
}
}
The SwiftVM β A Swift-Based Testing Environment
Testing blockchain contracts is simplified with SwiftVM, a Swift-based replica of SpaceVM that allows:
- Running contract endpoints and verifying results
- Simulating transactions and failures
- Debugging with Xcodeβs built-in tools
- Testing contract-to-contract interactions
- Managing ESDT tokens within test scenarios
With SwiftVM, you donβt need external testing tools,
everything runs natively in Swift.
func testDeployAdderInitialValueNonZero() throws {
try self.deployContract(
at: "adder",
arguments: [
15
]
)
let controller = self.instantiateController(AdderController.self, for: "adder")!
let result = try controller.getSum()
XCTAssertEqual(result, 15)
}
Documentation & AI Assistance
To make onboarding easy, SpaceKit comes with:
11-Chapter Interactive Tutorial β Learn contract development step by step
22+ Example Contracts β From simple adders to multisigs
568+ Test Cases β Covering real-world scenarios
Custom GPT Assistant β Get instant help while coding
More learning resources are coming soon!
The Future of SpaceKit
Short-term goals:
- Incorporate developer feedback & refine documentation
Mid-term plans:
- Enhance the CLI & SwiftVM for a smoother developer experience
Long-term vision:
- A full Swift-based stack for Web3 β smart contracts, backends, and iOS/macOS frontends in a single ecosystem
Get Started Today!
SpaceKit Repository: GitHub
Interactive Tutorials: Learn SpaceKit
GPT Assistant: Ask Questions
More about SpaceVM: MultiversX Documentation
Would love to hear your feedback! Letβs build the future of Web3 in Swift!