Skip to main content

Address

Handling and generating Ethereum addresses

Index

Constructors

publicconstructor

  • Parameters

    • buf: Buffer

    Returns Address

Properties

publicreadonlybuf

buf: Buffer

Methods

publicequals

  • Is address equal to another.


    Parameters

    Returns boolean

publicisPrecompileOrSystemAddress

  • isPrecompileOrSystemAddress(): boolean
  • True if address is in the address range defined by EIP-1352


    Returns boolean

publicisZero

  • isZero(): boolean
  • Is address zero.


    Returns boolean

publictoBuffer

  • toBuffer(): Buffer
  • Returns Buffer representation of address.


    Returns Buffer

publictoString

  • toString(): string
  • Returns hex encoding of address.


    Returns string

publicstaticfromPrivateKey

  • fromPrivateKey(privateKey: Buffer): Address
  • Returns an address for a given private key.


    Parameters

    • privateKey: Buffer

      A private key must be 256 bits wide

    Returns Address

publicstaticfromPublicKey

  • fromPublicKey(pubKey: Buffer): Address
  • Returns an address for a given public key.


    Parameters

    • pubKey: Buffer

      The two points of an uncompressed key

    Returns Address

publicstaticfromString

  • Returns an Address object from a hex-encoded string.


    Parameters

    • str: string

      Hex-encoded address

    Returns Address

publicstaticgenerate

  • Generates an address for a newly created contract.


    Parameters

    • from: Address

      The address which is creating this new address

    • nonce: bigint

      The nonce of the from account

    Returns Address

publicstaticgenerate2

  • Generates an address for a contract created using CREATE2.


    Parameters

    • from: Address

      The address which is creating this new address

    • salt: Buffer

      A salt

    • initCode: Buffer

      The init code of the contract being created

    Returns Address

publicstaticzero

  • Returns the zero address.


    Returns Address