Swiftpack.co - KevinVitale/Web3Kit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by KevinVitale.
KevinVitale/Web3Kit 0.0.2
Ethereum JSON-RPC in Swift 5
⭐️ 1
🕓 2 weeks ago
iOS macOS
.package(url: "https://github.com/KevinVitale/Web3Kit.git", from: "0.0.2")


  • macOS, v10.15+;
  • iOS, v13+;
  • Linux

Adding Web3Kit as a Dependency

To use the Web3Kit library in a Swift Package Manager (SPM) project, add the following line to the dependencies in you Package.swift file:

.package(url: "https://github.com/KevinVitale/Web3Kit", from: "0.0.2"),

The Web3Kit library is under active development, and while attempts are made to maintain source-stability, this is not guaranteed between minor versions. You may specify .upToNextMinor(from:), instead of from(_:), if you need to be at a specific version.


A Web3Kit clients can work with any node source, such as:

  • a local Ganache node (even one running inside a Docker container);
  • a local network Geth node;
  • an Infura node!

All this makes testing on macOS, iOS, or Linux really simple.

Example: Requests

An architectural goal for Web3Kit is to be small, yet flexible and expressive.

For any request you want to make, call (request:parameters:) with a string literal:

// Create a client
let web3 = Web3Client("")

// Calls 'web3_sha3'
let result = try await web3(request: "sha3", parameters: ["0xdeadbeef"]).result
print(result ?? "")

For convenience, most requests have statically defined equivalents. For the above example:

// Create a client
let web3 = Web3Client("")

// Calls 'web3_sha3'
let result = try await web3(request: .sha(data: "0xdeadbeef")).result
print(result ?? "")

Example: Checking balances

This example checks the balances of all the accounts on the node. It also demonstrates how my micro-framework, Wei can be used to convert String values:

// Create a client
let web3 = Web3Client("")

// Use `.eth' to invoke domain-specific API requests
let balance = web3.eth(request: "getBalance", parameters: ["0x0000000000000000000000000000000000000000"]).result ?? ""

// Print the amount in ETHER
print(balance(as: .wei).to(.ether))

Related Projects

Web3Kit is part of a suite of Ethereum tools and frameworks built for those who ❤️ Swift.


Stars: 1
Last commit: 1 week ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups


Release Notes

Structured concurrency
2 weeks ago

Structured Concurrency Edition

Waring: breaking changes abound.

  • Removes all callbacks in favor of async/await
  • Enjoy! 🎉

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