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
AddressLike Type
AddressLike is a union type accepting any input that can be coerced to an address:
Accepted Types
Number - Converted to 20-byte representation:0x prefix:
Performance
Zero-copy forUint8Array and AddressType (no allocation).
Conversion required for numbers, bigints, and strings (allocates new Uint8Array).
For performance-critical code, prefer passing Uint8Array or AddressType directly.
See Also
- fromHex - Parse hex string directly
- fromBytes - Create from Uint8Array directly
- fromNumber - Create from number/bigint directly
- fromPrivateKey - Derive from private key
- fromPublicKey - Derive from public key

