TonSdk.Connect 0.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TonSdk.Connect --version 0.2.1                
NuGet\Install-Package TonSdk.Connect -Version 0.2.1                
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="TonSdk.Connect" Version="0.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TonSdk.Connect --version 0.2.1                
#r "nuget: TonSdk.Connect, 0.2.1"                
#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 TonSdk.Connect as a Cake Addin
#addin nuget:?package=TonSdk.Connect&version=0.2.1

// Install TonSdk.Connect as a Cake Tool
#tool nuget:?package=TonSdk.Connect&version=0.2.1                

TonSdk.Connect

Overview example

// Create a TonConnectOptions object with the manifest URL
TonConnectOptions options = new TonConnectOptions()
{
    ManifestUrl = "https://dedust.io/tonconnect-manifest.json"
};

// Initialize TonConnect with the specified options
TonConnect tonConnect = new(options);

// Get wallet configurations
WalletConfig[] walletsConfig = tonConnect.GetWallets();

// Set event handlers for status changes and errors
tonConnect.OnStatusChange(OnStatusChange, OnErrorChange);

// Method called when the wallet status changes
void OnStatusChange(Wallet wallet)
{
    Console.WriteLine("Wallet connected. Address: " + wallet.Account.Address + ". Platform: " + wallet.Device.Platform + "," + wallet.Device.AppName + "," + wallet.Device.AppVersion);
}

// Method called when errors occur
void OnErrorChange(string wallet)
{
    Console.WriteLine(wallet);
}

// Connect to a wallet and await the result
string result = await tonConnect.Connect(walletsConfig[1]);

// Print the connection result
Console.WriteLine("Connect link: " + result);

Disconnect wallet method
// Call this method to disconnect from the current wallet
await tonConnect.Disconnect();
Use custom remote storage
// Create a `RemoteStorage` object with custom storage methods provided by the user (for example Player Prefs in Unity)
RemoteStorage remoteStorage = new(new(PlayerPrefs.GetString), new(PlayerPrefs.SetString), new(PlayerPrefs.DeleteKey), new(PlayerPrefs.HasKey));

// Initialize TonConnect with the specified options and the custom storage methods
TonConnect tonConnect = new(options, remoteStorage);
Use additional connect options
// This delegates uses, if platform as the Unity, needs reimplementation of httpClient logic, with using Coroutines.
// Dont use in usual C# projects.

// Create a custom SSE listen method with implementation of event stream subsctiptions.
// Example, https://github.com/continuation-team/unity-ton-connect/blob/main/Assets/TonConnect/Scripts/TonConnect/TonConnectHandler.cs#L147C5-L192C6
private void YourListenEventsMethod() {}

// Create a custom send post message method
// Example, https://github.com/continuation-team/unity-ton-connect/blob/main/Assets/TonConnect/Scripts/TonConnect/TonConnectHandler.cs#L119C5-L145C6
private void YourSendPostMethod() {}

// Create a `AdditionalConnectOptions` object with custom methods provided by the user (only in Unity)
AdditionalConnectOptions additionalOptions = new AdditionalConnectOptions()
{
    listenEventsFunction = new ListenEventsFunction(YourListenEventsMethod),
    sendGatewayMessage = new SendGatewayMessage(YourSendPostMethod)
}
Send transaction example
// Create a receiver address and the amount to send
Address receiver = new("receiver address");
Coins amount = new("send amount");

// Create an array of messages to send
Message[] sendTons = 
{
    new Message(receiver, amount),
    // Additional messages if needed
};

// Set the valid until timestamp for the transaction (expiration time in seconds from the current moment)
long validUntil = DateTimeOffset.Now.ToUnixTimeSeconds() + 600;

// Create a SendTransactionRequest object
SendTransactionRequest transactionRequest = new SendTransactionRequest(sendTons, validUntil);

// Print the result of sending the transaction
Console.WriteLine(await tonConnect.SendTransaction(transactionRequest));

Donation

continuation.ton

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 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 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 was computed. 
.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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.4 5,666 5/7/2024
0.2.3 441 4/28/2024
0.2.2 188 4/20/2024
0.2.1 157 4/15/2024
0.1.2 1,604 10/28/2023
0.1.0 190 9/6/2023