HeliosKit

Swift 5.2 Platforms Swift Package Manager License: MIT GitHub tag

Helios is a fully trustless, efficient, and portable Ethereum light client written in Rust.

Helios converts an untrusted centralized RPC endpoint into a safe unmanipulable local RPC for its users. It syncs in seconds, requires no storage, and is lightweight enough to run on mobile devices.

This Swift Package is a wrapper around Helios’ Rust library.

Installation

Add the package declaration to your project’s manifest dependencies array:

.package(url: "https://github.com/rkreutz/HeliosKit.git", from: "0.1.0")

Usage

You can start a client with:

let rpcURL = // URL to the unsafe RPC
try await Helios.shared.start(rpcURL: rpcURL)

Have in mind that only one client can be running at all times.

Once the client is up and running you can start doing RPC calls to it, it will be listening to 127.0.0.1:8545.

You may also use the library to call methods from the RPC with:

let (data, _) = try await Helios.shared.call(method: "eth_getBalance", params: ["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"])
let response = String(data: data, encoding: .utf8)!
print(response) // {"jsonrpc":"2.0","result":"0x0000000000000000000000000000000000000000000000000000000000000000","id":...}

To shutdown your client gracefully, use the shutdown() method:

await Helios.shared.shutdown()

Building locally

There is a build.sh script in the repo which can be used to build the xcframework for the helios rust library, this will create the XCFramework and place it (along with the Swift bridging files and checksum) in the .build/helios-rs/build directory. You may provide an additional parameter to the script to build a debug or release framework.

> sh build.sh debug # .build/helios-rs/build/debug/helios.xcframework

> sh build.sh # .build/helios-rs/build/release/helios.xcframework

GitHub

View Github