Skip to main content

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): Erc20Token

Create a new instance of Erc20Token from any valid Erc20Token input

Example

const token = Erc20Token.create(value);

Parameters

NameTypeDescription
valueErc20Tokenishthe Erc20Tokenish type

Returns

Erc20Token


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

NameTypeDescription
valueAErc20Tokenishthe first Erc20Token to compare
valueBErc20Tokenishthe second Erc20Token to compare

Returns

boolean

true if the two Erc20Tokens are equal


parse

Static parse(value): Erc20Data

Parameters

NameType
valueErc20Input

Returns

Erc20Data


equals

equals(value): boolean

Compares Erc20Token instance to current instance

Example

token.equals(value);

Parameters

NameTypeDescription
valueErc20Tokenishthe Erc20Tokenish to compare

Returns

boolean

true if the Erc20Token is equals given token

Implementation of

MoralisDataObject.equals


format

format(): Object

Deprecated

This method will be removed soon. To format the value, use one of the properties.

Returns

Object

NameType
chainstring
contractAddressstring
decimalsnumber
logo?null | string
logoHash?null | string
namestring
possibleSpam?boolean
symbolstring
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

NameType
chainstring
contractAddressstring
decimalsnumber
logo?null | string
logoHash?null | string
namestring
possibleSpam?boolean
symbolstring
thumbnail?null | string

Implementation of

MoralisDataObject.toJSON

Accessors

chain

get chain(): EvmChain

Example

token.chain;

Returns

EvmChain

The chain of the token.


contractAddress

get contractAddress(): EvmAddress

Example

token.contractAddress;

Returns

EvmAddress

The contract address of the token.


decimals

get decimals(): number

Example

token.decimals;

Returns

number

the decimals of the token.


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.


possibleSpam

get possibleSpam(): undefined | boolean

Example

transfer.possibleSpam // true

Returns

undefined | boolean

possibility of the token being a spam token


result

get result(): Erc20Data

Returns the processed Erc20Token.

Example

token.result;

Returns

Erc20Data

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.