{"id":28068393,"url":"https://github.com/sild/ton_lib_rs","last_synced_at":"2025-05-12T17:33:57.943Z","repository":{"id":290068701,"uuid":"973230810","full_name":"Sild/ton_lib_rs","owner":"Sild","description":"Bunch of tools to work with [TON](https://github.com/ton-blockchain) blockchain","archived":false,"fork":false,"pushed_at":"2025-05-11T19:52:54.000Z","size":674,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T20:29:17.420Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-26T14:48:26.000Z","updated_at":"2025-05-09T15:30:20.000Z","dependencies_parsed_at":"2025-05-11T20:34:47.874Z","dependency_job_id":null,"html_url":"https://github.com/Sild/ton_lib_rs","commit_stats":null,"previous_names":["sild/ton_lib_rs"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sild%2Fton_lib_rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sild%2Fton_lib_rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sild%2Fton_lib_rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sild%2Fton_lib_rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sild","download_url":"https://codeload.github.com/Sild/ton_lib_rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253632848,"owners_count":21939377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-12T17:33:16.778Z","updated_at":"2025-05-12T17:33:57.922Z","avatar_url":"https://github.com/Sild.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TonLib\n[![CI](https://github.com/sild/ton_lib_rs/actions/workflows/build.yml/badge.svg)](https://github.com/sild/ton_lib_rs/actions/workflows/build.yml)\n[![Crates.io](https://img.shields.io/crates/v/ton_lib.svg)](https://crates.io/crates/ton_lib)\n[![codecov](https://codecov.io/gh/sild/ton_lib_rs/branch/main/graph/badge.svg)](https://codecov.io/gh/sild/ton_lib_rs)\n\nThis crate is heavily based on the [tonlib-rs](https://github.com/ston-fi/tonlib-rs) repository and also uses [tonlib-sys](https://github.com/ston-fi/tonlib-sys) underneath for the [tonlibjson_client](ton_lib/src/clients/tonlib) implementation.\n\n## Features\n\n### [cell](ton_lib/src/cell) module\nBuild and read custom cells using [TonCell](ton_lib/src/cell/ton_cell.rs), and serialize them to bytes using [BOC](ton_lib/src/cell/boc/mod.rs):\n\n```rust\nfn main() -\u003e anyhow::Result\u003c()\u003e {\n    use ton_lib::cell::ton_cell::TonCell;\n    let mut builder = TonCell::builder();\n    builder.write_bits([1,2,3], 24).unwrap();\n    let cell = builder.build().unwrap();\n    assert_eq!(cell.data, vec![1, 2, 3]);\n    let mut parser = cell.parser();\n    let data = parser.read_bits(24).unwrap();\n    assert_eq!(data, [1, 2, 3]);\n}\n```\n\n---\n\n### [types](ton_lib/src/types) module\nContains 3 different layers:\n\n1. [tlb](ton_lib/src/types/tlb):  \n   The `TLBType` trait allows you to implement `serde` for your objects automatically.  \n   It also includes a collection of predefined TLB types.  \n   (Apologies for the `Dict` implementation — it's still in progress.)\n\n2. [client_types](ton_lib/src/types/client_types):  \n   Additional types for clients. (try don't use them!)\n\n3. The rest:  \n   High-level TON types such as `TonAddress` or `Wallet`.\n\n```rust\n#[derive(Debug, Clone, PartialEq, TLBDerive)]\n#[tlb_derive(ensure_empty = true)]\npub struct StateInit {\n    #[tlb_derive(bits_len = 5)]\n    pub split_depth: Option\u003cu8\u003e,\n    pub tick_tock: Option\u003cTickTock\u003e,\n    pub code: Option\u003cTonCellRef\u003e,\n    pub data: Option\u003cTonCellRef\u003e,\n    #[tlb_derive(adapter = \"TLBDict::\u003cDictKeyAdapterTonHash, DictValAdapterTLB, _, _\u003e::new(256)\")]\n    pub library: LibsDict,\n}\n\nfn main() {\n    let boc_hex = \"b5ee9c720102160100030400020134020100510000082f29a9a31738dd3a33f904d35e2f4f6f9af2d2f9c563c05faa6bb0b12648d5632083ea3f89400114ff00f4a413f4bcf2c80b03020120090404f8f28308d71820d31fd31fd31f02f823bbf264ed44d0d31fd31fd3fff404d15143baf2a15151baf2a205f901541064f910f2a3f80024a4c8cb1f5240cb1f5230cbff5210f400c9ed54f80f01d30721c0009f6c519320d74a96d307d402fb00e830e021c001e30021c002e30001c0039130e30d03a4c8cb1f12cb1fcbff08070605000af400c9ed54006c810108d718fa00d33f305224810108f459f2a782106473747270748018c8cb05cb025005cf165003fa0213cb6acb1f12cb3fc973fb000070810108d718fa00d33fc8542047810108f451f2a782106e6f746570748018c8cb05cb025006cf165004fa0214cb6a12cb1fcb3fc973fb0002006ed207fa00d4d422f90005c8ca0715cbffc9d077748018c8cb05cb0222cf165005fa0214cb6b12ccccc973fb00c84014810108f451f2a702020148130a0201200c0b0059bd242b6f6a2684080a06b90fa0218470d4080847a4937d29910ce6903e9ff9837812801b7810148987159f31840201200e0d0011b8c97ed44d0d70b1f8020158120f02012011100019af1df6a26840106b90eb858fc00019adce76a26840206b90eb85ffc0003db29dfb513420405035c87d010c00b23281f2fff274006040423d029be84c6002e6d001d0d3032171b0925f04e022d749c120925f04e002d31f218210706c7567bd22821064737472bdb0925f05e003fa403020fa4401c8ca07cbffc9d0ed44d0810140d721f404305c810108f40a6fa131b3925f07e005d33fc8258210706c7567ba923830e30d03821064737472ba925f06e30d1514008a5004810108f45930ed44d0810140d720c801cf16f400c9ed540172b08e23821064737472831eb17080185005cb055003cf1623fa0213cb6acb1fcb3fc98040fb00925f03e2007801fa00f40430f8276f2230500aa121bef2e0508210706c7567831eb17080185004cb0526cf1658fa0219f400cb6917cb1f5260cb3f20c98040fb0006\";\n    let state_init = StateInit::from_boc_hex(boc_hex).unwrap();\n}\n\n```\n\n---\n\n### [clients](ton_lib/src/clients) module\n- [LiteClient](ton_lib/src/clients/lite):  \n  A \"native\" lite-node client that uses ADNL. More straightforward to use, but less flexible.\n\n- [TLClient](ton_lib/src/clients/tonlib):  \n  A client based on the `tonlibjson` library from the TON monorepo (requires `tonlib-sys`).  \n  A bit tricky to use at times, but offers more features.\\\n  **Does not support `smc` methods - use `MethodEmulator` instead.**\n\n```rust\nasync fn main() -\u003e anyhow::Result\u003c()\u003e {\n    // LiteClient example\n    let config = LiteClientConfig::new(\u0026TON_NET_CONF_MAINNET)?;\n    let lite_client = LiteClient::new(config)?;\n    let mc_info = lite_client.get_mc_info().await?;\n    let block_id = lite_client.lookup_mc_block(mc_info.last.seqno).await?;\n    \n    // TLClient example\n    let config = TLClientConfig::new(TON_NET_CONF_MAINNET, archive_only);\n    let tl_client = TLClientDefault::new(config).await?;\n    let mc_info = tl_client.get_mc_info().await?;\n    let block = tl_client.lookup_mc_block(mc_info.last.seqno - 100).await?;\n}\n```\n\n---\n\n### [emulators](ton_lib/src/emulators) module\n- [TVMEmulator](ton_lib/src/emulators/tvm/tvm_emulator.rs): `run_method`, `send_int_msg`, `send_ext_msg`\\\nCheck [tvm_emulator_tests](ton_lib/src/emulators/tvm/test_tvm_emulator.rs) for usage examples\n- [TXEmulator](ton_lib/src/emulators/tx/tx_emulator.rs): WIP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsild%2Fton_lib_rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsild%2Fton_lib_rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsild%2Fton_lib_rs/lists"}