Skip to main content

Class: Erc20Transaction

moralis-monorepo / @moralisweb3/common-evm-utils / Erc20Transaction

Class: Erc20Transaction

@moralisweb3/common-evm-utils.Erc20Transaction

The Erc20Transaction is a representation of an Erc20 token transaction.

Implements

  • MoralisDataObject

Table of contents

Methods

Accessors

Constructors

Methods

create

Static create(data): Erc20Transaction

Create a new instance of Erc20Transaction from any valid input

Example

const transfer = Erc20Transaction.create(data);

Parameters

NameTypeDescription
dataErc20Transactionishthe Erc20Transactionish type

Returns

Erc20Transaction


equals

Static equals(dataA, dataB): boolean

Check the equality between two Erc20 transfers

Example

Erc20Transaction.equals(dataA, dataB)

Parameters

NameTypeDescription
dataAErc20TransactionishThe first transfer to compare
dataBErc20TransactionishThe second transfer to compare

Returns

boolean

true if the transfers are equal, false otherwise


parse

Static parse(data): Erc20TransactionData

Parameters

NameType
dataErc20TransactionInput

Returns

Erc20TransactionData


equals

equals(data): boolean

Checks the equality of the current trnasfer with another erc20 trnasfer

Example

transfer.equals(data)

Parameters

NameTypeDescription
dataErc20Transactionishthe transfer to compare with

Returns

boolean

true if the transfers are equal, false otherwise

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
addressstring
blockHashstring
blockNumberstring
blockTimestampDate
chainstring
fromAddressstring
logIndexnumber
possibleSpamboolean
toAddressstring
transactionHashstring
transactionIndexnumber
valuestring

Implementation of

MoralisDataObject.format


toJSON

toJSON(): Object

Example

transfer.toJSON()

Returns

Object

a JSON represention of the transfer.

NameType
addressstring
blockHashstring
blockNumberstring
blockTimestampDate
chainstring
fromAddressstring
logIndexnumber
possibleSpamboolean
toAddressstring
transactionHashstring
transactionIndexnumber
valuestring

Implementation of

MoralisDataObject.toJSON

Accessors

address

get address(): EvmAddress

Example

transfer.address // EvmAddress

Returns

EvmAddress

the contract address of the transfer


blockHash

get blockHash(): string

Example

transfer.blockHash // "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86"

Returns

string

the block hash of the transfer


blockNumber

get blockNumber(): BigNumber

Example

transfer.blockNumber // BigNumber

Returns

BigNumber

the block number of the transfer


blockTimestamp

get blockTimestamp(): Date

Example

transfer.blockTimestamp // Date

Returns

Date

the block timestamp of the transfer


chain

get chain(): EvmChain

Example

transfer.chain // EvmChain

Returns

EvmChain

the chain of the transfer


contractAddress

get contractAddress(): EvmAddress

Example

transfer.contractAddress // EvmAddress

Returns

EvmAddress

the contract address of the transfer


fromAddress

get fromAddress(): EvmAddress

Example

transfer.fromAddress // EvmAddress

Returns

EvmAddress

the from address of the transfer


fromWallet

get fromWallet(): EvmAddress

Example

transfer.fromWallet // EvmAddress

Returns

EvmAddress

the from address of the transfer


logIndex

get logIndex(): number

Example

transfer.logIndex // 2

Returns

number

the logIndex of the transfer


possibleSpam

get possibleSpam(): boolean

Example

transfer.possibleSpam // true

Returns

boolean

possibility of the token being a spam token


result

get result(): Erc20TransactionData

Example

transfer.result

Returns

Erc20TransactionData

all the data without casting it to JSON.


toAddress

get toAddress(): EvmAddress

Example

transfer.toAddress // EvmAddress

Returns

EvmAddress

the to address of the transfer


toWallet

get toWallet(): EvmAddress

Example

transfer.toWallet // EvmAddress

Returns

EvmAddress

the to address of the transfer


transactionHash

get transactionHash(): string

Example

transfer.transactionHash // "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86"

Returns

string

the transaction hash of the transfer


transactionIndex

get transactionIndex(): number

Example

transfer.transactionIndex // 3

Returns

number

the transactionIndex of the transfer


value

get value(): BigNumber

Example

transfer.value // BigNumber

Returns

BigNumber

the value of the transfer

Constructors

constructor

new Erc20Transaction(data)

Parameters

NameType
dataErc20TransactionInput