Skip to main content

Overview

The CDP Server Wallet offers a secure method for creating EVM and Solana Accounts from imported private keys. The import flow is end-to-end encrypted between the CDP SDK and the TEE, ensuring that keys are never exposed outside of the secure enclave during the request. Encrypted by the SDK in a way that only the TEE can decrypt the keys, this process enables seamless and secure import of your keys.

EVM Accounts: Import from external wallet providers

You can import private keys from other wallet providers by exporting them as raw, hex-encoded 32-byte strings. To complete the import, use importAccount in TypeScript or import_account in the Python CDP SDK. Only private key import is supported. To import an HD Wallet, derive individual private keys from the seed and import them one by one.
    import { CdpClient } from "@coinbase/cdp-sdk";
    import dotenv from "dotenv";

    dotenv.config();

    const cdp = new CdpClient();
    const account = await cdp.evm.importAccount({
        privateKey: "0x0123456789abcdef...",
        name: "ExternalWalletImportedAccount",
    });
    console.log("Imported account: ", account.address);

Solana Accounts: Import from external wallet providers

Here’s an example of how to import a Solana account with a base58-encoded private key from a wallet provider like Phantom.
    import { CdpClient } from "@coinbase/cdp-sdk";
    import dotenv from "dotenv";

    dotenv.config();

    const cdp = new CdpClient();
    const account = await cdp.solana.importAccount({
        privateKey: "4YFq9y5f5hi77Bq8kDCE6VgqoAq...",
        name: "ExternalWalletImportedAccount",
    });
    console.log("Imported account: ", account.address);
You can also import a Solana account using the raw 32-byte private key array.
    import { CdpClient } from "@coinbase/cdp-sdk";
    import dotenv from "dotenv";

    dotenv.config();

    const keypair = Keypair.generate();
    const privateKeyBytes32 = keypair.secretKey.subarray(0, 32);

    const account = await cdp.solana.importAccount({
        privateKey: privateKeyBytes32,
        name: "BytesAccount32",
    });
    console.log("Imported account: ", account.address);

Video: Watch and learn

Watch this video for a walkthrough of importing keys: