Skip to content

usePublicKey

Returns the public key to use for passing along to the EVM network.

For P2TR addresses, returns the hex-encoded x-only public key (after removing the first two bytes from the output). For P2WPKH and P2SH(P2WPKH), returns the hex-encoded x-coordinate of the public key.

Import

ts
import { usePublicKey } from "@midl/executor-react";

Example

ts
const publicKeyHex = usePublicKey({ from: 'bcrtq...' });

Parameters

NameTypeDescription
fromstring (optional)The BTC address of the account to get the public key from.
configConfig (optional)Custom configuration to override the default.

Returns

NameTypeDescription
publicKeystring | nullThe public key as a hex string, or null if not available.