Skip to content

createAddress

createAddress(address): Address

Creates an Address for safely interacting with an Ethereum address. Wraps EthjsAddress with a tevm style API.

Parameters

address: string | number | bigint | EthjsAddress | Uint8Array

The input to create an address from.

Returns

Address

An Address instance.

Throws

If the input is not a valid address.

Example

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

Defined in

packages/address/src/createAddress.js:26