Creates an instance of AccountAddress from a Uint8Array.
This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.
A Uint8Array representing an account address.
Determine if two AccountAddresses are equal based on their underlying byte data.
The AccountAddress to compare to.
true if the AccountAddresses are equal, false if not.
Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive. In other words, the last byte of the address must be < 0b10000 (16) and every other byte must be zero.
For more information on how special addresses are defined, see AIP-40: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.
true if the address is special, false otherwise.
Serialize the AccountAddress to a Serializer instance's data buffer.
The serializer to serialize the AccountAddress to.
void
Serializes the current instance into a byte sequence suitable for entry functions. This allows for the proper encoding of data when interacting with entry functions in the blockchain.
The serializer instance used to convert the data into bytes.
Serializes the current instance for use in a script function by encoding it into a byte sequence. This process involves serializing the variant index and the instance data, making it suitable for transmission.
The serializer instance used to perform the serialization.
Return the AccountAddress as a string as per AIP-40. https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md. This representation returns special addresses in SHORT form (0xf) and other addresses in LONG form (0x + 64 characters).
AccountAddress as a string conforming to AIP-40.
Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.
NOTE: Prefer to use toString
where possible, as it formats special addresses using the SHORT form (no leading 0s).
AccountAddress as a string in LONG form.
Returns the account address as a string in LONG form without a leading 0x. This function will include leading zeroes and will produce a string of 64 hex characters.
NOTE: Prefer to use toString
where possible, as it formats special addresses using the SHORT form (no leading 0s).
The account address in LONG form.
Static
deserializeDeserialize an AccountAddress from the byte buffer in a Deserializer instance. This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.
The deserializer to deserialize the AccountAddress from.
An instance of AccountAddress.
Static
fromConvenience method for creating an AccountAddress from various input types. This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding AccountAddress.
The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array, or an existing AccountAddress.
Static
fromCreate an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.
The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.
Static
fromNOTE: This function has relaxed parsing behavior. For strict behavior, please use
the fromStringStrict
function. Where possible use fromStringStrict
rather than this
function, fromString
is only provided for backwards compatibility.
Creates an instance of AccountAddress from a hex string.
This function allows all formats defined by AIP-40. In short this means the following formats are accepted:
Where:
Learn more about the different address formats by reading AIP-40: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.
A hex string representing an account address.
An instance of AccountAddress.
Static
fromNOTE: This function has strict parsing behavior. For relaxed behavior, please use
the fromString
function.
Creates an instance of AccountAddress from a hex string.
This function allows only the strictest formats defined by AIP-40. In short this means only the following formats are accepted:
Where:
This means the following are not accepted:
A hex string representing an account address.
An instance of AccountAddress.
This function has strict parsing behavior. For relaxed behavior, please use the fromString
function.
AIP-40 documentation for more details on address formats: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.
Static
isCheck if the provided input is a valid AccountAddress.
The arguments for validation.
A hex string representing an account address.
Optional
strict?: booleanIf true, use strict parsing behavior; if false, use relaxed parsing behavior.
An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details. If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.
Readonly
dataThis is the internal representation of an account address.
Static
AStatic
FOURStatic
Readonly
LENGTHThe number of bytes that make up an account address.
Static
Readonly
LONG_The length of an address string in LONG form without a leading 0x.
Static
ONEStatic
THREEStatic
TWOStatic
ZERO
NOTE: Only use this class for account addresses. For other hex data, e.g. transaction hashes, use the Hex class.
AccountAddress is used for working with account addresses. Account addresses, when represented as a string, generally look like these examples:
Proper formatting and parsing of account addresses is defined by AIP-40. To learn more about the standard, read the AIP here: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.
The comments in this class make frequent reference to the LONG and SHORT formats, as well as "special" addresses. To learn what these refer to see AIP-40.