Skip to main content

Class: SolNative

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

Class: SolNative

@moralisweb3/common-sol-utils.SolNative

The SolNative class is a MoralisData that references to the value of Solana native currency SOL

Implements

  • MoralisData

Table of contents

Methods

Accessors

Methods

create

Static create(value, unit?): SolNative

Create a new instance of SolNative from any valid SolNativeish value.

Example

const native = SolNative.create(2, 'lamports');
const native = SolNative.create(2);

Parameters

NameTypeDescription
valueSolNativeInputthe value to create the SolNative from
unit?SolNativeUnitthe unit of the value (optional), defaults to solana

Returns

SolNative

a new instance of SolNative


equals

Static equals(valueA, valueB): boolean

Compares two SolNativeish values.

Example

SolNative.equals(SolNative.create(1), SolNative.create(1)); // true

Parameters

NameTypeDescription
valueASolNativeInputthe first value to compare
valueBSolNativeInputthe second value to compare

Returns

boolean

true if the values are equal


fromJSON

Static fromJSON(json): SolNative

Parameters

NameType
jsonstring

Returns

SolNative


equals

equals(value): boolean

Compares SolNative with current instance.

Example

const native = SolNative.create(2, 'lamports');
native.equals(SolNative.create(1)); // false

Parameters

NameTypeDescription
valueSolNativethe value to compare with

Returns

boolean

true if the values are equal

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

Converts the SolNative to a string.

Example

native.toJSON()

Returns

string

the value of the SolNative as a string


toString

toString(): string

Converts the SolNative to a string.

Example

native.toString()

Returns

string

the value of the SolNative as a string

Accessors

lamports

get lamports(): string

Converts the SolNative to a string.

Example

native.lamports

Returns

string

the value of the SolNative as a string


solana

get solana(): string

Converts the SolNative to a solana unit.

Example

native.solana

Returns

string

the value of the SolNative as a solana string


value

get value(): BigNumber

Example

native.value

Returns

BigNumber

the value of the SolNative as a BigNumber