Skip to main content

Class: SolAddress

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

Class: SolAddress

@moralisweb3/common-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

Properties

Constructors

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
addressSolAddressInput

Returns

SolAddress


fromJSON

Static fromJSON(address): SolAddress

Parameters

NameType
addressstring

Returns

SolAddress


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
addressSolAddressInput

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(); // "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"

Returns

string

a string representing the address.


toString

toString(): string

Example

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

Returns

string

a string representing the address.

Properties

address

Readonly address: string

Constructors

constructor

new SolAddress(address)

Parameters

NameType
addressstring