Docs

Installation

How to add eth.zig to your Zig project.

Prerequisites

Add as a Dependency

One-liner:

zig fetch --save git+https://github.com/StrobeLabs/eth.zig.git#v0.1.0

Or add manually to your build.zig.zon:

.dependencies = .{
    .eth = .{
        .url = "git+https://github.com/StrobeLabs/eth.zig.git#v0.1.0",
        .hash = "...", // run `zig build` and it will tell you the expected hash
    },
},

Configure build.zig

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

Verify

const eth = @import("eth");

pub fn main() !void {
    // WARNING: This is a well-known Anvil/Hardhat test key. Never use it for real funds.
    const private_key = try eth.hex.hexToBytesFixed(32, "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
    const signer = eth.signer.Signer.init(private_key);
    const addr = try signer.address();
    const checksum = eth.primitives.addressToChecksum(&addr);
    // checksum == "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
    _ = checksum;
}

Build Commands

zig build                # Build
zig build test           # Unit tests
zig build integration-test  # Integration tests (requires Anvil)

Next Steps