TronDotNet 2.3.0

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

// Install TronDotNet as a Cake Tool
#tool nuget:?package=TronDotNet&version=2.3.0                

TronDotNet


Features

  • TronDotNet is a simple library to generate HD wallet offline and make transactions (TRC20 and TRX) via Tron blockchain like (USDT, USDC,...) and other services
  • it is offline wallet and sign transactions offline
  • it is so easy to use it, first things sign up to the Tron Grid https://www.trongrid.io/ for free and get api key
  • by using TronDotNet library you can build your application and make transactions via Tron blockchain locally without any web services or api
  • it is important to know that using TronDotNet library let you generate wallets and keep your private key secure with you only without shared it with another applications or web services
  • it is so easy to use it using C#

HD Wallet

  • TronDotNet can generate wallet support BIP-32 and BIP-44 proposals, and generate the corresponding TRON addresses based on the BIP-44 hierarchical sub-path
  • Suport BIP-39 English words list

Transaction Type

1- TRX : Official Token of TRON Protocol

2- USDT : Official stablecoin issued by Tether on the TRON network (TRC20)

3- USDC : is a fully collateralized US Dollar stablecoin developed by CENTRE (TRC20)

TronDotNet Service Fees

  • For transaction type TRX the fee is free
  • For all transactions type (TRC20) the fee will be as every 10,000 coin of (TRC20) the fee will be 5 TRX

Development

first things signup to the Tron Grid https://www.trongrid.io/ for free and get api key to connect to the tron blockchain

  • Note: most functions are return object of type 'TResultObject' that containe bool 'Sucsses', you must check the value of result.Sucsses if true then get the function result from object 'result.Data', else if 'Sucsses' value is false you can get information about Error at object result.ErrorData.ErrorMsg
  • add TronDotNet package to your application and using this namespaces:
using TronDotNet;
using TronDotNet.Node;
  • Generate HD Tron Wallet Offline: Generate your tron HD Wallet Offline using Bip39, Bip44 by random 16 bytes and get wallet keys and tron address and 12 secret words at the result
public async void Func_GenerateWalletOffline()
{
    var ser = new TronWallet();
    var data = new byte[]{16}; // any random 16 bytes
    var result = await ser.GenerateWalletOffline(data);
}
  • Backup HD Tron Wallet: if you have a wallet and you want to get wallet keys and tron address to use it, you can Backup it using 12 secret words
public async void Func_BackupWallet()
{
    var ser = new TronWallet();
    var data = "word1 word2 word3 word4 ...... word12"; // your 12 secret words
    var result = await ser.BackupWallet(data);
}
  • Get Wallet Balance: you can get all coins Balances for any wallet by address
public async void Func_GetBalance()
{
    ApiConnection.ApiKey = "------------your api key her-------------";
    var ser = new TronWallet();
    var data = "wallet address ...";
    var result = await ser.GetBalance(data);
}
  • Create Account on Tron blockchain: you can create the account by this way or you can send any amount of TRX to the new wallet and it will created on tron blockchain automatically (the cost of create account on tron blockchain is 1.1 TRX)
public async void Func_CreateAccount()
{
    ApiConnection.ApiKey = "------------your api key her-------------";
    var ser = new TronWallet();
    string OwnerPrivateKey = "Owner Private Key";//for pay 1.1 TRX cost of created
    string NewAddress = "new wallet address ...";//new wallet that generated from GenerateWalletOffline function
    var result = await ser.CreateAccount(OwnerPrivateKey, NewAddress);
}
  • Get Wallet address by Private Key:
public async void Func_GetTronAddressByPrivateKey()
{
    var ser = new TronWallet();
    var data = "wallet private key";
    var result = await ser.GetTronAddressByPrivateKey(data);
}
  • Get Wallet address by Public Key:
public async void Func_GetTronAddressByPublicKey()
{
    var ser = new TronWallet();
    var data = "wallet Public key";
    var result = await ser.GetTronAddressByPublicKey(data);
}
  • Validate values: you can check for wallet Keys and address
public void Func_Validate()
{
    var result1 = TronWallet.PrivateKeyValidate("Private Key");
    var result2 = TronWallet.PublicKeyValidate("Public Key");
    var result3 = TronWallet.Base58FormatValidate("Tron address");
}
  • Create Transaction (TRX or USDT): by this function you can create transaction and send coins to another wallet on tron network
public async void Func_CreateAndBroadcast()
{
    ApiConnection.ApiKey = "------------your api key her-------------";
    var ser = new Transactions();
    var data = new Transaction(TransactionType.USDT, "To Address", 200, "Private key hex format");
    var result = await ser.CreateAndBroadcast(data);
    //at the result you will get txID for see the transaction at https://tronscan.org/#/
}
  • Calculate TronDotNet Service Fees: Calculate fee by transaction type and coin amount, the fee coin will be always is TRX
public void Func_GetServiceFee()
{
    var ser = new Transactions();
    var result1 = ser.GetServiceFee(TransactionType.TRX, 800);    // 0 TRX (free)
    var result2 = ser.GetServiceFee(TransactionType.TRX, 5000);   // 0 TRX (free)
    
    var result3 = ser.GetServiceFee(TransactionType.USDT, 200);   // 5 TRX
    var result4 = ser.GetServiceFee(TransactionType.USDT, 9000);  // 5 TRX
    var result5 = ser.GetServiceFee(TransactionType.USDT, 11000); // 10 TRX
    var result6 = ser.GetServiceFee(TransactionType.USDT, 24000); // 15 TRX
    
    var result7 = ser.GetServiceFee(TransactionType.USDC, 800);   // 5 TRX
    var result8 = ser.GetServiceFee(TransactionType.USDC, 12000); // 10 TRX
}
  • Calculate Tron network Fee for TRC20 (USDT,USDC): you can Calculate network fee for energy required to create transaction, the fee coin will be always is TRX
public async void Func_GetNetworkFee()
{
    ApiConnection.ApiKey = "------------your api key her-------------";
    var ser = new Transactions();
    var result = await ser.GetNetworkFee(TransactionType.USDT, 600, "FromAddress", "ToAddress");
}
  • Read Last Transaction (TRX or USDT): by this function you can get list of transaction by wallet address
public async void Func_GetLastTransactions()
{
    ApiConnection.ApiKey = "------------your api key her-------------";
    var ser = new Transactions();
    var data = "wallet address";
    
    var result1 = await ser.GetLastTRXTransactions(data);// for get TRX Transactions
    
    var result2 = await ser.GetLastTRC20Transactions(data);//for get USDT,USDC Transactions
}

License

MIT

Contact

For more information, suggestions and questions please contact TronDotNet Team by email: trondotnet@hotmail.com

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 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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
2.5.0 171 10/9/2024
2.4.0 770 5/26/2024
2.3.0 103 5/16/2024
2.2.0 134 4/25/2024
2.1.0 329 10/19/2023
2.0.0 188 10/9/2023
1.0.0 241 7/31/2023