rootchain-core 1.0.2

Core types and foundational data structures for the RootChain ecosystem.
Documentation

rootchain-core

Crates.io License: MIT

Foundation types and data structures for the RootChain ecosystem.

This crate is the single source of truth for every primitive used across the RootChain monorepo. All other crates depend on it, making it the cornerstone of protocol correctness.


What's Inside

Module Description
types Core protocol types: Address, Hash, Transaction, Block, AccountState, EquivocationProof, and more
genesis Genesis block construction and initial chain state
test_utils Shared testing helpers for constructing mock transactions, blocks, and accounts

The serde_balance Module

A critical piece of infrastructure. The native balance type (u128) cannot safely cross JSON serialization boundaries due to JavaScript number precision limits (max safe int is 253 − 1, while u128 can hold up to 2128 − 1).

serde_balance transparently handles this:

  • Human-readable formats (JSON): Serializes u128 as a decimal string (e.g., "1000000").
  • Binary formats (Bincode): Serializes u128 as a raw 16-byte integer for maximum efficiency.
use rootchain_core::types::{Transaction, TransactionType};

// The `amount` and `fee` fields on Transaction use serde_balance automatically.
// You never need to think about precision loss.

Installation

[dependencies]
rootchain-core = "1.0.2"

For smart contract / no_std environments:

[dependencies]
rootchain-core = { version = "1.0.2", default-features = false }

Key Types

use rootchain_core::types::{Address, Hash, Block, Transaction, AccountState};

// A 32-byte Ed25519 public key used as a network address
let addr = Address([0u8; 32]);

// A 32-byte Blake3 hash
let hash = Hash::zero();

no_std Support

rootchain-core is fully compatible with no_std + alloc environments, making it usable inside WASM smart contracts compiled with rootchain-std.


License

MIT — See LICENSE for details.