Skip to content

Dzeta-tech/Ton.Net

Repository files navigation

Ton.NET

Banner

A modern, comprehensive .NET SDK for the TON (The Open Network) blockchain. Built from scratch with clean architecture, targeting compatibility with the official TON JavaScript SDK.

Documentation License: MIT

✨ Features

  • 🎯 API compatibility with TON JavaScript SDK
  • 🔒 Type-safe primitives and TL-B structures
  • 🧪 553+ tests with comprehensive coverage
  • 📦 Modular architecture - use only what you need
  • 🚀 Production-ready with .NET 8 & 9 support
  • 📚 Complete documentation with examples

📦 Packages

Package Version Description
Ton.Core NuGet Core primitives: Cells, BOC, Addresses, Types
Ton.Crypto NuGet Ed25519, Mnemonics (BIP39), SHA, HMAC
Ton.Contracts NuGet Smart contracts: Wallets V5R1
Ton.LiteClient NuGet ADNL protocol for direct node communication
Ton.HttpClient NuGet HTTP API clients (Toncenter v2/v4)

🚀 Quick Start

Install packages:

dotnet add package Ton.LiteClient

Create a wallet and check balance:

using Ton.Crypto.Mnemonic;
using Ton.Contracts.Wallets.V5;
using Ton.LiteClient;

// Generate mnemonic
var mnemonic = Mnemonic.New(24);
var keys = Mnemonic.ToWalletKey(mnemonic);

// Create wallet
var wallet = new WalletV5R1(keys.PublicKey);
Console.WriteLine($"Address: {wallet.Address}");

// Connect to blockchain
var client = await LiteClientFactory.CreateFromUrlAsync(
    "https://ton.org/global-config.json"
);

// Get balance
var info = await client.GetMasterchainInfoAsync();
var state = await client.GetAccountStateAsync(wallet.Address, info.Last);
Console.WriteLine($"Balance: {state.BalanceInTon} TON");

📚 Documentation

View Full Documentation →

Getting Started

Modules

Guides

API Reference

🧪 Testing

dotnet test

Test Coverage:

  • 298 Core tests (BOC, TL-B, Dictionaries, Addresses)
  • 47 Crypto tests (Mnemonics, Ed25519, Hashing)
  • 41 Contracts tests (Wallets)
  • 156 ADNL tests (Protocol, Serialization, Crypto)
  • 11 LiteClient tests (Integration)

Total: 553 passing tests

All tests validate compatibility with TON JavaScript SDK behavior.

🏗️ Architecture

Ton.LiteClient  → High-level blockchain queries (ADNL protocol)
    ├── Ton.Adnl      → Low-level ADNL protocol
    ├── Ton.Core      → Core primitives (Cell, Address, BOC)
    └── Ton.Crypto    → Cryptographic operations

Ton.HttpClient  → HTTP API client (Toncenter v2/v4)
    ├── Ton.Core
    └── Ton.Crypto

Ton.Contracts   → Smart contract implementations
    ├── Ton.Core
    └── Ton.Crypto

Key Design Principles

  • Type Safety - Nullable reference types, records, pattern matching
  • Zero External Dependencies - Only System.Text.Json for HTTP clients
  • Performance - Efficient cell serialization and hashing
  • Compatibility - 1:1 API compatibility with TON JS SDK
  • Testability - Comprehensive test coverage

🛠️ Development

Requirements

  • .NET 8.0 or .NET 9.0
  • C# 12 language features

Samples

Check out the /samples directory:

  • LiteClientPlayground - LiteClient usage examples
  • AdnlSample - Low-level ADNL protocol examples

🤝 Contributing

Contributions are welcome! This project aims for API compatibility with the TON JavaScript SDK.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🔗 Resources

Official TON

Community

Ton.NET


Made with ❤️ for the TON community

About

Modern .NET SDK for TON blockchain targeting API compatibility with official JavaScript SDKs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors