![]() |
VOOZH | about |
dotnet add package Tricksfor.BlockChainTools --version 10.1.2
NuGet\Install-Package Tricksfor.BlockChainTools -Version 10.1.2
<PackageReference Include="Tricksfor.BlockChainTools" Version="10.1.2" />
<PackageVersion Include="Tricksfor.BlockChainTools" Version="10.1.2" />Directory.Packages.props
<PackageReference Include="Tricksfor.BlockChainTools" />Project file
paket add Tricksfor.BlockChainTools --version 10.1.2
#r "nuget: Tricksfor.BlockChainTools, 10.1.2"
#:package Tricksfor.BlockChainTools@10.1.2
#addin nuget:?package=Tricksfor.BlockChainTools&version=10.1.2Install as a Cake Addin
#tool nuget:?package=Tricksfor.BlockChainTools&version=10.1.2Install as a Cake Tool
A .NET 9 library built on Nethereum that provides ready-to-use services for common blockchain operations including HD wallet management, balance queries, gas estimation, and token transfers.
dotnet add package Tricksfor.BlockChainTools
using BlockChainTools;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddHttpClient(); // Required for GasService
services.AddBlockChainTools();
var provider = services.BuildServiceProvider();
using BlockChainTools.Interfaces;
var web3Provider = provider.GetRequiredService<IWeb3ProviderService>();
// Read-only Web3
var web3 = web3Provider.CreateWeb3("https://polygon-rpc.com");
// Web3 with account (for transactions)
var web3Tx = web3Provider.CreateWeb3(
privateKey: "0x...",
chain: Nethereum.Signer.Chain.Polygon,
rpcUrl: "https://polygon-rpc.com"
);
var balanceService = provider.GetRequiredService<IBalanceService>();
var gasService = provider.GetRequiredService<IGasService>();
var transferService = provider.GetRequiredService<ITransferService>();
// Get native balance
var balance = await balanceService.GetBalanceOfAsync(web3, "0xAddress...");
// Get ERC20 balance
var usdcBalance = await balanceService.GetErc20BalanceAsync(
web3, "0xUSDCContract...", "0xAddress...");
// Estimate gas
var gasPrice = await gasService.GetGasPriceAsync("https://polygon-rpc.com");
var gasLimit = await gasService.EstimateTransferGasAsync(web3, "0xTo...", 1.5m);
// Transfer native tokens
var txInput = new Nethereum.RPC.Eth.DTOs.TransactionInput
{
From = "0xFrom...",
To = "0xTo...",
Value = new Nethereum.Hex.HexTypes.HexBigInteger(
Nethereum.Web3.Web3.Convert.ToWei(1.5m))
};
var txHash = await transferService.TransferAsync(web3Tx, txInput);
For transaction-enabled Web3 instances, the library integrates with Tricksfor.DistributedNonce to prevent nonce conflicts across multiple instances. To use this feature:
using DistributedLockManager;
using DistributedNonce;
services.AddHttpClient();
services.AddDistributedLockManager();
services.AddSingleton<IConnectionMultiplexer>(
await ConnectionMultiplexer.ConnectAsync("localhost:6379"));
services.AddDistributedNonce();
services.AddBlockChainTools();
For detailed documentation, examples, and API reference, visit the GitHub repository.
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.