Query Ethereum blocks, transactions, receipts, balances, and nonces using Nethereum (.NET). Use this skill whenever the user asks about getting block data, reading transactions, checking balances, fetching receipts, getting nonces, querying on-chain state, decoding event logs from receipts, detecting contracts, or reading ERC20 token balances with C# or .NET.
NuGet: Nethereum.Web3
All operations here are read-only — no private key needed.
using Nethereum.Web3;
var web3 = new Web3("https://mainnet.infura.io/v3/YOUR_KEY");
var balance = await web3.Eth.GetBalance.SendRequestAsync("0xaddress...");
var etherAmount = Nethereum.Util.UnitConversion.Convert.FromWei(balance.Value);
using Nethereum.RPC.Eth.DTOs;
var balance = await web3.Eth.GetBalance.SendRequestAsync(
"0xaddress...",
new BlockParameter(new HexBigInteger(15000000)));
BlockParameter also accepts BlockParameter.CreateLatest(), CreatePending(), CreateEarliest().
var blockNumber = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();
using Nethereum.Hex.HexTypes;
var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber
.SendRequestAsync(new HexBigInteger(blockNumber));
// block.Number, block.Timestamp, block.Transactions[]
// block.BaseFee (present on EIP-1559 blocks)
For tx hashes only (lighter): GetBlockWithTransactionsHashesByNumber.
var block = await web3.Eth.Blocks.GetBlockWithTransactionsByHash
.SendRequestAsync("0xabc123...");
Returns the transaction as submitted (before execution):
var tx = await web3.Eth.Transactions.GetTransactionByHash
.SendRequestAsync("0xtxhash...");
// tx.From, tx.To, tx.Value, tx.GasPrice
// tx.MaxFeePerGas, tx.MaxPriorityFeePerGas (EIP-1559)
// tx.Type (0x0 = legacy, 0x2 = EIP-1559)
Available after mining. Shows success/failure, gas used, and events:
var receipt = await web3.Eth.Transactions.GetTransactionReceipt
.SendRequestAsync("0xtxhash...");
// receipt.Status (1 = success, 0 = revert)
// receipt.GasUsed, receipt.EffectiveGasPrice
// receipt.Logs, receipt.BlockNumber
Both GetTransactionByHash and GetTransactionReceipt return null for unconfirmed transactions.
var nonce = await web3.Eth.Transactions.GetTransactionCount
.SendRequestAsync("0xaddress...");
var code = await web3.Eth.GetCode.SendRequestAsync("0xaddress...");
// Returns "0x" for EOAs, bytecode for contracts
var isContract = code != null && code != "0x";
using Nethereum.Contracts;
using Nethereum.Contracts.Standards.ERC20.ContractDefinition;
var receipt = await web3.Eth.Transactions.GetTransactionReceipt
.SendRequestAsync("0x654288d8...");
var events = receipt.DecodeAllEvents<TransferEventDTO>();
Console.WriteLine($"From: {events[0].Event.From}");
Console.WriteLine($"To: {events[0].Event.To}");
Console.WriteLine($"Value: {events[0].Event.Value}");
DecodeAllEvents<T>() scans all logs and returns only those matching the event signature.
var tokenBalance = await web3.Eth.ERC20
.GetContractService("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2")
.BalanceOfQueryAsync("0x8ee7d9235e01e6b42345120b5d270bdb763624c7");
Console.WriteLine(Web3.Convert.FromWei(tokenBalance, 18));
var receipt = await web3.Eth.Transactions.GetTransactionReceipt
.SendRequestAsync(txHash);
if (receipt == null)
Console.WriteLine("Transaction not yet mined");
else if (receipt.Status.Value == 1)
Console.WriteLine("Success");
else
Console.WriteLine("Reverted");
var costWei = receipt.GasUsed.Value * receipt.EffectiveGasPrice.Value;
var costEth = Nethereum.Util.UnitConversion.Convert.FromWei(costWei);