binary-merkle-trie

Implements EIP-7864 binary Merkle tries for stateless Ethereum execution in .NET.

2.3k|744|Updated Nov 23, 2015
One-click install
npx skills add https://github.com/Nethereum/Nethereum --skill binary-merkle-trie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: binary-merkle-trie
Source: https://github.com/Nethereum/Nethereum/tree/main/plugins/nethereum-skills/skills/binary-merkle-trie
Command: npx skills add https://github.com/Nethereum/Nethereum --skill binary-merkle-trie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Nethereum.Merkle.Binary.

What problem does it solve?

Working with EIP-7864 binary Merkle tries requires correctly deriving trie keys, packing account state, chunking bytecode, and generating inclusion proofs, which is error-prone when done manually in C#.

Core Features & Use Cases

  • Trie Operations: Insert, retrieve, delete, and compute roots on a binary Merkle trie using Nethereum.Merkle.Binary.
  • Key Derivation & State Packing: Map addresses and storage slots to trie keys and pack nonce, balance, and code size into BasicDataLeaf format.
  • Proof Generation & Verification: Build inclusion proofs with BinaryTrieProver and verify them against a root hash with BinaryTrieProofVerifier.
  • Use Case: A developer prototyping stateless Ethereum clients can derive keys for an account, insert account data and code chunks, then generate and verify a proof against the computed root.

Quick Start

Ask the AI to create a binary Merkle trie with Nethereum.Merkle.Binary, insert a key-value pair, and generate and verify an inclusion proof.

Frequently Asked Questions about binary-merkle-trie

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement an EIP-7864 binary Merkle trie in C#?

Install the Nethereum.Merkle.Binary NuGet package and use the BinaryTrie class with Put, Get, Delete, and ComputeRoot methods. Keys and values must each be exactly 32 bytes.

How to derive trie keys for Ethereum addresses and storage slots?

Use BinaryTreeKeyDerivation with a hash provider such as Blake3HashProvider. It provides GetTreeKeyForBasicData, GetTreeKeyForCodeHash, GetTreeKeyForStorageSlot, and GetTreeKeyForCodeChunk methods that accept a 20-byte address.

Does Nethereum.Merkle.Binary support BLAKE3 hashing?

Yes, pass a Blake3HashProvider instance to the BinaryTrie constructor to use BLAKE3. The default hash provider is SHA-256 via Sha256HashProvider.

How do I generate and verify binary trie inclusion proofs?

Create a BinaryTrieProver from your trie and call BuildProof with the key. Verify independently using BinaryTrieProofVerifier.VerifyProof with the root hash, key, and proof, which returns the value if valid or null otherwise.

Why does deleting a key not remove it from the binary trie?

The Delete method sets the value at the key to zero bytes rather than removing the key from the trie structure. This is the defined behavior of the BinaryTrie implementation.