| Crates.io | walletkit |
| lib.rs | walletkit |
| version | 0.3.5 |
| created_at | 2024-12-10 14:29:33.016431+00 |
| updated_at | 2026-01-24 22:40:00.046501+00 |
| description | Reference implementation for World ID clients. |
| homepage | https://docs.world.org |
| repository | https://github.com/worldcoin/walletkit |
| max_upload_size | |
| id | 1478549 |
| size | 161,219 |
WalletKit enables mobile applications to use World ID.
Part of the World ID SDK.
WalletKit can be used as a Rust crate, or directly as a Swift or Android package. WalletKit includes foreign bindings for direct usage in Swift/Kotlin through UniFFI.
To use WalletKit in another Rust project:
cargo install walletkit
To use WalletKit in an iOS app:
WalletKit is distributed through a separate repo specifically for Swift bindings. This repo contains all the binaries required and is a mirror of @worldcoin/walletkit.
https://github.com/worldcoin/walletkit-swiftTo use WalletKit in an Android app:
WalletKit's bindings for Kotlin are distributed through GitHub packages.
build.gradle (App Level)dependencies {
/// ...
implementation "org.world:walletkit-android:VERSION"
}
Replace VERSION with the desired WalletKit version.
Docker Desktop: Required for cross-compilation
cross which runs builds in Docker containers with all necessary toolchainsbrew install --cask docker
Android SDK + NDK: Required for Gradle Android tasks
sdk.dir (and ndk.dir if needed) in kotlin/local.propertiesProtocol Buffers compiler:
brew install protobuf
To test local changes before publishing a release, use the build script to compile the Rust library, generate UniFFI bindings, and publish a SNAPSHOT to Maven Local:
./build_android_local.sh 0.3.1-SNAPSHOT
Note: The script sets
RUSTUP_HOMEandCARGO_HOMEto/tmpby default to avoid Docker permission issues when usingcross. You can override them by exporting your own values.
This will:
~/.m2/repository/org/world/walletkit-android/In your consuming project, ensure mavenLocal() is included in your repositories and update your dependency version to the SNAPSHOT version (e.g., 0.3.1-SNAPSHOT).
WalletKit is broken down into separate crates, offering the following functionality.
walletkit-core - Enables basic usage of a World ID to generate ZKPs using different credentials.WalletKit is generally centered around a World ID. The most basic usage requires initializing a WorldId.
A World ID can then be used to generate Zero-Knowledge Proofs.
A ZKP is analogous to presenting a credential.
use walletkit::{proof::ProofContext, CredentialType, Environment, world_id::WorldId};
async fn example() {
let world_id = WorldId::new(b"not_a_real_secret", &Environment::Staging);
let context = ProofContext::new("app_ce4cb73cb75fc3b73b71ffb4de178410", Some("my_action".to_string()), None, CredentialType::Orb);
let proof = world_id.generate_proof(&context).await.unwrap();
println!(proof.to_json()); // the JSON output can be passed to the Developer Portal, World ID contracts, etc. for verification
}
WalletKit includes logging functionality that can be integrated with foreign language bindings. The logging system allows you to capture debug information and operational logs from the library.
Implement the Logger trait and set it as the global logger:
use walletkit_core::logger::{Logger, LogLevel, set_logger};
use std::sync::Arc;
struct MyLogger;
impl Logger for MyLogger {
fn log(&self, level: LogLevel, message: String) {
println!("[{:?}] {}", level, message);
}
}
// Set the logger once at application startup
set_logger(Arc::new(MyLogger));
class WalletKitLoggerBridge: WalletKit.Logger {
static let shared = WalletKitLoggerBridge()
func log(level: WalletKit.LogLevel, message: String) {
// Forward to your app's logging system
Log.log(level.toCoreLevel(), message)
}
}
// Set up the logger in your app delegate
public func setupWalletKitLogger() {
WalletKit.setLogger(logger: WalletKitLoggerBridge.shared)
}
class WalletKitLoggerBridge : WalletKit.Logger {
companion object {
val shared = WalletKitLoggerBridge()
}
override fun log(level: WalletKit.LogLevel, message: String) {
// Forward to your app's logging system
Log.log(level.toCoreLevel(), message)
}
}
// Set up the logger in your application
fun setupWalletKitLogger() {
WalletKit.setLogger(WalletKitLoggerBridge.shared)
}