#primitive #utilities #everscale #type #blockchain #status #ton-labs-types

everscale-types

A set of primitive types and utilities for the Everscale blockchain

22 releases

0.1.2 Nov 12, 2024
0.1.0 Oct 31, 2024
0.1.0-rc.7 Jun 10, 2024
0.1.0-rc.6 Oct 24, 2023
0.1.0-pre.2 Dec 28, 2022

#1 in #everscale

Download history 149/week @ 2024-08-26 16/week @ 2024-09-02 17/week @ 2024-09-09 40/week @ 2024-09-16 56/week @ 2024-09-23 21/week @ 2024-09-30 13/week @ 2024-10-14 10/week @ 2024-10-21 183/week @ 2024-10-28 190/week @ 2024-11-04 172/week @ 2024-11-11 30/week @ 2024-11-18 42/week @ 2024-11-25 37/week @ 2024-12-02 41/week @ 2024-12-09

155 downloads per month
Used in 8 crates (6 directly)

MIT/Apache

1.5MB
34K SLoC

Logo

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

Status: WIP

About

A set of primitive types and utilities for the Everscale blockchain.

Heavily inspired by ton-labs-types, but with much more emphasis on speed.

Basic usage

Get Cell from Vec<u8> representation of bytes

use everscale_types::boc::Boc;

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

Encode any model e.g.MerkleProof to base64 BOC representation and vice versa

use everscale_types::boc::BocRepr;

let cell = MerkleProof::create_for_cell(cell.as_ref(), EMPTY_CELL_HASH)
            .build()
            .unwrap();

let encoded = BocRepr::encode_base64(&cell).unwrap();

let decoded = Boc::decode_base64(encoded)?.as_ref().parse::<MerkleProof>()?:

Get specific everscale type from Cell

use everscale_types::models::BlockProof;

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

Same usage for virtualized cell

use everscale_types::prelude::DynCell;
use everscale_types::models::Block;

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

You can also 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 = builder.build()?;

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

~1.8–4.5MB
~92K SLoC