Go to file
Rodrigo Kreutz e97a2709c5 Update helios to 0.4.0 2023-04-10 12:24:15 +01:00
.scripts Update helios to 0.4.0 2023-04-10 12:24:15 +01:00
.swiftpm/xcode/xcshareddata/xcschemes Directly accessing methods from the Helios client 2023-03-12 03:05:00 +00:00
Sources/HeliosKit Update helios to 0.4.0 2023-04-10 12:24:15 +01:00
Tests/HeliosKitTests Updating Helios version 2023-04-03 23:36:46 +01:00
.gitignore Updating Helios to 0.1.3 2023-03-01 21:05:14 +00:00
LICENSE Initial commit 2022-12-06 22:50:49 +00:00
Package.swift Update helios to 0.4.0 2023-04-10 12:24:15 +01:00
README.md Directly accessing methods from the Helios client 2023-03-12 03:05:00 +00:00
build_xcframework.sh Update helios to 0.4.0 2023-04-10 12:24:15 +01:00

README.md

HeliosKit

Swift 5.7 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()

Logging

You may enable logging of the Rust lib with an environment var at runtime (RUST_LOG). The library uses Rust's env_logger framework, so you may set the desired levels accordingly.

Screen Shot 2022-12-13 at 18 31 46

Building locally

There is a build_xcframework.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 specify which version you would like to build and provide an additional parameter to the script to build a debug or release framework.

> zsh build_xcframework.sh 0.1.3 debug # .build/helios-rs/build/0.1.3/debug/helios.xcframework

> zsh build_xcframework.sh 0.1.3 # .build/helios-rs/build/0.1.3/debug/helios.xcframework

> zsh build_xcframework.sh debug # No version specified, defaults to latest

> zsh build_xcframework.sh # No version specified, defaults to latest

Running the test target

To be able to compile the test target you must create a Config.swift file (you can just copy and rename Config.swift.example) and add the RPC URL you have for mainnet.

You may optionaly provide a rawTransaction data to test sendRawTransaction(_:).