#blockchain #tycho #status

tycho-types

A set of primitive types and utilities for the Tycho node

3 unstable releases

Uses new Rust 2024

0.3.0 Sep 30, 2025
0.2.1 Jul 25, 2025
0.2.0 Jun 26, 2025

#10 in #tycho

Download history 79/week @ 2025-08-16 45/week @ 2025-08-23 134/week @ 2025-08-30 64/week @ 2025-09-06 48/week @ 2025-09-13 45/week @ 2025-09-20 308/week @ 2025-09-27 114/week @ 2025-10-04 127/week @ 2025-10-11 226/week @ 2025-10-18 123/week @ 2025-10-25 120/week @ 2025-11-01 68/week @ 2025-11-08 89/week @ 2025-11-15 84/week @ 2025-11-22 121/week @ 2025-11-29

369 downloads per month
Used in 18 crates (16 directly)

MIT/Apache

1.5MB
38K SLoC

tycho-types   crates-io-batch docs-badge rust-version-badge workflow-badge

Status: WIP

About

A set of primitive types and utilities for the Tycho node.

Basic usage

Decode Cell from bytes using the BOC (Bag Of Cells) format:

use tycho_types::boc::Boc;

let cell: Cell = Boc::decode(bytes)?;

Encode TLB model e.g.MerkleProof:

use tycho_types::boc::BocRepr;

let proof = MerkleProof::create_for_cell(cell.as_ref(), some_filter).build()?;

let encoded = BocRepr::encode_base64(proof)?;
let decoded = BocRepr::decode_base64(encoded)?:

Parse TLB type from Cell:

use tycho_types::models::BlockProof;

let proof: BlockProof = cell.parse::<BlockProof>()?;

Parse TLB type from proof cell (partially pruned):

use tycho_types::cell::DynCell;
use tycho_types::models::Block;

let virt_cell: &DynCell = proof.virtualize();
let block = virt_cell.parse::<Block>()?;

Use CellBuilder to create any Cell:

let mut builder = CellBuilder::new();
builder.store_bit_one()?;
builder.store_u32(100u32)?
builder.store_slice(slice)?;
builder.store_raw(&[0xdd, 0x55], 10)?;

// store references to another cells
builder.store_reference(cell)?;
builder.store_reference(another_cell)?;

let final_cell: Cell = builder.build()?;

// === or ===
let other_cell: Cell = CellBuilder::build_from((
    true,
    100u32,
    cell,
    another_cell,
))?;

Development

How to bench

cargo bench boc
cargo bench dict

How to miri check

# Add Miri component
rustup +nightly component add miri

# Run all tests with Miri
cargo +nightly miri test

How to fuzz

# Install fuzzer
cargo install cargo-fuzz

# Run any of the fuzzer targets
cargo +nightly fuzz run boc_decode -j 12
cargo +nightly fuzz run boc_decode_encode -j 12
cargo +nightly fuzz run boc_decode_pair -j 12
cargo +nightly fuzz run boc_dict -j 12
cargo +nightly fuzz run boc_message -j 12

Contributing

We welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.

License

Licensed under either of

at your option.

Dependencies

~2–5.5MB
~108K SLoC