Pure Zig implementation of Reown AppKit (formerly WalletConnect) for backend services.
- Full AppKit connection management
- Wagmi adapter integration
- Wallet connection and authentication
- Network switching
- Message signing
- Transaction handling
- Store management for state persistence
- HTTP/RPC client for blockchain interaction
- Environment configuration support
Run this command in your project directory:
zig fetch --save https://github.com/avosa/zig-wagmi/archive/refs/heads/main.tar.gzThis will automatically add the dependency to your build.zig.zon with the correct hash.
Add to your build.zig.zon:
.dependencies = .{
.zig_wagmi = .{
.url = "https://github.com/avosa/zig-wagmi/archive/refs/heads/main.tar.gz",
// Replace with actual hash from zig fetch command
.hash = "12200000000000000000000000000000000000000000000000000000000000000000",
},
},const zig_wagmi = b.dependency("zig_wagmi", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("appkit", zig_wagmi.module("appkit"));Set your Reown project ID in environment variables:
export REOWN_PROJECT_ID=your_project_id_hereOr create a .env file:
REOWN_PROJECT_ID=your_project_id_here
const std = @import("std");
const appkit = @import("appkit");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const config = try appkit.config.Config.init(allocator);
defer config.deinit();
const networks = [_]appkit.network.Network{
appkit.network.MAINNET,
appkit.network.POLYGON,
};
const wagmi_adapter = try allocator.create(appkit.WagmiAdapter);
wagmi_adapter.* = try appkit.WagmiAdapter.init(allocator, .{
.project_id = config.project_id,
.networks = &networks,
});
const app = try appkit.AppKit.createAppKit(allocator, .{
.adapters = &[_]*appkit.WagmiAdapter{wagmi_adapter},
.networks = &networks,
.project_id = config.project_id,
});
try app.connect();
app.disconnect();
}AppKit- Main application kit interfaceWagmiAdapter- Wagmi protocol adapterWallet- Wallet interaction methodsNetwork- Network configuration and managementStore- State management and persistenceHttpClient- HTTP client for API callsRpcClient- JSON-RPC client for blockchain interactionConfig- Environment configuration
MAINNET- Ethereum MainnetPOLYGON- Polygon NetworkARBITRUM- Arbitrum OneOPTIMISM- OptimismAVALANCHE- Avalanche C-ChainBSC- BNB Smart ChainBASE- BaseZKSYNC- zkSync EraCELO- CeloSEPOLIA- Sepolia Testnet
zig buildzig build testMIT