Skip to content

Human readable parsing

Definition

Zabi support parsing human readable solidity signatures.

It uses a solidity parser + lexer combo. These are not fully compatable with the solidity ast parser. Zabi exposes them but the recommended way to use the human readable parser is to call parseHumanReadable

The human readable parser support both tuples and structs. For structs that reference other structs these need to be in order otherwise this is return an error.

Usage

This expected 3 arguments:

  • The Abi type to parse to. It supports all abi items plus AbiParameters
  • The allocator to use to manage memory allocations.
  • The human readable abi signatures.
human.zig
const human = @import("zabi").human;
const testing = @import("std").testing;
 
const parsed = try human.parseHumanReadable(Abi, testing.allocator, slice); 
defer parsed.deinit();

Returns

Type: AbiParsed

AbiParsed

pub fn AbiParsed(comptime T: type) type {
    return struct {
        arena: *ArenaAllocator,
        value: T,
 
        pub fn deinit(self: @This()) void { ... }
    };
}