Skip to content
Get startedGetting started →

getEvmAddress

Derives the EIP-55 checksummed EVM address for a secp256k1 public key: keccak-256 over the uncompressed key’s coordinates, last 20 bytes, mixed-case checksum.

import {
function getEvmAddress(publicKey: Uint8Array): EvmAddress

Derives the EIP-55 checksummed EVM address for a secp256k1 public key.

@parampublicKey - A compressed or uncompressed secp256k1 public key.

@returnsThe EIP-55 mixed-case checksummed EVM address.

@throwsMeraError with code INPUT_INVALID when publicKey is not valid secp256k1.

getEvmAddress
} from "@category-labs/mera";
import {
function createSecp256k1SigningSession({ privateKey, }: CreateSigningSessionOptions): Secp256k1SigningSession

Creates a signing session from a secp256k1 private key.

@paramoptions - Signing session inputs.

@returnsA live secp256k1 signing session.

@throwsMeraError with code INPUT_INVALID when privateKey is not a valid secp256k1 scalar.

createSecp256k1SigningSession
,
function getEvmAddress(publicKey: Uint8Array): EvmAddress

Derives the EIP-55 checksummed EVM address for a secp256k1 public key.

@parampublicKey - A compressed or uncompressed secp256k1 public key.

@returnsThe EIP-55 mixed-case checksummed EVM address.

@throwsMeraError with code INPUT_INVALID when publicKey is not valid secp256k1.

getEvmAddress
,
} from "@category-labs/mera";
const
const session: Secp256k1SigningSession
session
=
function createSecp256k1SigningSession({ privateKey, }: CreateSigningSessionOptions): Secp256k1SigningSession

Creates a signing session from a secp256k1 private key.

@paramoptions - Signing session inputs.

@returnsA live secp256k1 signing session.

@throwsMeraError with code INPUT_INVALID when privateKey is not a valid secp256k1 scalar.

createSecp256k1SigningSession
({
privateKey: Uint8Array<ArrayBufferLike>

Curve private key. Must be exactly 32 bytes and, for secp256k1, a valid scalar.

privateKey
:
var crypto: Crypto
crypto
.
Crypto.getRandomValues<Uint8Array<ArrayBuffer>>(array: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>

The Crypto.getRandomValues() method lets you get cryptographically strong random values.

MDN Reference

getRandomValues
(new
var Uint8Array: Uint8ArrayConstructor
new (length: number) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array
(32)),
});
const
const address: `0x${string}`
address
=
function getEvmAddress(publicKey: Uint8Array): EvmAddress

Derives the EIP-55 checksummed EVM address for a secp256k1 public key.

@parampublicKey - A compressed or uncompressed secp256k1 public key.

@returnsThe EIP-55 mixed-case checksummed EVM address.

@throwsMeraError with code INPUT_INVALID when publicKey is not valid secp256k1.

getEvmAddress
(
const session: Secp256k1SigningSession
session
.
publicKey: Uint8Array<ArrayBuffer>

65-byte uncompressed secp256k1 public key for the session.

publicKey
);
// EIP-55 checksummed, like "0x8ba1f109551bD432803012645Ac136ddd64DBA72"
  • Type: Uint8Array
  • Required

A secp256k1 public key, compressed (33 bytes) or uncompressed (65 bytes). Normalized internally, so both forms give the same address.

import type {
type EvmAddress = `0x${string}`

A 20-byte EVM address as 0x-prefixed hex.

Structural type only: the 0x${string} shape does not constrain length or hex digits.

EvmAddress
} from "@category-labs/mera";
type
type ReturnType = `0x${string}`
ReturnType
=
type EvmAddress = `0x${string}`

A 20-byte EVM address as 0x-prefixed hex.

Structural type only: the 0x${string} shape does not constrain length or hex digits.

EvmAddress
;

The EIP-55 mixed-case checksummed address as a 0x-prefixed string. EvmAddress is the structural type `0x${string}`.

  • INPUT_INVALID: publicKey is not valid secp256k1 (wrong length, wrong prefix, or not a point on the curve).