Class: Erc20Token
moralis-monorepo / @moralisweb3/common-evm-utils / Erc20Token
Class: Erc20Token
@moralisweb3/common-evm-utils.Erc20Token
The Erc20Token class is a MoralisData that references to a Erc20 Token It holds data about the data and metadata of an Erc20 token
Implements
MoralisDataObject
Table of contents
Methods
Accessors
Methods
create
▸ Static
create(value
, core?
): Erc20Token
Create a new instance of Erc20Token from any valid Erc20Token input
Example
const token = Erc20Token.create(value);
Parameters
Name | Type | Description |
---|---|---|
value | Erc20Tokenish | the Erc20Tokenish type |
core? | Core | The MoralisCore instance |
Returns
equals
▸ Static
equals(valueA
, valueB
): boolean
Compares two Erc20Token instances. This checks if the chain and contractAddress of both tokens are equal.
Example
Erc20Token.equals(valueA, valueB);
Parameters
Name | Type | Description |
---|---|---|
valueA | Erc20Tokenish | the first Erc20Token to compare |
valueB | Erc20Tokenish | the second Erc20Token to compare |
Returns
boolean
true if the two Erc20Tokens are equal
parse
▸ Static
parse(value
, core
): Erc20Data
Parameters
Name | Type |
---|---|
value | Erc20Input |
core | Core |
Returns
equals
▸ equals(value
): boolean
Compares Erc20Token instance to current instance
Example
token.equals(value);
Parameters
Name | Type | Description |
---|---|---|
value | Erc20Tokenish | the Erc20Tokenish to compare |
Returns
boolean
true if the Erc20Token is equals given token
Implementation of
MoralisDataObject.equals
format
▸ format(): Object
Returns the token as JSON
Example
token.format();
Returns
Object
the Erc20Token as a JSON object
Name | Type |
---|---|
chain | string | number |
contractAddress | string |
decimals | number |
logo? | null | string |
logoHash? | null | string |
name | string |
symbol | string |
thumbnail? | null | string |
Implementation of
MoralisDataObject.format
toJSON
▸ toJSON(): Object
Returns the token as JSON
Example
token.toJSON();
Returns
Object
the Erc20Token as a JSON object
Name | Type |
---|---|
chain | string | number |
contractAddress | string |
decimals | number |
logo? | null | string |
logoHash? | null | string |
name | string |
symbol | string |
thumbnail? | null | string |
Implementation of
MoralisDataObject.toJSON
Accessors
chain
• get
chain(): EvmChain
Example
token.chain;
Returns
The chain of the token.
contractAddress
• get
contractAddress(): EvmAddress
Example
token.contractAddress;
Returns
The contract address of the token.
decimals
• get
decimals(): number
Example
token.decimals;
Returns
number
the decimals of the token.
logo
• get
logo(): undefined
| null
| string
Example
token.logo;
Returns
undefined
| null
| string
The logo of the token.
logoHash
• get
logoHash(): undefined
| null
| string
Example
token.logoHash;
Returns
undefined
| null
| string
The logo hash of the token.
name
• get
name(): string
Example
token.name;
Returns
string
The name of the token.
result
• get
result(): Erc20Data
Returns the processed Erc20Token.
Example
token.result;
Returns
the Erc20Token value
symbol
• get
symbol(): string
Example
token.symbol;
Returns
string
The symbol of the token.
thumbnail
• get
thumbnail(): undefined
| null
| string
Example
token.thumbnail;
Returns
undefined
| null
| string
The thumbnail of the token.