UsdtDotNet is a simple library to generate wallet offline and make USDT transactions (TRC20, ERC20) via TRON & Ethereum blockchain and other services. it is offline wallet and sign transactions offline
$ dotnet add package UsdtDotNetFeaturesTron and Ethereum networks and create USDT and main transactions on blockchain.offline.C# or vb.net.HD WalletTRON and Ethereum addressesunlimited HD WalletsAvailable coins for transactions| Coin | Chain | Contract | Description |
|---|---|---|---|
| TRX | Tron | Official Token of Tron | |
| USDT_TRC20 | Tron | TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t | USDT Tether |
| ETH | Ethereum | Official Token of Ethereum | |
| USDT_ERC20 | Ethereum | 0xdAC17F958D2ee523a2206206994597C13D831ec7 | USDT Tether |
UsdtDotNet Service FeesProduction and test networksYou can choose the network for test your project from available networks (default network is Mainnet)
ApiConnection.Network = Networks.Mainnet; //default network
| Chain | Production network | Test network |
|---|---|---|
| Tron | Tron Mainnet | Nile Testnet (for test only) |
| Ethereum | Ethereum Mainnet | Sepolia Testnet (for test only) |
DevelopmentFirst step to start
Signup to the Tron Grid https://www.trongrid.io/ for free and get api key to connect to the Tron blockchainSignup to the infura https://www.infura.io/ for free and get api key to connect to the Ethereum blockchainTResultObject 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.ErrorMsgusing HdWalletDotNet.Objects;
using HdWalletDotNet.Services;
1: Generate HD Wallet OfflineGenerate your tron HD Wallet Offline by random bytes and get wallet keys and address and secret words at the result
public async void Func_GenerateWalletOffline()
{
byte[] RandomBytes = new byte[] { 167, 47, 16, 99, 72, 108, 30, 240, 7, 89, 48, 173, 64, 51, 86, 203 };
ushort Index = 0; //default value is 0
var service = new HdWallet();
var result = await service.GenerateWalletOffline(RandomBytes, Index);
}
| Object name | Object value | Description |
|---|---|---|
| result.Data.Mnemonic | poet joy boat move sea job buddy champion pull account stick nuclear | the secret words for generated wallet |
| result.Data.TronKey.PrivateKey | bfc0760d387d25c77e357d61b0d4caaf124b126e95209c7b1090c2c41646fdba | private Key for tron network |
| result.Data.TronKey.Address | TC2XaRjm1wHQA4duyHR6pwqpKZYX6RN6gZ | wallet address for tron network |
| result.Data.EthereumKey.PrivateKey | 20e26d730b99ee6a1001519866bb7ce71ad971643d9910e67820a3e2b7471b1a | private Key for Ethereum network |
| result.Data.EthereumKey.Address | 0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf | wallet address for Ethereum network |
| Random bytes length | Secret words count |
|---|---|
| 16 bytes | 12 words |
| 20 bytes | 15 words |
| 24 bytes | 18 words |
| 28 bytes | 21 words |
| 32 bytes | 24 words |
Index for generate multiple wallets with same secret wordsresult.Data.TronKey when you call any functions via Tron blockchain and result.Data.EthereumKey for Ethereum blockchainWarning: Always keep private keys secure. UsdtDotNet does not store or transmit your keys.2: Backup HD Walletif you have a wallet and you want to get wallet keys and addresses to use it, you can Backup it using secret words
for secret words count must be as last table
public async void Func_BackupWallet()
{
string data = "poet joy boat move sea job buddy champion pull account stick nuclear"; // secret words
var service = new HdWallet();
var result = await service.BackupWallet(data);
}
3: Create Transactionby this function you can create transaction and send coins to another wallet
100 USDT_TRC20 via Tron network, from the wallet that we generated above (we need just private key), to the address TEwSJVoqQ7omHzx7x2UPkKwGo4ubdARuvE// Example 1
public async void Func_CreateAndBroadcast()
{
ApiConnection.Network = Networks.Mainnet; //default network
ApiConnection.TronApiKey = "------------your Tron api key her-------------";
var data = new Transaction()
{
Coin = Coins.USDT_TRC20,
ToAddress = "TEwSJVoqQ7omHzx7x2UPkKwGo4ubdARuvE",
Amount = 100,
PrivateKey = "bfc0760d387d25c77e357d61b0d4caaf124b126e95209c7b1090c2c41646fdba"
};
var service = new TransactionBroadcast();
var result = await service.CreateAndBroadcast(data);
}
200 USDT_ERC20 via Ethereum network, from the wallet that we generated above (we need just private key), to the address 0x860dbec5965a6c320ccaf46d44671c9a05714f1f// Example 2
public async void Func_CreateAndBroadcast()
{
ApiConnection.Network = Networks.Mainnet; //default network
ApiConnection.InfuraApiKey = "------------your Infura api key her-------------";
var data = new Transaction()
{
Coin = Coins.USDT_ERC20,
ToAddress = "0x860dbec5965a6c320ccaf46d44671c9a05714f1f",
Amount = 200,
PrivateKey = "20e26d730b99ee6a1001519866bb7ce71ad971643d9910e67820a3e2b7471b1a"
};
var service = new TransactionBroadcast();
var result = await service.CreateAndBroadcast(data);
}
both examples at the result if Sucsses is true, you can get txID from the object result.Data.ID,
else if Sucsses is false, you can get information about error from object result.ErrorData.ErrorMsg
4: Get Wallet Balanceyou can get coin Balances for any wallet by his address
public async void Func_GetBalance()
{
ApiConnection.Network = Networks.Mainnet; //default network
ApiConnection.TronApiKey = "------------your Tron api key her-------------";
ApiConnection.InfuraApiKey = "------------your Infura api key her-------------";
var service = new HdWallet();
var result1 = await service.GetBalance(Coins.TRX, "TC2XaRjm1wHQA4duyHR6pwqpKZYX6RN6gZ");
var result2 = await service.GetBalance(Coins.USDT_TRC20, "TC2XaRjm1wHQA4duyHR6pwqpKZYX6RN6gZ");
var result3 = await service.GetBalance(Coins.ETH, "0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf");
var result4 = await service.GetBalance(Coins.USDT_ERC20, "0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf");
}
5: Get Wallet address by Private Keypublic void Func_GetTronAddressByPrivateKey()
{
var service = new HdWallet();
string TronPrivateKey = "bfc0760d387d25c77e357d61b0d4caaf124b126e95209c7b1090c2c41646fdba";
string EthereumPrivateKey = "20e26d730b99ee6a1001519866bb7ce71ad971643d9910e67820a3e2b7471b1a";
var result1 = service.GetAddressByPrivateKey(Coins.TRX, TronPrivateKey);
var result2 = service.GetAddressByPrivateKey(Coins.ETH, EthereumPrivateKey);
//result1 : TC2XaRjm1wHQA4duyHR6pwqpKZYX6RN6gZ
//result2 : 0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf
}
6: Validate valuesyou can check for wallet Keys and address
public void Func_Validate()
{
bool result1 = HdWallet.PrivateKeyValidate("bfc0760d387d25c77e357d61b0d4caaf124b126e95209c7b1090c2c41646fdba"); //true
bool result2 = HdWallet.PrivateKeyValidate("any value 123456"); //false
bool result3 = HdWallet.AddressValidate(Coins.TRX, "TC2XaRjm1wHQA4duyHR6pwqpKZYX6RN6gZ"); //true
bool result4 = HdWallet.AddressValidate(Coins.TRX, "0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf"); //false
bool result5 = HdWallet.AddressValidate(Coins.ETH, "0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf"); //true
bool result6 = HdWallet.AddressValidate(Coins.ETH, "TC2XaRjm1wHQA4duyHR6pwqpKZYX6RN6gZ"); //false
bool result7 = HdWallet.AddressValidate(Coins.ETH, "any valueeeeeeeee"); //false
}
7: Calculate UsdtDotNet Service FeesCalculate fee by transaction type and coin amount, the fee coin will be always is TRX
public void Func_GetServiceFee()
{
var service = new TransactionBroadcast();
var result1 = service.GetServiceFee(Coins.TRX, 850); // 0 TRX (free)
var result2 = service.GetServiceFee(Coins.ETH, 0.21); // 0 ETH (free)
var result3 = service.GetServiceFee(Coins.USDT_TRC20, 2000); // 5 TRX
var result4 = service.GetServiceFee(Coins.USDT_ERC20, 9000); // 0.0004 ETH
var result5 = service.GetServiceFee(Coins.USDT_TRC20, 11500); // 10 TRX
}
8: Calculate network Feeyou can Calculate approximate network fee for energy required to create transaction, the fee coin will be always main coin
public async void Func_GetNetworkFee()
{
ApiConnection.Network = Networks.Mainnet; //default network
ApiConnection.InfuraApiKey = "------------your Infura api key her-------------";
var service = new TransactionBroadcast();
string FromAddress = "0x47d5a094cfbf042ea2981ef0bbb22a4bdb1630bf";
string ToAddress = "0x860dbec5965a6c320ccaf46d44671c9a05714f1f";
var result = await service.GetNetworkFee(Coins.USDT_ERC20, 600, FromAddress, ToAddress);
}
LicenseMIT
ContactFor more information, suggestions and questions please contact TronDotNet Team by email: trondotnet@hotmail.com