Try it Live
Run AccessList examples in the interactive playground
Conversions
Encoding and decoding AccessList to/from RLP bytes.AccessList.toBytes()
Encode access list to RLP bytes.list: Access list to encode
- Top-level list of items
- Each item is [address, keys] pair
- Address encoded as 20-byte string
- Keys encoded as list of 32-byte strings
- Empty storageKeys encoded as empty list
[]
AccessList.fromBytes()
Decode RLP bytes to access list.bytes: RLP-encoded access list
- Error if not RLP list
- Error if item not [address, keys] pair
- Error if address not 20 bytes
- Error if storage key not 32 bytes
- Validates RLP structure
- Validates byte lengths
- Does not validate address checksums
- Does not deduplicate
Patterns
Round-trip Encoding
Transaction Integration
Safe Decoding
Serialize for Storage
Network Transmission
Compare Encoded Size
RLP Format Details
Empty List
Single Address, No Keys
Single Address, Single Key
Multiple Items
Size Calculations
Encoded Size Formula
- RLP list prefix: 1-9 bytes
- Item tuple prefix: 1 byte
- Keys list prefix: 1 byte
Size Analysis
Error Handling
Encoding Errors
Decoding Errors
Validation After Decoding
Best Practices
-
Validate before encoding
-
Always validate after decoding
-
Handle encoding errors gracefully
-
Deduplicate before encoding
-
Cache encoded results
Performance
| Operation | Complexity | Notes |
|---|---|---|
| toBytes | O(n×m) | Encodes all items |
| fromBytes | O(n×m) | Decodes all items |
- Cache encoded bytes if encoding multiple times
- Deduplicate before encoding to minimize size
- Reuse decoded lists instead of re-decoding
See Also
- Constructors - Creating lists
- RLP - RLP encoding
- Validation - Type guards

