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
Name | Type | Description |
---|---|---|
value | SolNativeish | the value to create the SolNative from |
unit? | SolNativeUnit | the unit of the value (optional), defaults to solana |
Returns
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
Name | Type | Description |
---|---|---|
valueA | SolNativeish | the first value to compare |
valueB | SolNativeish | the second value to compare |
Returns
boolean
true if the values are equal
equals
▸ equals(value
): boolean
Compares SolNative with current instance.
Example
const native = SolNative.create(2, 'lamports');
native.equals(SolNative.create(1)); // false
Parameters
Name | Type | Description |
---|---|---|
value | SolNative | the value to compare with |
Returns
boolean
true if the values are equal
Implementation of
MoralisData.equals
format
▸ format(): MoralisDataFormatted
Converts the SolNative to a string.
Example
native.format()
Returns
MoralisDataFormatted
the value of the SolNative as a string
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