Skip to content
docs

formatPrivateKey

formatPrivateKey(chain, privateKey, options?): FormattedPrivateKey

Defined in: keys.ts:148

The inverse of parsePrivateKey, in the format each chain’s wallets import:

  • EVM: 0x + 64 hex (MetaMask, Rabby); Tron: 64 hex (TronLink).
  • BTC, Zcash: compressed WIF (K… / L…; testnet c…). Electrum needs a p2wpkh: prefix to land on the same SegWit address.
  • Solana: base58 of the 64-byte secret key (seed ‖ public key), as Phantom exports.
  • NEAR: ed25519: + base58 of the 64-byte secret key (near-cli, MyNearWallet).
  • TON: hex of the 64-byte secret key (seed ‖ public key). TON wallets themselves import only 24-word phrases.

ChainKey

Uint8Array

boolean

FormattedPrivateKey