Skip to content

Latest commit

 

History

History
223 lines (106 loc) · 6.07 KB

address.md

File metadata and controls

223 lines (106 loc) · 6.07 KB

Module 0x2::address

Constants

Error from from_bytes when it is supplied too many or too few bytes.

const ErrorAddressParseError: u64 = 1;

Error from from_u256 when

The length of an address, in bytes

const LENGTH: u64 = 32;

const MAX: u256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935;

const ZERO: address = 0x0;

Function from_bytes

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

Function from_bytes_option

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>

Function to_bytes

Convert a into BCS-encoded bytes.

public fun to_bytes(a: &address): vector<u8>

Function to_ascii_string

Convert a to a hex-encoded ASCII string

public fun to_ascii_string(a: &address): ascii::String

Function to_string

Convert a to a hex-encoded ASCII string

public fun to_string(a: &address): string::String

Function from_ascii_bytes

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

Function from_ascii_bytes_option

public fun from_ascii_bytes_option(bytes: &vector<u8>): option::Option<address>

Function from_ascii_string

Convert a from a little endian encoding hex ASCII string

Function length

Length of a Rooch address in bytes

public fun length(): u64

Function max

Largest possible address

public fun max(): u256

Function zero

all zeros address

public fun zero(): address