Skip to content

RomarQ/substrate-scale-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Substrate SCALE Codec for Zig

⚠️ Warning: This project is a work in progress. The API is unstable and may change without notice.

A Zig implementation of the SCALE (Simple Concatenated Aggregate Little-Endian) encoding and decoding library for Substrate blockchain projects.

Overview

SCALE is a lightweight, efficient encoding and decoding codec used extensively in the Polkadot/Substrate ecosystem. This library provides a Zig implementation based on the Parity SCALE codec.

Installation

zig fetch --save git+https://github.com/RomarQ/substrate-scale-zig/#HEAD

Usage

Basic Example

const std = @import("std");
const scale = @import("scale");

pub fn main() !void {
    const allocator = std.heap.page_allocator;
    
    // Encoding
    const value: u32 = 42;
    const encoded = try scale.encoder.encodeAlloc(allocator, value);
    defer allocator.free(encoded);
    
    // Decoding
    const result = try scale.decoder.decodeAlloc(u32, encoded, allocator);
    std.debug.print("Decoded value: {}\n", .{result.value});
}

Testing

Run the tests with:

zig build test --summary all

About

Substrate SCALE Codec for Zig

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages