Skip to main content

Class: EvmTransaction

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

Class: EvmTransaction

@moralisweb3/common-evm-utils.EvmTransaction

The EvmTransaction is a representation of a published transaction.

Use this class any time you work with a transaction.

Hierarchy

Table of contents

Methods

Accessors

Constructors

Properties

Methods

create

Static create(data): EvmTransaction

Create a new instance of EvmTransaction from any valid transaction input

Example

const transaction = EvmTransaction.create(data);

Parameters

NameTypeDescription
dataEvmTransactionishthe EvmTransactionish type

Returns

EvmTransaction


equals

Static equals(dataA, dataB): boolean

Check the equality between two Evm transactions

Example

EvmTransaction.equals(dataA, dataB)

Parameters

NameTypeDescription
dataAEvmTransactionishThe first transaction
dataBEvmTransactionishThe second transaction

Returns

boolean


parse

Static parse(data): EvmTransactionData

Parameters

NameType
dataEvmTransactionInput

Returns

EvmTransactionData


equals

equals(data): boolean

Checks the equality of the current transaction with another evm transaction

Example

transaction.equals(data)

Parameters

NameTypeDescription
dataEvmTransactionishthe transaction to compare with

Returns

boolean


format

format(): Object

Deprecated

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

Returns

Object

NameType
blockHashstring
blockNumberstring
blockTimestampstring
chainstring
contractAddressundefined | string
cumulativeGasUsedstring
data?string
fromstring
gasundefined | string
gasPricestring
gasUsedstring
hashstring
indexstring | number
internalTransactionsEvmInternalTransactionJSON[]
logs{ address: string ; blockHash: string ; blockNumber: number ; blockTimestamp?: string ; chain: string ; data: string ; logIndex?: number ; topics: (null | string)[] ; transactionHash: string ; transactionIndex?: number }[]
nonceundefined | string
receiptRoot?string
receiptStatus?number
signatureundefined | MoralisDataObjectValue
toundefined | string
valueundefined | string

toJSON

toJSON(): Object

Returns

Object

NameType
blockHashstring
blockNumberstring
blockTimestampstring
chainstring
contractAddressundefined | string
cumulativeGasUsedstring
data?string
fromstring
gasundefined | string
gasPricestring
gasUsedstring
hashstring
indexstring | number
internalTransactionsEvmInternalTransactionJSON[]
logs{ address: string ; blockHash: string ; blockNumber: number ; blockTimestamp?: string ; chain: string ; data: string ; logIndex?: number ; topics: (null | string)[] ; transactionHash: string ; transactionIndex?: number }[]
nonceundefined | string
receiptRoot?string
receiptStatus?number
signatureundefined | MoralisDataObjectValue
toundefined | string
valueundefined | string

Accessors

blockHash

get blockHash(): string

Example

transaction.blockHash // 0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86

Returns

string

the transaction black hash


blockNumber

get blockNumber(): BigNumber

Example

transaction.blockNumber // 12526958

Returns

BigNumber

the transaction block number


blockTimestamp

get blockTimestamp(): Date

Example

transaction.blockTimestamp // Date

Returns

Date

the transaction block timestamp


chain

get chain(): EvmChain

Example

transaction.chain // EvmChain

Returns

EvmChain

the transaction chain


contractAddress

get contractAddress(): undefined | EvmAddress

Example

transaction.contractAddress // EvmAddress

Returns

undefined | EvmAddress

the transaction contract address


cumulativeGasUsed

get cumulativeGasUsed(): BigNumber

Example

transaction.cumulativeGasUsed // 1340925

Returns

BigNumber

the transaction cumulative gas used


data

get data(): undefined | string

Example

transaction.data // 0x000000000000000000000000000000000000000000000000000000000000002

Returns

undefined | string

the transaction data


from

get from(): EvmAddress

Example

transaction.address // EvmAddress

Returns

EvmAddress

the transaction from address


gas

get gas(): undefined | BigNumber

Example

transaction.gas // 6721975

Returns

undefined | BigNumber

the transaction gas


gasPrice

get gasPrice(): BigNumber

Example

transaction.gasPrice // 20000000000

Returns

BigNumber

the transaction gas price


gasUsed

get gasUsed(): BigNumber

Example

transaction.gasUsed // 1340925

Returns

BigNumber

the transaction gas used


hash

get hash(): string

Example

transaction.hash // 0x057Ec652A4F150f7FF94f089A38008f49a0DF88e

Returns

string

the transaction hash


index

get index(): string | number

Example

transaction.index // 1

Returns

string | number

the index


internalTransactions

get internalTransactions(): EvmInternalTransaction[]

Example

transaction.logs // EvmInternalTransaction[]

Returns

EvmInternalTransaction[]

the internal transactions


logs

get logs(): EvmTransactionLog[]

Example

transaction.logs // EvmTransactionLog[]

Returns

EvmTransactionLog[]

the transaction logs


nonce

get nonce(): undefined | BigNumber

Example

transaction.nonce // 326595425

Returns

undefined | BigNumber

the transaction nonce


r

get r(): undefined | string

Returns

undefined | string


receiptRoot

get receiptRoot(): undefined | string

Example

transaction.receiptRoot // string

Returns

undefined | string

the transaction receipt root


receiptStatus

get receiptStatus(): undefined | number

Example

transaction.receiptStatus // 1

Returns

undefined | number

the transaction receipt status


result

get result(): EvmTransactionData

Example

transaction.result

Returns

EvmTransactionData

the transaction


s

get s(): undefined | string

Returns

undefined | string


signature

get signature(): undefined | EvmSignature

Example

transaction.signature // EvmSignature

Returns

undefined | EvmSignature

the signature (if available)


to

get to(): undefined | EvmAddress

Example

transaction.to // EvmAddress

Returns

undefined | EvmAddress

the transaction to address


v

get v(): undefined | number

Returns

undefined | number


value

get value(): undefined | EvmNative

Example

transaction.value // EvmNative

Returns

undefined | EvmNative

the transaction value

Constructors

constructor

new EvmTransaction(data)

Parameters

NameType
dataEvmTransactionInput

Properties

_data

Protected _data: EvmTransactionData