Skip to content

Address

Utility class for ethereum addresses. Wraps EthjsAddress with a tevm style API. toString returns a checksummed address rather than lowercase

Example

import { createAddress } from '@tevm/address';
// takes hex string
let address = createAddress(`0x${'00'.repeat(20)}`);
// takes number and bigint
address = createAddress(0);
// takes bytes
address = createAddress(new Uint8Array());
// non hex string
address = createAddress('55'.repeat(20));

Extends

Constructors

new Address()

new Address(bytes): Address

Parameters

bytes: Uint8Array

Returns

Address

Inherited from

EthjsAddress.constructor

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:7

Properties

bytes

readonly bytes: Uint8Array

Inherited from

EthjsAddress.bytes

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:6

Methods

equals()

equals(address): boolean

Is address equal to another.

Parameters

address: EthjsAddress

Returns

boolean

Inherited from

EthjsAddress.equals

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:43


isPrecompileOrSystemAddress()

isPrecompileOrSystemAddress(): boolean

True if address is in the address range defined by EIP-1352

Returns

boolean

Inherited from

EthjsAddress.isPrecompileOrSystemAddress

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:52


isZero()

isZero(): boolean

Is address zero.

Returns

boolean

Inherited from

EthjsAddress.isZero

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:47


toBytes()

toBytes(): Uint8Array

Returns a new Uint8Array representation of address.

Returns

Uint8Array

Inherited from

EthjsAddress.toBytes

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:60


toString()

toString(): `0x${string}`

Returns the checksummed address.

Returns

`0x${string}`

The checksummed address.

Overrides

EthjsAddress.toString

Defined in

packages/address/src/Address.js:27


fromPrivateKey()

static fromPrivateKey(privateKey): EthjsAddress

Returns an address for a given private key.

Parameters

privateKey: Uint8Array

A private key must be 256 bits wide

Returns

EthjsAddress

Inherited from

EthjsAddress.fromPrivateKey

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:26


fromPublicKey()

static fromPublicKey(pubKey): EthjsAddress

Returns an address for a given public key.

Parameters

pubKey: Uint8Array

The two points of an uncompressed key

Returns

EthjsAddress

Inherited from

EthjsAddress.fromPublicKey

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:21


fromString()

static fromString(str): EthjsAddress

Returns an Address object from a hex-encoded string.

Parameters

str: string

Hex-encoded address

Returns

EthjsAddress

Inherited from

EthjsAddress.fromString

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:16


generate()

static generate(from, nonce): EthjsAddress

Generates an address for a newly created contract.

Parameters

from: EthjsAddress

The address which is creating this new address

nonce: bigint

The nonce of the from account

Returns

EthjsAddress

Inherited from

EthjsAddress.generate

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:32


generate2()

static generate2(from, salt, initCode): EthjsAddress

Generates an address for a contract created using CREATE2.

Parameters

from: EthjsAddress

The address which is creating this new address

salt: Uint8Array

A salt

initCode: Uint8Array

The init code of the contract being created

Returns

EthjsAddress

Inherited from

EthjsAddress.generate2

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:39


zero()

static zero(): EthjsAddress

Returns the zero address.

Returns

EthjsAddress

Inherited from

EthjsAddress.zero

Defined in

node_modules/.pnpm/@ethereumjs+util@9.1.0/node_modules/@ethereumjs/util/dist/esm/address.d.ts:11