Skip to main content

Class: EvmAddress

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

Class: EvmAddress

@moralisweb3/common-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.

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

Returns

EvmAddress


equals

Static equals(addressA, addressB): boolean

Check the equality between two Evm addresses

Example

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

Parameters

NameType
addressAEvmAddressInput
addressBEvmAddressInput

Returns

boolean


fromJSON

Static fromJSON(address): EvmAddress

Parameters

NameType
addressstring

Returns

EvmAddress


equals

equals(address): boolean

Checks the equality of the current address with another evm address

Example

address.equals("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359")

Parameters

NameType
addressEvmAddressInput

Returns

boolean


toJSON

toJSON(): string

Returns a JSON representation of the address.

Returns

string

an address.