Class: EvmAddress

moralis-monorepo / @moralisweb3/evm-utils / EvmAddress

Class: EvmAddress

@moralisweb3/evm-utils.EvmAddress

A representation of an address on the EVM network.

Use this class any time you work with an address, as it will provide utilities to validate the address,
and format it to lowercase and checksum format.

Implements

  • MoralisData

Table of contents

Accessors

Methods

Accessors

ZERO_ADDRESS

Static get ZERO_ADDRESS(): EvmAddress

Example

EvmAddress.ZERO_ADDRESS

Returns

EvmAddress

EvmAddress instance of the zero address: "0x0000000000000000000000000000000000000000"


checksum

get checksum(): string

Example

address.checksum // "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"

Returns

string

the address value in checksum (EIP-55) format (see https://eips.ethereum.org/EIPS/eip-55)


lowercase

get lowercase(): string

Example

address.lowercase // "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359"

Returns

string

the address value in lowercase format

Methods

create

Static create(address, core?): EvmAddress

Create a new instance of EvmAddress from any valid address input

Example

const address = EvmAddress.create("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359")
const address = EvmAddress.create("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359")
const address = EvmAddress.ZERO_ADDRESS

Parameters

NameType
addressEvmAddressish
core?MoralisCore

Returns

EvmAddress


equals

Static equals(addressA, addressB): boolean

Check the equality between two Evm addresses

Example

EvmAddress.equals("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359", "0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359")

Parameters

NameType
addressAEvmAddressish
addressBEvmAddressish

Returns

boolean


equals

equals(address): boolean

Checks the equality of the current address with another evm address

Example

address.equals("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359")

Parameters

NameType
addressEvmAddressish

Returns

boolean

Implementation of

MoralisData.equals


format

format(style?): string

Formats the address to a specific format.
If no formatStyle is provided as argument, it will use the formatEvmAddress set in the config.

Example

address.format() // "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"

Parameters

NameType
style?EvmAddressFormat

Returns

string

Implementation of

MoralisData.format


Did this page help you?