Skip to content

Address.fromPublicKey

Converts an ECDSA public key to an Address.Address.

Imports

Named
import { Address } from 'ox'

Examples

import { Address, PublicKey } from 'ox'
 
const publicKey = PublicKey.from(
  '0x048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5',
)
const address = Address.fromPublicKey(publicKey)
'0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'

Definition

function fromPublicKey(
  publicKey: PublicKey.PublicKey,
  options?: fromPublicKey.Options,
): Address

Source: src/Address.ts

Parameters

publicKey

  • Type: PublicKey.PublicKey

The ECDSA public key to convert to an Address.Address.

publicKey.prefix

  • Type: numberType

publicKey.x

  • Type: bigintType

publicKey.y

  • Type: bigintType

options

  • Type: fromPublicKey.Options
  • Optional

Conversion options.

options.checksum

  • Type: boolean
  • Optional

Whether to checksum the address.

Return Type

The Address.Address corresponding to the public key.

Address

Error Type

Address.fromPublicKey.ErrorType