Crates.io | tonlib-core |
lib.rs | tonlib-core |
version | |
source | src |
created_at | 2024-09-17 12:34:18.51818 |
updated_at | 2024-12-10 14:56:26.972767 |
description | Data structures library for tonlib-client |
homepage | |
repository | https://github.com/ston-fi/tonlib-rs |
max_upload_size | |
id | 1377399 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Rust SDK for The Open Network
To use this library in your Rust application, add the following to your Cargo.toml file:
[dependencies]
tonlib-core = "version"
Then, in your Rust code, you can import the library with:
use tonlib_core;
Data structures and helpers for building and parsing Cell and Bag of Cells. See the documentation on ton.org for details.
Data structures, builders, and parsers for Message See the documentation on ton.org for details.
Includes standard messages for Jetton, NFT, and Soulbound NFT, specified by TON Enhancement Proposal.
Data structure to store mnemonic.
Data structures for storage and easy conversion of Ton Smart-contract Address and Ton Transaction Id
Data structure for deriving wallet addresses.
Creating a Cell
and writing data to it:
use anyhow::anyhow;
use tonlib_core::TonAddress;
use tonlib_core::cell::CellBuilder;
fn write_cell() -> anyhow::Result<()> {
let mut writer = CellBuilder::new();
let addr = TonAddress::from_base64_url("EQDk2VTvn04SUKJrW7rXahzdF8_Qi6utb0wj43InCu9vdjrR")?;
let cell = writer
.store_u32(32, 0xFAD45AADu32)?
.store_bit(true)?
.store_u8(8, 234u8)?
.store_slice(&[0xFA, 0xD4, 0x5A, 0xAD, 0xAA, 0x12, 0xFF, 0x45])?
.store_address(&addr)?
.store_string("Hello, TON")?
.build()?;
# Ok(())
}
Reading data from a Cell
:
use tonlib_core::cell::Cell;
fn read_cell(cell: Cell) -> anyhow::Result<()> {
let mut reader = cell.parser();
let u32_value = reader.load_u32(32)?;
let bit_value = reader.load_bit()?;
let u8_value = reader.load_u8(8)?;
let bytes_value = reader.load_bytes(8)?;
let address_value = reader.load_address()?;
let str_value = reader.ensure_empty()?;
Ok(())
}