- Constants
- Function
from_bytes
- Function
to_bytes
- Function
to_ascii_string
- Function
length
- Function
max
- Function
zero
use 0x1::ascii;
use 0x2::bcs;
use 0x2::hex;
Error from from_bytes
when it is supplied too many or too few bytes.
const ErrorAddressParseError: u64 = 1;
Error from from_u256
when
const ErrorU256TooBigToConvertToAddress: u64 = 2;
The length of an address, in bytes
const LENGTH: u64 = 32;
const MAX: u256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
const ZERO: address = 0x0;
Convert a
into a u256 by interpreting a
as the bytes of a big-endian integer
(e.g., to_u256(0x1) == 1
)
Convert n
into an address by encoding it as a big-endian integer (e.g., from_u256(1) = @0x1
)
Aborts if n
> MAX_ADDRESS
Convert bytes
into an address.
Aborts with ErrorAddressParseError
if the length of bytes
is invalid length
public fun from_bytes(bytes: vector<u8>): address
Convert a
into BCS-encoded bytes.
Convert a
to a hex-encoded ASCII string
public fun to_ascii_string(a: address): ascii::String
Convert a
to a hex-encoded ASCII string
Length of a Rooch address in bytes
public fun length(): u64
Largest possible address
public fun max(): u256
all zeros address
public fun zero(): address