Tricksfor.BlockChainTools
9.0.0
dotnet add package Tricksfor.BlockChainTools --version 9.0.0
NuGet\Install-Package Tricksfor.BlockChainTools -Version 9.0.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="Tricksfor.BlockChainTools" Version="9.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tricksfor.BlockChainTools" Version="9.0.0" />
<PackageReference Include="Tricksfor.BlockChainTools" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tricksfor.BlockChainTools --version 9.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tricksfor.BlockChainTools, 9.0.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.
#:package Tricksfor.BlockChainTools@9.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tricksfor.BlockChainTools&version=9.0.0
#tool nuget:?package=Tricksfor.BlockChainTools&version=9.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BlockChainTools
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.
Features
- HD Wallet Management - Generate and restore hierarchical deterministic wallets
- Balance Services - Query native, ERC20, and ERC721 token balances
- Gas Estimation - Estimate gas costs for various transaction types
- Transfer Services - Simplified transfers for native tokens, ERC20, and ERC721 (NFTs)
- Transaction & Block Services - Query blockchain data
- Web3 Provider - Easy Web3 instance creation with distributed nonce support
Installation
dotnet add package Tricksfor.BlockChainTools
Quick Start
1. Register Services
using BlockChainTools;
using Microsoft.Extensions.DependencyInjection;
var services = new ServiceCollection();
services.AddHttpClient(); // Required for GasService
services.AddBlockChainTools();
var provider = services.BuildServiceProvider();
2. Create Web3 Instance
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"
);
3. Common Operations
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);
Available Services
- IWeb3ProviderService - Create Web3 instances (read-only or with account)
- IBalanceService - Query native, ERC20, and ERC721 balances
- IGasService - Gas price queries and estimation (requires HttpClient)
- ITransferService - Transfer native tokens, ERC20, and ERC721 (NFTs)
- IHdWalletService - Generate/restore HD wallets and derive accounts
- ITransactionService - Query transaction details
- IBlockService - Query blockchain block information
Distributed Nonce Management
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();
Documentation
For detailed documentation, examples, and API reference, visit the GitHub repository.
License
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.10)
- Nethereum.Accounts (>= 5.0.0)
- Nethereum.HdWallet (>= 5.0.0)
- Nethereum.Signer (>= 5.0.0)
- Nethereum.Web3 (>= 5.0.0)
- Tricksfor.DistributedNonce (>= 9.0.0)
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 |
|---|---|---|
| 9.0.0 | 44 | 11/3/2025 |