Nethereum.Model 7.0.0

Prefix Reserved
dotnet add package Nethereum.Model --version 7.0.0
                    
NuGet\Install-Package Nethereum.Model -Version 7.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="Nethereum.Model" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nethereum.Model" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Nethereum.Model" />
                    
Project file
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 Nethereum.Model --version 7.0.0
                    
#r "nuget: Nethereum.Model, 7.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 Nethereum.Model@7.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=Nethereum.Model&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nethereum.Model&version=7.0.0
                    
Install as a Cake Tool

Nethereum.Model

Core Ethereum data models representing transactions, blocks, accounts, and cryptographic signatures.

Overview

Nethereum.Model is a foundational package that defines the core data structures used throughout the Ethereum protocol. These models represent:

  • Transaction Types: Support for Legacy, EIP-2930, EIP-1559, and EIP-7702 transactions
  • Block Headers: Ethereum block header structure with all consensus fields
  • Account State: Account nonce, balance, storage root, and code hash
  • Signatures: ECDSA signature components (R, S, V) for transaction verification
  • Event Logs: Smart contract event data structures

This package provides the canonical implementation of Ethereum data structures with built-in RLP encoding/decoding support.

Installation

dotnet add package Nethereum.Model

Dependencies

Nethereum Dependencies:

  • Nethereum.RLP - Recursive Length Prefix encoding/decoding
  • Nethereum.Util - Keccak-256 hashing, address utilities, unit conversion

Key Concepts

Transaction Types

Ethereum has evolved to support multiple transaction formats:

  • Legacy Transactions (LegacyTransaction): Original transaction format (pre-EIP-155)
  • Legacy with Chain ID (LegacyTransactionChainId): EIP-155 transactions preventing replay attacks
  • EIP-2930 (Transaction2930): Transactions with access lists for gas optimization
  • EIP-1559 (Transaction1559): Fee market transactions with base fee and priority fee
  • EIP-7702 (Transaction7702): Account abstraction with authorization lists
  • EIP-4844 (Transaction4844): Blob transactions with KZG commitments for data availability

Blob Encoding

BlobEncoder converts arbitrary data to/from EIP-4844 blobs (131,072 bytes each, 4096 field elements):

// Encode data into blobs (auto-splits if > 126,976 bytes)
var blobs = BlobEncoder.EncodeBlobs(myData);

// Decode blobs back to original data
var decoded = BlobEncoder.DecodeBlobs(blobs);

BlobSidecar carries the blob data alongside the transaction for network transmission:

var tx = new Transaction4844(chainId, nonce, maxPriorityFee, maxFee, gasLimit,
    to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes);
tx.Sidecar = new BlobSidecar(blobs, commitments, proofs);

// Encode with sidecar for eth_sendRawTransaction
var networkBytes = tx.GetRLPEncodedWithSidecar();

RLP Encoding

All models implement RLP (Recursive Length Prefix) encoding, the serialization format used by Ethereum for:

  • Transmitting transactions over the network
  • Computing cryptographic hashes (transaction hash, block hash)
  • Storing data in the Ethereum state trie

Signatures

Ethereum uses ECDSA signatures with three components:

  • R: X-coordinate of the random point on the elliptic curve
  • S: Signature proof value
  • V: Recovery identifier (allows deriving the public key from the signature)

Chain Identification

The Chain enum provides constants for major Ethereum networks (MainNet, Sepolia, Polygon, Arbitrum, Optimism, Base, etc.) and is used with EIP-155 to prevent cross-chain replay attacks.

Numeric Types — EvmUInt256

Transaction amounts, gas limits, fees, nonces, chain IDs, block numbers, balances, and cumulative gas — every 256-bit scalar field on the model types — are typed as Nethereum.Util.EvmUInt256. The struct provides EVM-semantic unsigned arithmetic (wrap-around, divide-by-zero → zero) without System.Numerics.BigInteger allocations in hot paths.

BigInteger remains supported at the API boundary through an implicit conversion, so existing consumer code like amount: BigInteger.Parse("1000000000000000000") continues to compile and behave identically. For new code, prefer the direct EvmUInt256 constructor for small values (new EvmUInt256(1_000_000_000_000_000_000UL)) or the conversion helpers in EvmUInt256BigIntegerExtensions for arbitrary-precision input.

Block / Receipt Encoding Providers

IBlockEncodingProvider abstracts over the binary encoding of block headers, receipts, accounts, logs, and withdrawals so callers outside Nethereum.Model (state-root calculators, witness producers, SSZ encoders) can swap in alternative encoders without taking a direct RLP dependency. The default implementation is RlpBlockEncodingProvider (RLP canonical encoding for Ethereum mainnet); Nethereum.Model.SSZ supplies the beacon-chain SSZ variant.

Quick Start

using Nethereum.Model;
using System.Numerics;

// Create a simple EIP-1559 transaction
var transaction = new Transaction1559(
    chainId: 1,  // Ethereum Mainnet
    nonce: 0,
    maxPriorityFeePerGas: BigInteger.Parse("2000000000"),  // 2 gwei
    maxFeePerGas: BigInteger.Parse("100000000000"),        // 100 gwei
    gasLimit: 21000,
    receiverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    amount: BigInteger.Parse("1000000000000000000"),       // 1 ETH
    data: "",
    accessList: null
);

Usage Examples

Example 1: Creating a Legacy Transaction

using Nethereum.Model;
using System.Numerics;

// Create a legacy transaction (most common pre-2021)
var legacyTx = new LegacyTransaction(
    to: "0x13978aee95f38490e9769c39b2773ed763d9cd5f",
    amount: new BigInteger(10000000000000000L),  // 0.01 ETH
    nonce: 0,
    gasPrice: new BigInteger(1000000000000L),    // 1000 gwei
    gasLimit: 10000
);

// Transaction is ready to be signed with Nethereum.Signer

Source: tests/Nethereum.Signer.UnitTests/TransactionTests.cs

Example 2: Decoding a Signed Transaction from RLP

using Nethereum.Model;
using Nethereum.Hex.HexConvertors.Extensions;
using Nethereum.RLP;

// RLP-encoded signed transaction (typically from network or storage)
var rlpHex = "f86b8085e8d4a510008227109413978aee95f38490e9769c39b2773ed763d9cd5f872386f26fc10000801ba0eab47c1a49bf2fe5d40e01d313900e19ca485867d462fe06e139e3a536c6d4f4a014a569d327dcda4b29f74f93c0e9729d2f49ad726e703f9cd90dbb0fbf6649f1";

// Decode the transaction
var tx = new LegacyTransaction(rlpHex.HexToByteArray());

// Access transaction properties
var nonce = tx.Nonce.ToBigIntegerFromRLPDecoded();
var gasPrice = tx.GasPrice.ToBigIntegerFromRLPDecoded();
var value = tx.Value.ToBigIntegerFromRLPDecoded();
var to = tx.ReceiveAddress.ToHex();

// Access signature components
var v = tx.Signature.V[0];  // 27 or 28 for legacy transactions
var r = tx.Signature.R.ToHex();
var s = tx.Signature.S.ToHex();

Source: tests/Nethereum.Signer.UnitTests/TransactionTests.cs

Example 3: Using TransactionFactory to Decode Any Transaction Type

using Nethereum.Model;

// TransactionFactory automatically detects transaction type
var rlpEncoded = GetTransactionFromNetwork();  // byte[] from RPC or P2P

ISignedTransaction transaction = TransactionFactory.CreateTransaction(rlpEncoded);

// Check the transaction type
switch (transaction.TransactionType)
{
    case TransactionType.LegacyTransaction:
        var legacy = (LegacyTransaction)transaction;
        // Handle legacy transaction
        break;

    case TransactionType.EIP1559:
        var eip1559 = (Transaction1559)transaction;
        var maxFeePerGas = eip1559.MaxFeePerGas;
        var maxPriorityFee = eip1559.MaxPriorityFeePerGas;
        break;

    case TransactionType.LegacyEIP2930:
        var eip2930 = (Transaction2930)transaction;
        var accessList = eip2930.AccessList;
        break;

    case TransactionType.EIP7702:
        var eip7702 = (Transaction7702)transaction;
        var authList = eip7702.AuthorisationList;
        break;
}

Source: src/Nethereum.Model/TransactionFactory.cs

Example 4: Creating an EIP-1559 Transaction with Access List

using Nethereum.Model;
using Nethereum.Signer;
using System.Numerics;
using System.Collections.Generic;

// Create an access list (EIP-2930) to reduce gas costs
var accessList = new List<AccessListItem>
{
    new AccessListItem(
        address: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
        storageKeys: new List<byte[]>
        {
            "0x0000000000000000000000000000000000000000000000000000000000000001".HexToByteArray()
        }
    )
};

// Create an EIP-1559 transaction
var tx1559 = new Transaction1559(
    chainId: (int)Chain.MainNet,
    nonce: 42,
    maxPriorityFeePerGas: new BigInteger(2_000_000_000),   // 2 gwei tip
    maxFeePerGas: new BigInteger(100_000_000_000),         // 100 gwei max
    gasLimit: 100_000,
    receiverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    amount: BigInteger.Parse("5000000000000000000"),       // 5 ETH
    data: "0x",
    accessList: accessList
);

// Get RLP encoding for signing
var rlpForSigning = tx1559.GetRLPEncodedRaw();

Source: src/Nethereum.Model/Transaction1559.cs, src/Nethereum.Model/AccessListItem.cs

Example 5: Working with Ethereum Account State

using Nethereum.Model;
using System.Numerics;

// Create an account state object (as stored in the Ethereum state trie)
var account = new Account
{
    Nonce = 42,  // Number of transactions sent from this address
    Balance = BigInteger.Parse("5000000000000000000000"),  // 5000 ETH in wei
    StateRoot = stateRootHash,  // Root of the account's storage trie
    CodeHash = contractCodeHash  // Keccak-256 hash of the contract bytecode
};

// For EOA (Externally Owned Accounts), defaults are used:
var eoa = new Account
{
    Nonce = 0,
    Balance = BigInteger.Parse("1000000000000000000"),  // 1 ETH
    StateRoot = DefaultValues.EMPTY_TRIE_HASH,  // Empty storage
    CodeHash = DefaultValues.EMPTY_DATA_HASH    // No code
};

Source: src/Nethereum.Model/Account.cs

Example 6: Creating Event Logs

using Nethereum.Model;
using Nethereum.Hex.HexConvertors.Extensions;

// Create an event log (emitted by smart contracts)
var eventData = "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000".HexToByteArray();
var topic1 = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef".HexToByteArray();  // Transfer event signature
var topic2 = "0x000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f0beb".HexToByteArray();  // From address
var topic3 = "0x00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640".HexToByteArray();  // To address

var log = Log.Create(
    data: eventData,
    address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",  // Contract address
    topics: new[] { topic1, topic2, topic3 }
);

// Or create log without data
var logWithoutData = Log.Create(
    address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    topics: new[] { topic1, topic2, topic3 }
);

Source: src/Nethereum.Model/Log.cs

Example 7: Working with Block Headers

using Nethereum.Model;
using System.Numerics;

// Construct a block header
var blockHeader = new BlockHeader
{
    ParentHash = parentBlockHash,
    UnclesHash = unclesHash,
    Coinbase = "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326",  // Miner address
    StateRoot = stateRoot,
    TransactionsHash = transactionsTrieRoot,
    ReceiptHash = receiptsTrieRoot,
    BlockNumber = 18_000_000,
    LogsBloom = logsBloomFilter,
    Difficulty = 0,  // Post-merge (PoS) difficulty is always 0
    Timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
    GasLimit = 30_000_000,
    GasUsed = 12_543_210,
    MixHash = mixHash,
    ExtraData = extraData,
    Nonce = nonce,
    BaseFee = new BigInteger(15_000_000_000)  // EIP-1559 base fee
};

// Encode the block header for hashing
var encoded = BlockHeaderEncoder.Current.Encode(blockHeader);

Source: src/Nethereum.Model/BlockHeader.cs

Example 8: Creating Transactions for Different Networks

using Nethereum.Model;
using Nethereum.Signer;
using System.Numerics;

// Ethereum Mainnet transaction
var mainnetTx = new Transaction1559(
    chainId: (int)Chain.MainNet,  // 1
    nonce: 0,
    maxPriorityFeePerGas: new BigInteger(2_000_000_000),
    maxFeePerGas: new BigInteger(50_000_000_000),
    gasLimit: 21000,
    receiverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    amount: BigInteger.Parse("1000000000000000000"),
    data: "",
    accessList: null
);

// Polygon transaction (lower gas fees)
var polygonTx = new Transaction1559(
    chainId: (int)Chain.Polygon,  // 137
    nonce: 0,
    maxPriorityFeePerGas: new BigInteger(30_000_000_000),  // 30 gwei
    maxFeePerGas: new BigInteger(200_000_000_000),         // 200 gwei
    gasLimit: 21000,
    receiverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    amount: BigInteger.Parse("1000000000000000000"),
    data: "",
    accessList: null
);

// Base L2 transaction
var baseTx = new Transaction1559(
    chainId: (int)Chain.Base,  // 8453
    nonce: 0,
    maxPriorityFeePerGas: new BigInteger(100_000),      // Very low on L2
    maxFeePerGas: new BigInteger(1_000_000),
    gasLimit: 21000,
    receiverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    amount: BigInteger.Parse("1000000000000000000"),
    data: "",
    accessList: null
);

Source: Chain.cs enum values

Example 9: Account Storage Encoding

using Nethereum.Model;
using Nethereum.Util.HashProviders;
using Nethereum.Hex.HexConvertors.Extensions;

var sha3Provider = new Sha3KeccackHashProvider();

// Encode a storage key for the state trie
var storageKey = "0x0000000000000000000000000000000000000000000000000000000000000001".HexToByteArray();
var encodedKey = AccountStorage.EncodeKeyForStorage(storageKey, sha3Provider);

// Encode a storage value
var storageValue = "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000".HexToByteArray();
var encodedValue = AccountStorage.EncodeValueForStorage(storageValue);

// These encoded values are used in the Patricia Merkle Trie

Source: src/Nethereum.Model/Account.cs

API Reference

Transaction Types

TransactionType Enum
  • LegacyTransaction (-1): Pre-EIP-155 transactions
  • LegacyChainTransaction (-2): EIP-155 transactions with chain ID
  • LegacyEIP2930 (0x01): Transactions with access lists
  • EIP1559 (0x02): Fee market transactions
  • Blob (0x03): EIP-4844 blob transactions
  • EIP7702 (0x04): Account abstraction with authorization
LegacyTransaction

Pre-EIP-155 transaction format with basic fields.

Key Properties:

  • byte[] Nonce: Transaction sequence number
  • byte[] GasPrice: Gas price in wei
  • byte[] GasLimit: Maximum gas units
  • byte[] ReceiveAddress: Recipient address
  • byte[] Value: Amount in wei
  • byte[] Data: Contract call data or deployment code
  • Signature Signature: Transaction signature (R, S, V)

Key Methods:

  • byte[] GetRLPEncoded(): Get signed transaction RLP encoding
LegacyTransactionChainId

EIP-155 transaction with chain ID to prevent replay attacks.

Inherits from SignedLegacyTransaction (the same base LegacyTransaction inherits) with an added chain ID in the V signature component.

Transaction1559

EIP-1559 fee market transaction.

Key Properties:

  • EvmUInt256 ChainId: Network chain identifier
  • EvmUInt256? Nonce: Transaction sequence number
  • EvmUInt256? MaxPriorityFeePerGas: Miner tip
  • EvmUInt256? MaxFeePerGas: Maximum total fee per gas
  • EvmUInt256? GasLimit: Gas limit
  • string ReceiverAddress: Recipient
  • EvmUInt256? Amount: Value to transfer
  • string Data: Call data
  • List<AccessListItem> AccessList: Optional access list

Key Methods:

  • byte[] GetRLPEncoded(): Get complete RLP-encoded transaction
  • byte[] GetRLPEncodedRaw(): Get RLP encoding for signing (without signature)
Transaction2930

EIP-2930 transaction with access list.

Similar structure to Transaction1559 but uses GasPrice instead of base/priority fees.

Transaction7702

EIP-7702 transaction that allows EOAs to temporarily set account code for a single transaction via signed authorizations.

Key Properties:

  • EvmUInt256 ChainId: Network chain identifier
  • EvmUInt256? Nonce: Transaction sequence number
  • EvmUInt256? MaxPriorityFeePerGas: Miner tip
  • EvmUInt256? MaxFeePerGas: Maximum total fee per gas
  • EvmUInt256? GasLimit: Gas limit
  • string ReceiverAddress: Recipient
  • EvmUInt256? Amount: Value to transfer
  • string Data: Call data
  • List<AccessListItem> AccessList: Optional access list
  • List<Authorisation7702Signed> AuthorisationList: Signed authorization tuples

Key Methods:

  • byte[] GetRLPEncoded(): Get complete RLP-encoded transaction
  • byte[] GetRLPEncodedRaw(): Get RLP encoding for signing (without signature)
Gas7702

Gas cost constants for EIP-7702 authorization processing.

Constants:

  • PER_AUTH_BASE_COST = 12500: Base gas cost per authorization entry
  • PER_EMPTY_ACCOUNT_COST = 25000: Additional gas cost when the authorized account is empty
TransactionFactory

Factory class for creating and decoding transactions.

Key Methods:

  • static ISignedTransaction CreateTransaction(byte[] rlp): Automatically detects and decodes any transaction type
  • static ISignedTransaction CreateTransaction(string rlpHex): Hex string overload
  • static ISignedTransaction Create1559Transaction(...): Create EIP-1559 transaction
  • static ISignedTransaction Create2930Transaction(...): Create EIP-2930 transaction
  • static ISignedTransaction Create7702Transaction(...): Create EIP-7702 transaction
  • static ISignedTransaction CreateLegacyTransaction(...): Create legacy transaction

Block Models

BlockHeader

Ethereum block header structure.

Properties:

  • byte[] ParentHash: Hash of parent block
  • byte[] UnclesHash: Hash of uncle blocks list
  • string Coinbase: Miner/validator address
  • byte[] StateRoot: State trie root hash
  • byte[] TransactionsHash: Transactions trie root hash
  • byte[] ReceiptHash: Receipts trie root hash
  • EvmUInt256 BlockNumber: Block height
  • byte[] LogsBloom: Bloom filter for logs
  • EvmUInt256 Difficulty: Mining difficulty (0 post-merge)
  • long Timestamp: Block timestamp (Unix seconds)
  • long GasLimit: Maximum gas for block
  • long GasUsed: Total gas used in block
  • byte[] MixHash: PoW mix hash (random post-merge)
  • byte[] ExtraData: Arbitrary extra data
  • byte[] Nonce: PoW nonce (0 post-merge)
  • EvmUInt256? BaseFee: EIP-1559 base fee per gas
BlockHeaderEncoder

RLP encoder/decoder for block headers.

Methods:

  • byte[] Encode(BlockHeader header, bool legacyMode = false): Encode block header to RLP
  • BlockHeader Decode(byte[] rawdata, bool legacyMode = false): Decode RLP to block header

Account Models

Account

Ethereum account state.

Properties:

  • EvmUInt256 Nonce: Transaction count or contract creation count
  • EvmUInt256 Balance: Account balance in wei
  • byte[] StateRoot: Storage trie root (default: empty trie hash)
  • byte[] CodeHash: Contract code hash (default: empty data hash)
AccountStorage

Utilities for encoding account storage.

Methods:

  • static byte[] EncodeKeyForStorage(byte[] key, Sha3KeccackHashProvider): Encode storage key
  • static byte[] EncodeValueForStorage(byte[] value): Encode storage value

Signature Models

Signature : ISignature

ECDSA signature components.

Properties:

  • byte[] R: Signature R component
  • byte[] S: Signature S component
  • byte[] V: Recovery identifier

Constructors:

  • Signature(): Default constructor
  • Signature(byte[] r, byte[] s, byte[] v): Create with components
SignatureExtensions

Extension methods for signature operations.

Key Methods:

  • bool IsVSignedForChain(this ISignature signature): Check if V indicates chain-specific signature

Event Log Models

Log

Smart contract event log.

Properties:

  • string Address: Contract address that emitted the log
  • byte[] Data: Non-indexed event data
  • List<byte[]> Topics: Indexed event topics (event signature + indexed parameters)

Static Methods:

  • static Log Create(byte[] data, string address, params byte[][] topics): Create log with data
  • static Log Create(string address, params byte[][] topics): Create log without data
LogBloomFilter

Bloom filter for efficient log filtering.

Access List Models

AccessListItem

EIP-2930 access list entry.

Properties:

  • string Address: Contract address
  • List<byte[]> StorageKeys: Storage slots to pre-warm

Constructors:

  • AccessListItem(): Default constructor
  • AccessListItem(string address, List<byte[]> storageKeys): Create with values
AccessListRLPEncoderDecoder

RLP encoder/decoder for access lists.

Authorization Models (EIP-7702)

Authorisation7702

Unsigned authorization tuple specifying which contract code an EOA delegates to.

Properties:

  • EvmUInt256 ChainId: Chain ID the authorization is valid for
  • string Address: Contract address whose code the EOA will execute
  • EvmUInt256 Nonce: Nonce of the authorizing account at time of signing
Authorisation7702Signed

Signed authorization extending Authorisation7702 with ECDSA signature components. Implements ISignature.

Properties (inherited from Authorisation7702):

  • EvmUInt256 ChainId: Chain ID the authorization is valid for
  • string Address: Contract address whose code the EOA will execute
  • EvmUInt256 Nonce: Nonce of the authorizing account

Properties (signature):

  • byte[] V: YParity value
  • byte[] R: Signature R component
  • byte[] S: Signature S component

Constructors:

  • Authorisation7702Signed(): Default constructor
  • Authorisation7702Signed(EvmUInt256 chainId, string address, EvmUInt256 nonce, byte[] r, byte[] s, byte[] v): Create with all fields
  • Authorisation7702Signed(Authorisation7702 authorisation, Signature signature): Create from unsigned authorization and signature
  • Authorisation7702Signed(Authorisation7702 authorisation, byte[] r, byte[] s, byte[] v): Create from unsigned authorization and raw signature bytes
AuthorisationListRLPEncoderDecoder

RLP encoder/decoder for authorization lists.

Enumerations

Chain

Well-known Ethereum network chain IDs.

Common Values:

  • MainNet = 1: Ethereum Mainnet
  • Sepolia = 11155111: Sepolia testnet
  • Polygon = 137: Polygon PoS
  • Arbitrum = 42161: Arbitrum One
  • Optimism = 10: Optimism
  • Base = 8453: Base L2
  • Avalanche = 43114: Avalanche C-Chain
  • Binance = 56: BNB Chain

See Chain.cs for the complete list of 100+ networks

Utility Classes

DefaultValues

Default constant values used throughout the package.

Constants:

  • EMPTY_BYTE_ARRAY: Empty byte array
  • EMPTY_TRIE_HASH: Keccak-256 of empty trie
  • EMPTY_DATA_HASH: Keccak-256 of empty data
VRecoveryAndChainCalculations

Utilities for signature V value and chain ID calculations.

Methods:

  • static EvmUInt256 GetChainFromVChain(EvmUInt256 vChain): Extract chain ID from V
  • V value encoding/decoding for EIP-155

Used By (Consumers)

  • Nethereum.Signer - Signs transactions using the transaction models defined here
  • Nethereum.RPC - RPC methods return block headers, transactions, and logs
  • Nethereum.Contracts - Contract deployment and interaction uses transaction models
  • Nethereum.Accounts - Account management uses transaction types for sending
  • Nethereum.BlockchainProcessing - Processes blocks, transactions, and logs

Dependencies

  • Nethereum.RLP - All models use RLP encoding for serialization
  • Nethereum.Util - Uses Keccak-256 hashing, address validation, and byte conversions

Important Notes

Transaction Type Detection

When decoding transactions from RLP:

  • The first byte determines if it's a typed transaction (0x00-0x7F) or legacy (≥0xC0)
  • TransactionFactory.CreateTransaction() automatically detects the type
  • Legacy transactions are identified by their RLP list structure

V Signature Component

The V value in signatures serves dual purposes:

  • Recovery ID: Allows deriving the public key (and address) from the signature
  • Chain ID (EIP-155): For legacy transactions, V encodes chain ID as V = CHAIN_ID * 2 + 35 + {0,1}
  • For typed transactions (EIP-2930, EIP-1559, EIP-7702), V is simply 0 or 1

Gas Pricing Models

Different transaction types use different gas pricing:

  • Legacy & EIP-2930: Single gasPrice (user pays gasPrice × gasUsed)
  • EIP-1559+: maxFeePerGas and maxPriorityFeePerGas
    • Actual fee = min(maxFeePerGas, baseFee + maxPriorityFeePerGas) × gasUsed
    • BaseFee is burned, priority fee goes to validator

Chain ID Usage

Always specify the correct chain ID to prevent:

  • Replay attacks: Same transaction valid on multiple chains (e.g., mainnet and testnet)
  • Lost funds: Sending to wrong network addresses

RLP Encoding for Signing vs. Transmission

Transactions have two RLP encodings:

  • Raw encoding (GetRLPEncodedRaw()): Unsigned, used for signing
  • Full encoding (GetRLPEncoded()): Includes signature, used for transmission

Block Header Post-Merge Changes

After Ethereum's transition to Proof-of-Stake (The Merge):

  • Difficulty is always 0
  • Nonce is 0 (no longer used for mining)
  • MixHash contains randomness from the beacon chain
  • Coinbase is the fee recipient (validator or pool)

Account State Storage

Account state is stored in a Patricia Merkle Trie:

  • StateRoot: Root hash of the account's storage trie
  • CodeHash: Keccak-256 of contract bytecode (empty hash for EOAs)
  • These hashes allow verification without storing full state

Additional Resources

Ethereum Improvement Proposals (EIPs)

  • EIP-155: Simple replay attack protection (chain ID)
  • EIP-2718: Typed transaction envelope
  • EIP-2930: Optional access lists
  • EIP-1559: Fee market change (base fee + priority fee)
  • EIP-4844: Shard blob transactions
  • EIP-7702: Set EOA account code for one transaction

Ethereum Protocol

Nethereum Documentation

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (13)

Showing the top 5 NuGet packages that depend on Nethereum.Model:

Package Downloads
Nethereum.Signer

Nethereum signer library to sign and verify messages, RLP and transactions using an Ethereum account

Nethereum.RPC

Nethereum.RPC Ethereum Core RPC Class Library to interact via RPC with an Ethereum client, for example geth.

Nethereum.Merkle.Patricia

Nethereum Merkle Patrica trie and verification

Nethereum.Beaconchain

Nethereum.Beaconchain - Ethereum Beacon Chain REST API client library for light client, state, and validator endpoints.

Nethereum.CoreChain

Nethereum CoreChain - Core blockchain infrastructure for state, transactions, and receipts root management

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.0 318 10/2/2026
6.1.0 272,242 3/25/2026
6.0.4 24,877 3/18/2026
6.0.3 2,184 3/18/2026
6.0.1 3,774 3/17/2026
6.0.0 6,741 3/16/2026
5.8.0 139,369 1/6/2026
5.0.0 530,190 5/28/2025
4.29.0 477,170 2/10/2025
4.28.0 112,984 1/7/2025
4.27.1 18,424 12/24/2024
4.27.0 13,604 12/24/2024
4.26.0 141,658 10/1/2024
4.25.0 56,683 9/19/2024
4.21.4 173,553 8/9/2024
4.21.3 21,560 7/22/2024
4.21.2 84,086 6/26/2024
4.21.1 5,245 6/26/2024
4.21.0 28,076 6/18/2024
4.20.0 530,679 3/28/2024
Loading failed