Class: AptosNative
moralis-monorepo / @moralisweb3/common-aptos-utils / AptosNative
Class: AptosNative
@moralisweb3/common-aptos-utils.AptosNative
The AptosNative class is a MoralisData that references to the value of Aptos native currency APT
Implements
MoralisData
Table of contents
Methods
Accessors
Methods
create
▸ Static
create(value
, unit?
): AptosNative
Create a new instance of AptosNative from any valid AptosNativeInput value.
Example
const native = AptosNative.create(2, 'octas');
const native = AptosNative.create(2);
Parameters
Name | Type | Description |
---|---|---|
value | AptosNativeInput | the value to create the AptosNative from |
unit? | AptosNativeUnit | the unit of the value (optional), defaults to aptos |
Returns
a new instance of AptosNative
equals
▸ Static
equals(valueA
, valueB
): boolean
Compares two AptosNativeish values.
Example
AptosNative.equals(AptosNative.create(1), AptosNative.create(1)); // true
Parameters
Name | Type | Description |
---|---|---|
valueA | AptosNativeInput | the first value to compare |
valueB | AptosNativeInput | the second value to compare |
Returns
boolean
true if the values are equal
fromJSON
▸ Static
fromJSON(json
): AptosNative
Parameters
Name | Type |
---|---|
json | string |
Returns
equals
▸ equals(value
): boolean
Compares AptosNative with current instance.
Example
const native = AptosNative.create(2, 'octas');
native.equals(AptosNative.create(1)); // false
Parameters
Name | Type | Description |
---|---|---|
value | AptosNative | the 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 AptosNative to a string.
Example
native.toJSON()
Returns
string
the value of the AptosNative as a string
toString
▸ toString(): string
Converts the AptosNative to a string.
Example
native.toString()
Returns
string
the value of the AptosNative as a string
Accessors
aptos
• get
aptos(): string
Converts the AptosNative to an aptos unit.
Example
native.aptos
Returns
string
the value of the AptosNative as an aptos string
octas
• get
octas(): string
Converts the AptosNative to a string.
Example
native.lamports
Returns
string
the value of the AptosNative as a string
value
• get
value(): BigNumber
Example
native.value
Returns
BigNumber
the value of the AptosNative as a BigNumber