Class: SolAddress

moralis-monorepo / @moralisweb3/sol-utils / SolAddress

Class: SolAddress

@moralisweb3/sol-utils.SolAddress

A representation of an address on the Solana network.

Use this class any time you work with an address.

Implements

  • MoralisData

Table of contents

Methods

Methods

create

Static create(address): SolAddress

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

Example

const address = SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")

Throws

an error when a passed address is invalid.

Parameters

NameType
addressSolAddressish

Returns

SolAddress


format

format(): MoralisDataFormatted

Formats the address to a specific format.
Currently returns a string representing the address.

Example

address.format(); // "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"

Returns

MoralisDataFormatted

Implementation of

MoralisData.format


equals

equals(address): boolean

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

Example

address.equals("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM")

Example

address.equals(SolAddress.create("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"))

Parameters

NameType
addressSolAddressish

Returns

boolean

Implementation of

MoralisData.equals


toString

toString(): string

Example

address.toString(); // "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"

Returns

string

a string representing the address.


toJSON

toJSON(): string

Example

address.toJSON(); // "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"

Returns

string

a string representing the address.


Did this page help you?