Client: wallets
Import a private key
Import a hex private key by family; EVM covers all EVM chains on the allowlist.
Overview
Imports a single private key as kind: "private_key". For family: "evm" omit chainId—the wallet covers all EVM chains on the allowlist. Other families require chainId. Monero imports the spend key only (view is derived); not multi-chain.
Signature
js
await client.wallets.importPrivateKey(options)Parameters
ImportPrivateKeyOptions
| Field | Required | Description |
|---|---|---|
| privateKey | Yes | `"0x"` + 64 hex (32 bytes). Monero: 32-byte spend secret. |
| family | Yes | `"evm" | "solana" | "tron" | "utxo" | "monero" | …` |
| chainId | No | `GrayChainId` — **required** when `family !== "evm"`. Ignored for EVM. |
| label | No | `string` — UI name. |
| password | No | `string` — keystore PIN when storage is encrypted. |
Response
Promise<Wallet> — kind: "private_key"
ts
{
id: string;
label: string;
kind: "private_key";
enabledChains: GrayChainId[]; // EVM → all enabled EVM; else single chain
// …
}Usage
js
await client.wallets.importPrivateKey({
privateKey: "0x…",
family: "evm",
password: pin,
});
await client.wallets.importPrivateKey({
privateKey: "0x…",
family: "solana",
chainId: "solana",
password: pin,
});
await client.wallets.importPrivateKey({
privateKey: "0x…",
family: "utxo",
chainId: "bitcoin",
password: pin,
});
await client.wallets.importPrivateKey({
privateKey: "0x…", // spend secret
family: "monero",
chainId: "monero",
password: pin,
});
// Help the user pick a family:
const { candidates } = detectPrivateKey(pk);
const pick = candidates.find((c) => c.family === "monero") ?? candidates[0];
await client.wallets.importPrivateKey({
privateKey: pk,
family: pick.family,
...(pick.family !== "evm" ? { chainId: pick.chainIds[0] } : {}),
password: pin,
});Throws
| Field | Required | Description |
|---|---|---|
| conflict | No | Derived address already exists on overlapping chains (any wallet kind). Message includes id, label, chains. |
| invalid_argument | No | Bad key length/format, missing chainId for non-EVM, or unknown family. |
| unauthorized | No | Encrypted storage — bad or missing PIN. |