Utilities.Tron.AddressConverter
8.0.1024
dotnet add package Utilities.Tron.AddressConverter --version 8.0.1024
NuGet\Install-Package Utilities.Tron.AddressConverter -Version 8.0.1024
<PackageReference Include="Utilities.Tron.AddressConverter" Version="8.0.1024" />
<PackageVersion Include="Utilities.Tron.AddressConverter" Version="8.0.1024" />
<PackageReference Include="Utilities.Tron.AddressConverter" />
paket add Utilities.Tron.AddressConverter --version 8.0.1024
#r "nuget: Utilities.Tron.AddressConverter, 8.0.1024"
#:package Utilities.Tron.AddressConverter@8.0.1024
#addin nuget:?package=Utilities.Tron.AddressConverter&version=8.0.1024
#tool nuget:?package=Utilities.Tron.AddressConverter&version=8.0.1024
Utilities.Tron.AddressConverter
A simple .NET library for conversion between HEX format addresses and TRON blockchain addresses, targeting .NET 8.
Description
This library provides utility extension methods to convert hexadecimal string representations of addresses to the Base58Check encoded TRON address format. It also includes an object pool for SHA256
instances to optimize performance and reduce memory allocations during repeated hashing operations required for address checksum calculations.
Features
- Convert hexadecimal addresses to TRON addresses.
- Handles optional "0x" prefix in hex addresses.
- Efficiently computes checksums using a pooled
SHA256
implementation.
Installation
You can install the package via NuGet Package Manager:
Install-Package Utilities.Tron.AddressConverter
Or via the .NET CLI:
dotnet add package Utilities.Tron.AddressConverter
Usage
Here's a basic example of how to convert a hexadecimal address to a TRON address:
using Utilities.Tron.AddressConverter.Extensions;
public class Example
{
public static void Main(string[] args)
{
string? hexAddress = "0xa614f803b6fd780986a42c78ec9c7f77e6ded13c"; // Example hex address (with or without "0x" prefix)
string? tronAddress = hexAddress.ToTronAddress();
if (tronAddress != null)
{
Console.WriteLine($"Hex Address: {hexAddress}");
Console.WriteLine($"Tron Address: {tronAddress}");
// Expected Tron Address: TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t (for the example hex above without the 0x41 prefix)
// If the hexAddress already includes the 0x41 prefix, the output will be the same.
}
else
{
Console.WriteLine("Invalid hex address provided.");
}
}
}
Sha256Pool
For applications performing many address conversions, the Sha256Pool
class is used internally by ToTronAddress
to manage SHA256
crypto provider instances. This helps in reducing GC pressure by reusing SHA256
objects. If you have other parts of your application that require SHA256
hashing, you can also leverage this pool:
using System.Security.Cryptography;
using Utilities.Tron.AddressConverter; // Namespace for Sha256Pool
// ...
SHA256 sha256Instance = Sha256Pool.Rent();
try
{
// Use sha256Instance for hashing operations
// byte[] dataToHash = ...;
// byte[] hash = sha256Instance.ComputeHash(dataToHash);
}
finally
{
Sha256Pool.Return(sha256Instance);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.ObjectPool (>= 8.0.16)
- SimpleBase (>= 5.4.1)
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 |
---|---|---|
8.0.1024 | 288 | 6/10/2025 |