- Constants
- Function
from_bytes
- Function
from_bytes_option
- Function
to_bytes
- Function
to_ascii_string
- Function
to_string
- Function
from_ascii_bytes
- Function
from_ascii_bytes_option
- Function
from_ascii_string
- Function
length
- Function
max
- Function
zero
use 0x1::ascii;
use 0x1::option;
use 0x1::string;
use 0x1::vector;
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 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 or if the bytes are not a valid address
public fun from_bytes(bytes: vector<u8>): address
Convert bytes
into an address.
Returns None
if the length of bytes
is invalid length or if the bytes are not a valid address
public fun from_bytes_option(bytes: vector<u8>): option::Option<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
public fun to_string(a: &address): string::String
Converts an ASCII string to an address, taking the numerical value for each character. The
string must be Base16 encoded, and thus exactly 64 characters long.
For example, the string "00000000000000000000000000000000000000000000000000000000DEADB33F"
will be converted to the address @0xDEADB33F.
Aborts with EAddressParseError
if the length of s
is not 64,
or if an invalid character is encountered.
public fun from_ascii_bytes(bytes: &vector<u8>): address
public fun from_ascii_bytes_option(bytes: &vector<u8>): option::Option<address>
Convert a
from a little endian encoding hex ASCII string
public fun from_ascii_string(a: ascii::String): option::Option<address>
Length of a Rooch address in bytes
public fun length(): u64
Largest possible address
all zeros address
public fun zero(): address