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
Return Type
The fetchAddressFromName
function will return an AccountAddress
or null
if the name does not exist.
AccountAddress
Name | Type | Default |
---|---|---|
data | Uint8Array<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 | |
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 | |
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 | |
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 | |
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. |