TonLib.Net
0.21.2
See the version list below for details.
dotnet add package TonLib.Net --version 0.21.2
NuGet\Install-Package TonLib.Net -Version 0.21.2
<PackageReference Include="TonLib.Net" Version="0.21.2" />
paket add TonLib.Net --version 0.21.2
#r "nuget: TonLib.Net, 0.21.2"
// Install TonLib.Net as a Cake Addin #addin nuget:?package=TonLib.Net&version=0.21.2 // Install TonLib.Net as a Cake Tool #tool nuget:?package=TonLib.Net&version=0.21.2
TonLib.NET
Wrapper around tonlibjson
library for accessing Telegram Open Network lite servers (nodes) directly via ADNL protocol.
Does not require TonAPI, TonCenter API, TonKeeper API or any other HTTP API.
⚠ For net6.0
uses System.Text.Json
package v7.0.0 (from net7.0
) - it makes [de]serialization much simpler (because of Polymorphic serialization). It only updates System.Text.Encodings.Web
(v6.0 → v7.0) as a transitive dependency, which I think is acceptable.
Features
- Read account balance and transaction history (sample);
- Operate with keys and mnemonics (sample);
- Send TON to different account (sample);
- Work with BOCs and Cells (read and parse using Slices, compose using CellBuilder) (sample), including HashmapE (tests);
- Read and parse smartcontract data, call get-methods (sample);
- Resolve domains (sample)
TonRecipes
class (ready-to-use one-liners) to work with:
And more:
- Easy-to-extend:
- Describe and call new TonLib methods without waiting for new version (sample);
- Add your own Recipe methods to existing repice classes without recompiling library;
- Connects to random LiteServer or choosen by you;
- Reconnects to different LiteServer if previous one fails (but you need to handle exceptions and implement retry logic yourself, for example with Polly);
- No 3rd-party packages except native .NET assemblies;
Usage
Register in Startup
(for console projects - create instance manually or see demo project for hosted sample):
services.AddSingleton<ITonClient, TonClient>();
And use:
// Obtain client from DI
var tonClient = app.Services.GetRequiredService<ITonClient>();
// You need to init it before first use.
// During this, TON network config file is loaded from internet.
// Subsequent calls to `InitIfNeeded` will be ignored,
// so no need for you to have additional variable
// to remember that you already called it.
await tonClient.InitIfNeeded();
// Use 'Execute' to send requests.
var lsi = await tonClient.Execute(new LiteServerGetInfo());
logger.LogInformation("Server time: {Now}", lsi.Now);
Run Demo project for more samples.
Installing dependencies and running a demo
This library is a wrapper around tonlibjson
library. You need to obtain complied copy of it (and its dependencies) yourself.
Go to https://github.com/ton-blockchain/ton/releases, open latest release, scroll to "Assets" and download tonlibjson.*
for your OS. Make sure this file will be available for your running program (for example, add it to your project and set "Copy to Output Directory" to "Copy if newer").
The number of additional dependencies you need depends of what you already have on your machine. On my Win machine I also needed libcrypto-1_1-x64.dll
from OpenSSL v1.1. You may use Process Monitor to find what it wants if it fails to run.
3rd-party libraries and dependencies
- Microsoft.Extensions.Logging.Abstractions v6.0.0 / v7.0.0 / v8.0.0
- Microsoft.Extensions.Options v6.0.0 / v7.0.0 / v8.0.0
- System.Text.Json v7.0.0 for
net6.0
andnet7.0
, v8.0.0 fornet8.0
- System.Text.Encodings.Web v7.0.0 for
net6.0
as transitive dependency
- System.Text.Encodings.Web v7.0.0 for
Donate
just_dmitry.ton
Useful links
- TON ADNL API Home: https://ton.org/docs/develop/dapps/apis/adnl
- TonLib TL Schema: https://github.com/ton-blockchain/ton/blob/master/tl/generate/scheme/tonlib_api.tl
- Block.tlb schema: https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb
- TL Language description: https://core.telegram.org/mtproto/TL
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 is compatible. 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. |
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- System.Text.Json (>= 7.0.0)
-
net7.0
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.0)
- System.Text.Json (>= 7.0.0)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TonLib.Net:
Package | Downloads |
---|---|
TonProof
TonProof validates proof requests from TonConnect |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.22.0 | 8,247 | 8/5/2024 |
0.21.3 | 6,407 | 3/30/2024 |
0.21.2 | 163 | 2/25/2024 |
0.21.1 | 3,023 | 2/7/2024 |
0.20.0 | 2,233 | 11/27/2023 |
0.19.0 | 3,639 | 7/8/2023 |
0.18.1 | 991 | 6/6/2023 |
0.17.1 | 228 | 6/5/2023 |
0.17.0 | 273 | 6/1/2023 |
0.16.0 | 506 | 5/18/2023 |
0.15.0 | 536 | 5/3/2023 |
0.14.1 | 314 | 4/27/2023 |
0.14.0 | 351 | 4/21/2023 |
0.13.0 | 312 | 4/16/2023 |
0.12.0 | 219 | 4/7/2023 |
0.11.0 | 250 | 3/26/2023 |
0.10.0 | 259 | 3/15/2023 |
0.9.0 | 239 | 3/9/2023 |
0.8.0 | 224 | 3/7/2023 |
0.7.0 | 261 | 3/5/2023 |
0.6.0 | 306 | 2/21/2023 |
0.5.0 | 276 | 2/21/2023 |
0.4.0 | 271 | 2/13/2023 |
0.3.1 | 293 | 2/6/2023 |
0.3.0 | 286 | 2/6/2023 |
0.2.0 | 316 | 2/1/2023 |
0.1.0 | 325 | 1/31/2023 |
A lot of changes, see GitHub changelog.