Swiftpack.co -  OpenZesame/Zesame as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Swift SDK for Zilliqa
.package(url: "https://github.com/OpenZesame/Zesame.git", from: "1.1.1")


Zesame is an unofficial Swift SDK for Zilliqa. It is written in Swift 5.3. This SDK contains cryptographic methods allowing you to create and restore a wallet, sign and broadcast transactions. The cryptographic methods are implemented in EllipticCurveKit. This SDK uses Zilliqas JSON-RPC API

Getting started

SPM will install all dependencies, either when run from terminal, or when Xcode gets opened. To run tests it is recommended to use optimisation flag, otherwise it takes quite a bit of time to run them:

swift test -Xswiftc -O


Zesame uses the JSON-RPC API and not the protobuf API, however, for the packaging of the transaction we need to use protobuf. Please note that protocol buffers is only used for the packaging of the transaction, it is not used at all for any communication with the API. All data is sent as JSON to the JSON-RPC API.

We use the apple/swift-protobuf project for protocol buffers, and it is important to note the two different programs associated with swift protobuf:

Install protobuf


This program is used only for generating our swift files from our .proto files and we install this program using brew (it can also be manually downloaded and built).

Follow installation instructions using brew here.

brew install swift-protobuf

After this is done we can generate .pb.swift files using

$ protoc --swift_out=. my.proto

SwiftProtobuf library

In order to make use of our generated .pb.swift files we need to include the SwiftProtobuf library, which is installed through SPM.

Use protobuf

Stand in the root of the project and run:

protoc --swift_opt=Visibility=Public --swift_out=. Sources/Zesame/Models/Protobuf/messages.proto

Add the generated file messages.pb.swift to Models folder.


You will find all dependencies inside the Package.swift, but to mention the most important:


Zesame is dependent on the Elliptic Curve Cryptography of EllipticCurveKit, for the generation of new wallets, restoration of existing ones, the encryption of your private keys into keystores and the signing of your transactions using Schnorr Signatures.


  • RxSwift: The library uses RxSwift for async programming.

  • JSONRPCKit: For consuming the Zilliqa JSON-RPC API.


Closure or Rx

This SDK contains two implementations for each method, one that uses Closures(a.k.a. "Callbacks") and one implementation using RxSwift Observables.


DefaultZilliqaService.shared.rx.getBalance(for: address).subscribe(
    onNext: { print("Balance: \($0.balance)") },
    onError: { print("Failed to get balance, error: \($0)") }
).disposed(by: bag)


DefaultZilliqaService.shared.getBalance(for: address) {
    switch $0 {
    case .success(let balanceResponse): print("Balance: \(balanceResponse.balance)") 
    case .failure(let error): print("Failed to get balance, error: \(error)")


Have a look at ZilliqaService.swift for an overview of the functions, here is a snapshot of the current functions of the reactive API (each function having a closure counterpart):

public protocol ZilliqaServiceReactive {
    func createNewWallet() -> Observable<Wallet>
    func exportKeystore(from wallet: Wallet, encryptWalletBy passphrase: String) -> Observable<Keystore>
    func importWalletFrom(keyStore: Keystore, encryptedBy passphrase: String) -> Observable<Wallet>

    func getBalance(for address: Address) -> Observable<BalanceResponse>
    func sendTransaction(for payment: Payment, signWith keyPair: KeyPair) -> Observable<TransactionIdentifier>


While developing it might be useful for you to use the Zilliqa explorer


This SDK and the foundation EllipticCurveKit its built upon has been developed by the single author Alexander Cyon without paid salary in his free time - approximately a thousand hours of work since May 2018 (see initial commit).

Any donation would be much appreciated:

  • ZIL: zil108t2jdgse760d88qjqmffhe9uy0nk4wvzx404t
  • BTC: 3GarsdAzLpEYbhkryYz1WiZxhtTLLaNJwo
  • ETH: 0xAB8F0137295BFE37f50b581F76418518a91ab8DB
  • NEO: AbbnnCLP26ccSnLooDDcwPLDnfXbVL5skH


Zesame is released under the MIT License.


Stars: 15
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Change min/default gasLimit to 50
2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API