ch1seL.TonNet.Client 1.26.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ch1seL.TonNet.Client --version 1.26.0
NuGet\Install-Package ch1seL.TonNet.Client -Version 1.26.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ch1seL.TonNet.Client" Version="1.26.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ch1seL.TonNet.Client --version 1.26.0
#r "nuget: ch1seL.TonNet.Client, 1.26.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ch1seL.TonNet.Client as a Cake Addin
#addin nuget:?package=ch1seL.TonNet.Client&version=1.26.0

// Install ch1seL.TonNet.Client as a Cake Tool
#tool nuget:?package=ch1seL.TonNet.Client&version=1.26.0

Main workflow Chat on Telegram <img src="https://avatars3.githubusercontent.com/u/67861283?s=150&u=4536b61595a1b422604fab8a7012092d891278f6&v=4" align="right" width="150">

Free TON .NET Client

Free TON is modern and fast crypto network. Lets do this network convenient both for users and developers!

  • This client was automatically generated from api.json (see ClientGenerator)
  • Fully supported methods provided in SDK documentation https://github.com/tonlabs/TON-SDK/tree/master/docs
  • No Newtonsoft.Json required, it is kinda legacy now, last release was over a year ago. New System.Text.Json is ten times faster
  • The most complete support of CancellationToken
  • Net Standard 2.1 compatible

Quick start

Add Nuget Package to your project

dotnet add package ch1seL.TonNet.Client

Register in DI

Be careful! no network endpoints provided as default

public void ConfigureServices(IServiceCollection services)
{
    services.AddTonClient();
}

Ready to use everywhere

public class YourTonService {
    private readonly ITonClient _tonClient;

    public YourTonService(ITonClient tonClient) {
        _tonClient = tonClient;
    }
    
    public string GetTonSecretPhase() {
        var mnemonic = await _tonClient.Crypto.MnemonicFromRandom(new ParamsOfMnemonicFromRandom());
        return mnemonic.Phrase;
    }
}

IPackageManager interface

There is easy option to load contracts abi and tvm info from files in this client.

Now available following async methods:

Task<Package> LoadPackage(string name); // Package entity just contains Abi and Tvc
Task<Abi> LoadAbi(string name);
Task<string> LoadTvc(string name);

Default contracts path is _contracts

IDebotBrowser interface

Attention! DeBot module is UNSTABLE yet, see TON SDK description

More information:

As default IDebotBrowser will resolve instance of DefaultDebotBrowser.

Can be inherited or implemented self-owned: services.AddTransient<IDebotBrowser, MyDebotBrowser>()

Advanced client configuration

See configuration parameters:

public void ConfigureServices(IServiceCollection services)
{
    services.AddTonClient(config =>
    {
        config.Network.Endpoints = new[] { "net5.ton.dev" };
        config.Network.NetworkRetriesCount = 5;
    }, packageManagerConfig =>
    {
        packageManagerConfig.PackagesPath = "packages"; // path to abi.json and tvc files, _contracts is default
    });  
}

or configure options by appsettings.json or another configuration provider

https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration-providers

Example for appsettings.json
{
  "TonClient": {
    "Network": {
      "Endpoints": [ "net.ton.dev" ],
      "WaitForTimeout": 5000
    }
  },
  "PackageManager": {
    "PackagesPath": "my_app_contracts"
  }
}
public void ConfigureServices(IServiceCollection services)
{
    services.AddTonClient()        
        .Configure<TonClientOptions>(Configuration.GetSection("TonClient"))
        .Configure<PackageManagerOptions>(Configuration.GetSection("PackageManager"));
}

Logging

Fully compatible with https://docs.microsoft.com/en-us/dotnet/core/extensions/logging

Anonymous type extensions

There are a few properties with type JsonElement in data models. And this client provide methods to easy convert this properties to/from Anonymous prototype.

Convert to anonymous type example:

ResultOfParse parseResult = await tonClient.Boc.ParseMessage(new ParamsOfParse
{
    Boc = "te6ccgEBAQEAWAAAq2n+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE/zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzSsG8DgAAAAAjuOu9NAL7BxYpA"
});
var parsedPrototype = new {type = default(int), id = default(string)};
var parsedMessage = parseResult.Parsed!.Value.ToAnonymous(parsedPrototype);

_logger.LogInformation("Parsed message id: {id} type: {type}", parsedMessage.id, parsedMessage.type);

Convert from anonymous type example:

await tonClient.Net.WaitForCollection(new ParamsOfWaitForCollection
{
    Collection = "transactions",
    Filter = new {in_msg = new {eq = parsedMessage.id}}.ToJsonElement(),
    Result = "id"
});

Samples

https://github.com/ton-actions/ton-client-dotnet/tree/master/samples/

Enjoy!


My Coffee Surf address:

ton://surf/0:9b487d68e4f029ab6d92640892d99d1c549ae69b198df414e905350559a165bf

https://ton.surf

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ch1seL.TonNet.Client:

Package Downloads
ch1seL.TonNet.TestsShared

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.28.0.1 560 1/8/2022
1.28.0 275 12/28/2021
1.27.1 956 12/10/2021
1.27.0 1,000 12/6/2021
1.26.1 487 12/4/2021
1.26.0 2,314 11/26/2021
1.25.0 712 11/10/2021
1.24.0.1 645 11/10/2021
1.24.0 347 10/26/2021
1.23.0 396 10/6/2021
1.22.0.3 302 9/27/2021
1.22.0.2 380 9/24/2021
1.22.0.1 353 9/24/2021
1.22.0 300 9/24/2021
1.21.5.1 313 9/18/2021
1.21.5 339 9/15/2021
1.21.4 347 9/10/2021
1.21.3 305 9/6/2021
1.21.2 312 8/26/2021
1.21.0 332 8/24/2021
1.20.1 333 8/5/2021
1.20.0 345 7/20/2021
1.19.0 362 7/9/2021
1.18.0 388 6/30/2021
1.17.0 365 6/23/2021
1.16.1 366 6/18/2021
1.16.0 353 5/26/2021
1.15.0 353 5/19/2021
1.14.1 345 4/30/2021
1.14.0 335 4/28/2021
1.13.0 342 4/23/2021
1.12.0 332 4/6/2021
1.11.1 340 3/22/2021
1.10.0 375 3/10/2021
1.9.0 339 3/1/2021
1.8.0 325 2/12/2021
1.7.0 322 2/12/2021
1.6.3 343 2/5/2021
1.6.0 342 2/5/2021
1.5.2 386 12/30/2020
1.5.0.1 572 12/26/2020
1.5.0 384 12/26/2020
1.4.0 495 12/26/2020
1.4.0-beta1 389 12/25/2020
1.3.0.2 429 12/18/2020
1.3.0.1 573 12/10/2020
1.3.0 555 12/10/2020
1.2.0.1 598 12/9/2020
1.2.0 522 12/8/2020
1.2.0-beta.3 169 12/8/2020
1.2.0-beta.2 194 12/3/2020
1.2.0-beta.1 184 12/2/2020
1.2.0-alfa.1 206 11/29/2020
1.1.2 510 11/29/2020
1.1.2-alpha.1 227 11/29/2020
0.3.1 490 11/22/2020
0.3.0 493 11/21/2020
0.2.4 401 11/20/2020
0.2.3 402 11/20/2020
0.2.2 415 11/19/2020
0.2.1 437 11/19/2020
0.2.0 421 11/18/2020
0.1.0 436 11/17/2020
0.0.5 407 11/17/2020
0.0.4 422 11/17/2020
0.0.3 399 11/17/2020
0.0.2 408 11/17/2020
0.0.1 398 11/17/2020