Overview
Bytes provides variable-length and fixed-size byte array types used throughout Ethereum. The module includes:- Bytes - Variable-length byte arrays
- Bytes1-Bytes8 - Small fixed-size types (1-8 bytes)
- Bytes16 - 16-byte fixed type (UUIDs, nonces)
- Bytes32 - 32-byte fixed type (storage, hashes)
- Bytes64 - 64-byte fixed type (signatures, public keys)
Uint8Array values with zero runtime overhead.
- Type Definition
Uint8Array values. TypeScript enforces type safety through a unique Symbol brand, preventing accidental mixing with other Uint8Arrays.Quick Start
- Variable-Length Bytes
- Fixed-Size Bytes
- Comparisons
Variable-Length Bytes API
Constructors
Conversions
Manipulation
Comparisons
Validation
Fixed-Size Types
Bytes32
32-byte fixed type for storage values, numeric representations, and general-purpose 32-byte data.Bytes64
64-byte fixed type for signatures and uncompressed public keys.Bytes16
16-byte fixed type for UUIDs and nonces.Bytes1-Bytes8
Small fixed-size types for packed data.Error Types
| Error | Cause |
|---|---|
InvalidBytesLengthError | Wrong byte length for fixed-size type |
InvalidBytesFormatError | Invalid hex format (missing 0x, odd length, bad chars) |
InvalidValueError | Unsupported input type |

