fromLegacyKeypair

function fromLegacyKeypair(
    keypair,
    extractable?,
): Promise<CryptoKeyPair>;

Converts a legacy Keypair object to a native Ed25519 CryptoKeyPair object.

Parameters

ParameterType
keypairKeypair
extractable?boolean

Returns

Promise<CryptoKeyPair>

Example

import { fromLegacyKeypair } from '@solana/compat';
 
// `Keypair.generate()` is synchronous in web3.js v1 and asynchronous in v3; `await` works with both.
const legacyKeyPair = await Keypair.generate();
const { privateKey, publicKey } = await fromLegacyKeypair(legacyKeyPair);

On this page