Try it Live
Run Address examples in the interactive playground
- C
primitives_address_from_hex(const char* hex, PrimitivesAddress* out_address): int
Create address from hex string in C. Accepts hex strings with or without 0x prefix.Parameters:hex: const char*- Hex string (with or without0xprefix)out_address: PrimitivesAddress*- Pointer to output address struct (20 bytes)
int - PRIMITIVES_SUCCESS (0) on success, error code otherwiseExample:- Returns non-zero error code on failure
- Check result before using
out_address - Common errors: invalid hex format, incorrect length
Format Requirements
Length (implementation-dependent): TypeScript implementations (Class API):- Requires
0xprefix: exactly 42 characters total
- Accepts both formats:
- With
0xprefix: exactly 42 characters - Without
0xprefix: exactly 40 characters
- With
- Valid:
0-9,a-f,A-F - Invalid:
g-z,G-Z, whitespace, special characters
- Parsing is case-insensitive
- Both lowercase and uppercase hex are accepted
- Mixed-case (EIP-55 checksummed) addresses are valid
Error Handling
Validation Before Parsing
UseAddress.isValid() to check before parsing:
EIP-55 Checksums
fromHex() accepts checksummed addresses but does not validate checksums. Use isValidChecksum() to validate before parsing:
See Also
- from - Universal constructor
- fromBytes - Create from Uint8Array
- toHex - Convert to hex string
- toChecksummed - Convert to EIP-55 checksummed hex
- isValid - Validate address format
- isValidChecksum - Validate EIP-55 checksum
- EIP-55: Mixed-case checksum

