Skip to main content

Function: toPrivateKeyHex()

function toPrivateKeyHex(privateKey): `0x${string}`;

Defined in: evm-client/src/provider.ts:239

Key material from an OvercastConfig as the 32-byte hex secp256k1 key viem wants. Accepts a 0x-prefixed hex string or a raw byte array.

Bare (un-prefixed) hex is rejected even though it would be unambiguous here, because the same privateKey is read a second time by core's createProtocolSigner — which takes its leading 32 bytes as an ed25519 seed and requires the 0x prefix. Accepting a form that builds a working chain signer but throws when the protocol signer is built would be the worst of the three outcomes.

There is no base58 branch, unlike Solana's loadKeypair: base58 is not an encoding EVM tooling emits, so a base58 string here is far more likely to be a Solana key pasted into the wrong config than an EVM key. Resolving a file path is the caller's job — nothing here touches the filesystem, so the package stays browser-bundlable.

Parameters​

ParameterType
privateKeystring | number[]

Returns​

`0x${string}`