Skip to Content

🚧 These packages are still in development and may change rapidly as they are developed.

TypeScriptfetchAddressFromName

fetchAddressFromName

This function is used to fetch the address from an ANS name.

Usage

import { AptosJSProClient } from "@aptos-labs/js-pro"; const client = new AptosJSProClient({ /* ... */ }); const address = await client.fetchAddressFromName({ name: "aptos.apt", });

Parameters

NameTypeDefault
namestring | AptosName

The name to fetch the address for. You can pass in an instance of AptosName or a string.

networkNetworkInfo

The network to use for the request. If not set, the network of the AptosJSProClient instance will be used.

Return Type

The fetchAddressFromName function will return an AccountAddress or null if the name does not exist.

AccountAddress

NameTypeDefault
dataUint8Array<ArrayBufferLike>

This is the internal representation of an account address.

isSpecial() => boolean

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 .

toString() => `0x${string}`

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).

toStringWithoutPrefix() => string

Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.

NOTE: Prefer to use toString where possible.

toStringLong() => `0x${string}`

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).

toStringLongWithoutPrefix() => string

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).

toStringShort() => `0x${string}`

Convert the account address to a string in SHORT format, which is 0x followed by the shortest possible representation (no leading zeros).

toStringShortWithoutPrefix() => string

Returns a lossless short string representation of the address by trimming leading zeros. If the address consists of all zeros, returns “0”.

toUint8Array() => Uint8Array<ArrayBufferLike>

Get the inner data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.

serialize(serializer: Serializer) => void

Serialize the AccountAddress to a Serializer instance’s data buffer.

serializeForEntryFunction(serializer: Serializer) => 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.

serializeForScriptFunction(serializer: Serializer) => void

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.

equals(other: AccountAddress) => boolean

Determine if two AccountAddresses are equal based on their underlying byte data.

bcsToBytes() => Uint8Array<ArrayBufferLike>

Serializes a Serializable value to its BCS representation. This function is the TypeScript SDK equivalent of bcs::to_bytes in Move.

bcsToHex() => Hex

Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.

Last updated on