Dzeta.TonSdk.Core
0.5.0
Prefix Reserved
dotnet add package Dzeta.TonSdk.Core --version 0.5.0
NuGet\Install-Package Dzeta.TonSdk.Core -Version 0.5.0
<PackageReference Include="Dzeta.TonSdk.Core" Version="0.5.0" />
<PackageVersion Include="Dzeta.TonSdk.Core" Version="0.5.0" />
<PackageReference Include="Dzeta.TonSdk.Core" />
paket add Dzeta.TonSdk.Core --version 0.5.0
#r "nuget: Dzeta.TonSdk.Core, 0.5.0"
#:package Dzeta.TonSdk.Core@0.5.0
#addin nuget:?package=Dzeta.TonSdk.Core&version=0.5.0
#tool nuget:?package=Dzeta.TonSdk.Core&version=0.5.0
Dzeta.TonSdk.NET
Note: This is a fork of TonSdk.NET with critical bug fixes and improvements.
Key changes:
- Thread-safety fixes: Replaced
DictionarywithConcurrentDictionaryin LiteClient for concurrent request handling- Bounds checking: Added BOC deserialization safety checks to prevent "Index out of range" errors
- Address struct: Rewritten
Addressas a high-performancestructusingfixed byteandReadOnlySpan<byte>- EF Core integration: New extension package for Entity Framework Core value converters
- Atomic operations: Proper use of
TryAdd/TryRemovefor thread-safe request managementStatus: Currently only Core, Adnl, and EntityFrameworkCore packages are published. Other packages (Client, Contracts, Connect, DeFi) will be added incrementally with improvements.
Packages
Dzeta.TonSdk.Core
Core library with types and structures for TON Blockchain. Includes:
Addressas high-performancestructwithfixed bytehash storageCoinsfor TON, Jetton amounts- BOC serialization/deserialization with bounds checking
- Cell, Builder, Slice
- Mnemonic (BIP39 and TON standards)
- Ed25519 signing
dotnet add package Dzeta.TonSdk.Core
Dzeta.TonSdk.Adnl
Thread-safe ADNL client and LiteClient for interacting with TON blockchain nodes. Includes:
- ADNL protocol implementation
- LiteClient with concurrent request handling (
ConcurrentDictionary) - Atomic operations for safe multi-threaded access
- Block and account state queries
dotnet add package Dzeta.TonSdk.Adnl
Dzeta.TonSdk.Core.EntityFrameworkCore
Entity Framework Core integration for TonSdk.Core types. Includes:
AddressValueConverter- stores Address as 36 bytes (4 bytes workchain + 32 bytes hash)AddressStringValueConverter- stores Address as human-readable string (~80 bytes)- Extension methods for easy configuration
dotnet add package Dzeta.TonSdk.Core.EntityFrameworkCore
Usage example:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Wallet>()
.Property(e => e.Address)
.HasAddressConversion<Wallet>(); // Binary storage (36 bytes)
}
Features and Status
- Builder, Cell, Slice
- BOC (de)serialization with bounds checking
- Hashmap(E) (dictionary) (de)serialization
- Mnemonic BIP39 standard
- Mnemonic TON standard
- Coins (class for TON, JETTON, etc.)
- Address (struct with
fixed bytefor high performance) - Message layouts (MessageX, etc.)
- Popular structures from block.tlb
- Ed25519 signing of transactions
- ADNL client (thread-safe)
- Lite client over ADNL client (thread-safe)
- EF Core value converters for TON types
- Client with HTTP API (coming soon)
- Contracts abstraction (coming soon)
- TON Connect 2.0 (coming soon)
- DeFi integrations (coming soon)
Installation
Install via NuGet Package Manager or .NET CLI:
dotnet add package Dzeta.TonSdk.Core
dotnet add package Dzeta.TonSdk.Adnl
dotnet add package Dzeta.TonSdk.Core.EntityFrameworkCore # Optional, for EF Core users
Quick Start
Using Address
using TonSdk.Core;
// Parse address
var address = new Address("EQDk2VTvn04SUKJrW7rXahzdF8_Qi6utb0wj43InCu9vdjrR");
// Get raw format
string raw = address.ToRaw(); // "0:e4d954ef9f4e1250a26b5bbad76a1cdd17cfc08babaddf4c23e37227..."
// Get workchain and hash
int workchain = address.Workchain; // 0
ReadOnlySpan<byte> hash = address.Hash; // 32 bytes
Using LiteClient
using TonSdk.Adnl;
using TonSdk.Adnl.LiteClient;
var client = new LiteClient(LiteClientOptions.GetFromUrl("https://ton-blockchain.github.io/global.config.json"));
await client.Connect();
var masterchain = await client.GetMasterchainInfo();
Console.WriteLine($"Last block: {masterchain.Last.Seqno}");
Using with Entity Framework Core
using TonSdk.Core;
using TonSdk.Core.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
public class Wallet
{
public int Id { get; set; }
public Address Address { get; set; } // TON address stored efficiently
public decimal Balance { get; set; }
}
public class MyDbContext : DbContext
{
public DbSet<Wallet> Wallets { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Binary storage (36 bytes) - recommended
modelBuilder.Entity<Wallet>()
.Property(e => e.Address)
.HasAddressConversion<Wallet>();
}
}
License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- JustCRC32C (>= 1.1.0)
- Portable.BouncyCastle (>= 1.9.0)
-
net8.0
- JustCRC32C (>= 1.1.0)
- Portable.BouncyCastle (>= 1.9.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Dzeta.TonSdk.Core:
| Package | Downloads |
|---|---|
|
Dzeta.TonSdk.Adnl
Library that allows to interact with Ton ADNL (Thread-safe fork with event-driven LiteClient architecture) |
|
|
Dzeta.TonSdk.Core.EntityFrameworkCore
Entity Framework Core integration for TonSdk.Core, providing value converters for Address and other TON types |
GitHub repositories
This package is not used by any popular GitHub repositories.