Try it Live
Run RLP examples in the interactive playground
Flattening Order
flatten uses depth-first traversal:
Usage Patterns
Extract Transaction Fields
Extract all byte values from transaction:Extract Proof Nodes
Extract all nodes from Merkle proof:Extract Log Data
Extract all data from event logs:Count Byte Values
Count total byte values in nested structure:Extract All Hashes
Extract all hash values from trie:Search for Value
Search for specific byte value in nested structure:Calculate Total Data Size
Calculate total bytes in nested structure:Return Type
flatten returns an array of BytesData:
Algorithm
Conceptual implementation:Depth-first Traversal
Performance
Complexity
- Time: O(n) where n is total number of items
- Space: O(n) for result array + O(d) for recursion depth
vs Manual Extraction
flatten is more convenient than manual extraction:
Caching
Cache flattened results for repeated access:See Also
- decode - Decode RLP bytes
- equals - Compare RLP data
- Types - RLP type system
- Usage Patterns - Real-world examples

