SpaceKit - The First-Ever Swift Smart Contract Framework

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

:white_check_mark: Swift-Powered Smart Contracts – No need for Rust, Solidity, or other languages
:white_check_mark: High-Level Abstractions – Work with BigUInt, Vector, Buffer, and more
:white_check_mark: Seamless Storage Management – Use @Storage, @Event, and custom mappers
:white_check_mark: Async Calls & Callbacks – Easily manage inter-contract calls
:white_check_mark: Secure Randomness – Generate random numbers with SpaceVM's built-in features
:white_check_mark: Full ESDT Support – Issue, mint, burn, and manage fungible & non-fungible tokens
:white_check_mark: Cross-Platform Support – Works on macOS, Linux, and Windows (via WSL)
:white_check_mark: Developer-Friendly CLI – Compile contracts, generate ABIs, and deploy with ease
:white_check_mark: 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:

:open_book: 11-Chapter Interactive Tutorial – Learn contract development step by step
:scroll: 22+ Example Contracts – From simple adders to multisigs
:hammer_and_wrench: 568+ Test Cases – Covering real-world scenarios
:robot: 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!

:rocket: SpaceKit Repository: GitHub
:books: Interactive Tutorials: Learn SpaceKit
:robot: GPT Assistant: Ask Questions
More about SpaceVM: MultiversX Documentation

Would love to hear your feedback! Let’s build the future of Web3 in Swift! :fire:

2 Likes

SpaceKit 0.2.7 is out :raising_hands:

This version brings multiple fixes and features, the major ones being:

  • BigUint.min and BigUint.max are implemented
  • SingleValueMapper can be used as endpoint's return value
  • Possibility to manipulate the random seed in the swift tests

This version comes with a brand new DocCC interactive tutorial of 7 chapters where you'll see how to build and test from scratch a coin flip smart contract :books:

This tutorial covers a lot of concepts such as ESDT transfers, swift tests, randomness, admin endpoints, etc. each line is explained!

Link to the tutorial: Build a Coin Flip Contract

1 Like