Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-wagmi

Pure Zig implementation of Reown AppKit (formerly WalletConnect) for backend services.

Features

  • 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

Installation

Option 1: Using zig fetch (Recommended)

Run this command in your project directory:

zig fetch --save https://github.com/avosa/zig-wagmi/archive/refs/heads/main.tar.gz

This will automatically add the dependency to your build.zig.zon with the correct hash.

Option 2: Manual Configuration

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",
    },
},

Add to your build.zig:

const zig_wagmi = b.dependency("zig_wagmi", .{
    .target = target,
    .optimize = optimize,
});
exe.root_module.addImport("appkit", zig_wagmi.module("appkit"));

Configuration

Set your Reown project ID in environment variables:

export REOWN_PROJECT_ID=your_project_id_here

Or create a .env file:

REOWN_PROJECT_ID=your_project_id_here

Quick Start

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();
}

API Reference

Core Modules

  • AppKit - Main application kit interface
  • WagmiAdapter - Wagmi protocol adapter
  • Wallet - Wallet interaction methods
  • Network - Network configuration and management
  • Store - State management and persistence
  • HttpClient - HTTP client for API calls
  • RpcClient - JSON-RPC client for blockchain interaction
  • Config - Environment configuration

Available Networks

  • MAINNET - Ethereum Mainnet
  • POLYGON - Polygon Network
  • ARBITRUM - Arbitrum One
  • OPTIMISM - Optimism
  • AVALANCHE - Avalanche C-Chain
  • BSC - BNB Smart Chain
  • BASE - Base
  • ZKSYNC - zkSync Era
  • CELO - Celo
  • SEPOLIA - Sepolia Testnet

Building

zig build

Testing

zig build test

License

MIT

About

Zig implementation of Reown AppKit (formerly WalletConnect) for backend services.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages