Raiden1411/zabi
Interact with ethereum and EVM based chains via Zig!
A zig library to interact with EVM blockchains
Zabi aims to add support for interacting with ethereum or any compatible EVM based chain.
Zabi will support zig v0.13 in separate branches. If you would like to use it you can find it in the zig_version_0.13.0
branch where you can build it against zig 0.13.0.
The main branch of zabi will follow the latest commits from zig and the other branch will be stable in terms of zig versions but not features from zabi.
You can check how to integrate ZABI in your project here
const args_parser = zabi.args;
const std = @import("std");
const zabi = @import("zabi");
const Wallet = zabi.clients.wallet.Wallet(.http);
const CliOptions = struct {
priv_key: [32]u8,
url: []const u8,
};
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var iter = try std.process.argsWithAllocator(gpa.allocator());
defer iter.deinit();
const parsed = args_parser.parseArgs(CliOptions, gpa.allocator(), &iter);
const uri = try std.Uri.parse(parsed.url);
var wallet = try Wallet.init(parsed.priv_key, .{
.allocator = gpa.allocator(),
.network_config = .{ .endpoint = .{ .uri = uri } },
}, false);
defer wallet.deinit();
const message = try wallet.signEthereumMessage("Hello World");
const hexed = try message.toHex(wallet.allocator);
defer gpa.allocator().free(hexed);
std.debug.print("Ethereum message: {s}\n", .{hexed});
}
Explore the docs to find out more on how you can use or integrate Zabi in your project!
You can install the latest version of zig here or you can also use a version manager like zvm to manage your zig version.
And a lot more yet to come...
The goal of zabi is to be one of the best library to use by the ethereum ecosystem and to expose to more people to the zig programming language.
Contributions to Zabi are greatly appreciated! If you're interested in contributing to ZAbi, feel free to create a pull request with a feature or a bug fix.
You can also read the contributing guide before submitting a pull request
If you find Zabi useful or use it for work, please consider supporting development on GitHub Sponsors or sending crypto to zzabi.eth or interacting with the drip platform where 40% of the revenue gets sent to zabi's dependencies. Thank you 🙏