Skip to main content

Core Foundation

The foundation layer provides Ethereum primitives, ABI encoding, RPC communication, and the high-level Web3 entry point. Most users only need Nethereum.Web3, which pulls in all core dependencies.

The Simple Path: web3.Eth

web3.Eth is designed as a complete entry point for every common Ethereum task. Gas estimation, nonce management, EIP-1559 fee calculation, and transaction signing are all automatic — you never need to manage these unless you choose to.

var web3 = new Web3(account, "https://mainnet.infura.io/v3/YOUR-PROJECT-ID");

// Send ETH — fees, gas, nonce all handled automatically
var receipt = await web3.Eth.GetEtherTransferService()
.TransferEtherAndWaitForReceiptAsync("0xRecipient", 1.5m);

// Query any balance — read-only, no gas or signing needed
var balance = await web3.Eth.GetBalance.SendRequestAsync("0xAddress");
var ethBalance = Web3.Convert.FromWei(balance.Value);

Here's what web3.Eth gives you out of the box:

TaskSimple Path
Get ETH balanceweb3.Eth.GetBalance.SendRequestAsync(address)
Get ERC-20 balanceweb3.Eth.ERC20.GetContractService(addr).BalanceOfQueryAsync(owner)
Get ERC-721 balanceweb3.Eth.ERC721.GetContractService(addr).BalanceOfQueryAsync(owner)
Send ETHweb3.Eth.GetEtherTransferService().TransferEtherAndWaitForReceiptAsync(to, amount)
Send transaction with dataweb3.Eth.TransactionManager.SendTransactionAndWaitForReceiptAsync(input)
Get blockweb3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(num)
Get transactionweb3.Eth.Transactions.GetTransactionByHash.SendRequestAsync(hash)
Get receiptweb3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(hash)
Convert unitsWeb3.Convert.FromWei(value) / Web3.Convert.ToWei(value)
Resolve ENSweb3.Eth.GetEnsService().ResolveAddressAsync("vitalik.eth")
Multicall batchweb3.Eth.GetMultiQueryHandler()
Delegate EOA (EIP-7702)web3.Eth.GetEIP7022AuthorisationService().AuthoriseRequestAndWaitForReceiptAsync(contract)
Check if smart accountweb3.Eth.GetEIP7022AuthorisationService().IsDelegatedAccountAsync(address)
Get delegate contractweb3.Eth.GetEIP7022AuthorisationService().GetDelegatedAccountAddressAsync(address)
Revoke delegationweb3.Eth.GetEIP7022AuthorisationService().RemoveAuthorisationRequestAndWaitForReceiptAsync()

For token standards, Nethereum includes built-in typed services — no ABI needed:

  • web3.Eth.ERC20 — balances, transfers, allowances, metadata
  • web3.Eth.ERC721 — NFT ownership, metadata, enumeration
  • web3.Eth.ERC1155 — multi-token balances and batch operations

For smart account features, EIP-7702 lets any EOA delegate to a contract — batch calls, spending limits, gas sponsorship — all through web3.Eth.GetEIP7022AuthorisationService(). Delegate, check if an address has a smart account, get the delegate contract, or revoke — gas overhead is calculated automatically. For sponsored delegation (another account pays gas), use EIP7022SponsorAuthorisationService. See the EIP-7702 guide for details.

Every row in the table above works with zero fee configuration. When you need more control — explicit fees, legacy transactions, custom gas — every guide shows you how. But the simple path is always enough for common tasks.

Transactions

Every state change on Ethereum happens through a transaction. Sending ETH, calling a smart contract function, deploying a contract — all transactions.

Transaction Lifecycle

  1. Build — set the recipient, value, data, gas limit, and gas price
  2. Sign — the sender's private key signs the transaction (proves ownership)
  3. Send — the signed transaction is submitted to a node via JSON-RPC
  4. Mine — a validator includes the transaction in a block
  5. Receipt — the network returns a receipt with status, gas used, and logs

Transaction Types

TypeEIPDescription
Legacy (Type 0)Pre-EIP-2718Original format with gasPrice
Access List (Type 1)EIP-2930Adds access list for gas discounts on storage
EIP-1559 (Type 2)EIP-1559maxFeePerGas + maxPriorityFeePerGas (current default)
Blob (Type 3)EIP-4844Carries blob data for L2 rollups
Set Code (Type 7)EIP-7702Delegates EOA to smart contract code

Nethereum automatically uses EIP-1559 (Type 2) transactions when the network supports it.

Sending Transactions

// Simple ETH transfer
var receipt = await web3.Eth.GetEtherTransferService()
.TransferEtherAndWaitForReceiptAsync("0xRecipient", 1.5m);

// Contract function call
var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();
var receipt = await transferHandler.SendRequestAndWaitForReceiptAsync(
contractAddress,
new TransferFunction { To = recipient, Value = amount });

Blocks and the Chain

Ethereum organizes transactions into blocks — ordered bundles of transactions that are proposed, validated, and finalized by the network's consensus mechanism.

var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber
.SendRequestAsync(new HexBigInteger(18_000_000));

foreach (var tx in block.Transactions)
{
Console.WriteLine($"{tx.TransactionHash} | From: {tx.From} | To: {tx.To}");
}

Block Parameters

Many RPC calls accept a block parameter that specifies which state to query:

ParameterMeaning
latestMost recent block the node has processed
earliestGenesis block (block 0)
pendingPending state (transactions in the mempool)
finalizedLatest block that has achieved finality
safeLatest block safe from reorganization

Gas & Fees

Every computation on Ethereum costs gas. Since the London upgrade, Ethereum uses a two-component fee model (EIP-1559):

ComponentDescription
Base FeeSet by the protocol based on congestion. Burned.
Priority Fee (Tip)Goes to the validator. Incentivizes faster inclusion.
Max FeeThe absolute maximum you're willing to pay per gas unit.

Nethereum estimates gas automatically when you don't specify it:

var gas = await transferHandler.EstimateGasAsync(contractAddress, transferFunction);

Events & Logs

Events are the primary way smart contracts communicate what happened during a transaction. Indexed parameters become searchable topics; non-indexed parameters go into data.

var transferEvent = web3.Eth.GetEvent<TransferEventDTO>(contractAddress);
var filter = transferEvent.CreateFilterInput(
BlockParameter.CreateEarliest(),
BlockParameter.CreateLatest());

var events = await transferEvent.GetAllChangesAsync(filter);

For indexing large volumes of events, use Nethereum.BlockchainProcessing. See Data & Indexing.

ABI Encoding

The Application Binary Interface (ABI) is Ethereum's standard for encoding data when interacting with smart contracts. The easiest way to work with ABI encoding is through code-generated typed classes:

var transferFunction = new TransferFunction
{
To = "0xRecipientAddress",
Value = 1000
};

var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();
var receipt = await transferHandler.SendRequestAndWaitForReceiptAsync(contractAddress, transferFunction);

For manual encoding, use ABIEncode:

var abiEncode = new ABIEncode();
byte[] encoded = abiEncode.GetABIEncoded(
new ABIValue("address", "0x1234..."),
new ABIValue("uint256", 1000)
);

Guides

Step-by-step guides covering everything from reading balances to advanced transaction handling.

Essentials

GuideWhat You'll Learn
Query BalanceRead ETH, ERC-20, and ERC-721 balances
Unit ConversionConvert between Wei, Ether, Gwei, and custom decimals
Fee EstimationUnderstand automatic fees and customize when needed
Transfer EtherSend ETH with EtherTransferService
Send TransactionsSend transactions with data using the transaction manager
Query BlocksGet blocks, transactions, receipts, and nonces

Transaction Deep Dives

GuideWhat You'll Learn
Transaction TypesLegacy, EIP-1559, Blob, and EIP-7702 transaction models
EIP-7702 DelegationDelegate EOA to smart contract code — self, sponsored, and batch delegation
Transaction HashSign and predict the hash before sending
Transaction RecoveryRecover the sender from a signed transaction
Transaction ReplacementReplace a pending transaction with higher fees
Pending TransactionsRetrieve pending transactions from the mempool
Decode TransactionsDecode function calls from transaction input data

Encoding & Utilities

GuideWhat You'll Learn
ABI EncodingEncode and decode smart contract data
Hex EncodingWork with hex data
Address UtilitiesValidate and format addresses
RLP EncodingLow-level RLP encoding and decoding

Transport & Streaming

GuideWhat You'll Learn
RPC TransportChoose the right connection method
Real-Time StreamingSubscribe to blockchain events via WebSocket

Core Packages

PackageDescription
Nethereum.Web3High-level entry point aggregating RPC, contracts, accounts, and signing
Nethereum.ABIABI encoding/decoding for functions, events, errors, and complex types
Nethereum.ContractsSmart contract interaction, typed services (ERC-20/721/1155/ENS)
Nethereum.AccountsAccount types, transaction managers, nonce management
Nethereum.ModelBlock headers, transaction types, RLP encoding
Nethereum.RPCTyped wrappers for all standard RPC methods