Skip to main content

Class: AptosAddress

moralis-monorepo / @moralisweb3/common-aptos-utils / AptosAddress

Class: AptosAddress

@moralisweb3/common-aptos-utils.AptosAddress

A representation of an address on the Aptos network.

Use this class any time you work with an address.

Implements

  • MoralisData

Table of contents

Methods

Properties

Constructors

Accessors

Methods

create

Static create(address): AptosAddress

Create a new instance of AptosAddress from any valid address input.

Example

const address = AptosAddress.create("0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90")

Throws

an error when a passed address is invalid.

Parameters

NameType
addressAptosAddressInput

Returns

AptosAddress


equals

Static equals(addressA, addressB): boolean

Check the equality between two Aptos addresses

Example

AptosAddress.equals("0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90", "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90")

Parameters

NameType
addressAAptosAddressInput
addressBAptosAddressInput

Returns

boolean


fromJSON

Static fromJSON(json): AptosAddress

Parameters

NameType
jsonstring

Returns

AptosAddress


equals

equals(address): boolean

Checks the equality of the current address with another Aptos address.

Example

address.equals("0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90")

Example

address.equals(AptosAddress.create("0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90"))

Parameters

NameType
addressAptosAddressInput

Returns

boolean

Implementation of

MoralisData.equals


format

format(): MoralisDataFormatted

Deprecated

This method will be removed soon. To format the value, use one of the properties.

Returns

MoralisDataFormatted

Implementation of

MoralisData.format


toJSON

toJSON(): string

Example

address.toJSON(); // "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90"

Returns

string

a string representing the address.


toString

toString(): string

Example

address.toString(); // "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90"

Returns

string

a string representing the address.

Properties

address

Readonly address: string

Constructors

constructor

new AptosAddress(address)

Parameters

NameType
addressstring

Accessors

short

get short(): string

Example

address.short; // "0x1"

Returns

string

a string representing the address, the leading zeros are removed from the address.