# Importing a wallet from a private key

Use the `import` action on `useEthereumEmbeddedWallet` (Ethereum) or `useSolanaEmbeddedWallet` (Solana) to register an existing private key as a new embedded wallet. The key is split with Shamir secret sharing and the shares are persisted to Shield and your account exactly like a freshly created wallet — only the key generation step is skipped.

:::info\[Key format]

* **Ethereum (EVM)** — hex-encoded private key (`0x` prefix optional).
* **Solana (SVM)** — base58-encoded 64-byte secret key (the same string returned by `exportPrivateKey()` for a Solana wallet).
  :::

:::warning\[Handle private keys with care]
Treat the imported `privateKey` as a high-value secret. Read it from a trusted user-controlled input, avoid logging it, and never persist it in plaintext after import — once imported, all subsequent signing happens through Openfort's MPC flow.
:::

:::code-group

```tsx [Ethereum]
import { useEthereumEmbeddedWallet } from "@openfort/react/ethereum"
import { RecoveryMethod } from "@openfort/react"

function ImportWallet() {
  const { import: importWallet, isLoading } = useEthereumEmbeddedWallet()

  const handleImport = async (privateKey: string) => {
    const wallet = await importWallet({
      privateKey,
      recoveryMethod: RecoveryMethod.AUTOMATIC,
    })
    console.log("Ethereum wallet imported:", wallet.address)
  }

  return (
    <form
      onSubmit={(e) => {
        e.preventDefault()
        handleImport((e.target as HTMLFormElement).privateKey.value)
      }}
    >
      <input name="privateKey" type="password" placeholder="0x..." />
      <button type="submit" disabled={isLoading}>
        Import wallet
      </button>
    </form>
  )
}
```

```tsx [Solana]
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"
import { RecoveryMethod } from "@openfort/react"

function ImportWallet() {
  const { import: importWallet, isLoading } = useSolanaEmbeddedWallet()

  const handleImport = async (privateKey: string) => {
    const wallet = await importWallet({
      privateKey,
      recoveryMethod: RecoveryMethod.AUTOMATIC,
    })
    console.log("Solana wallet imported:", wallet.address)
  }

  return (
    <form
      onSubmit={(e) => {
        e.preventDefault()
        handleImport((e.target as HTMLFormElement).privateKey.value)
      }}
    >
      <input name="privateKey" type="password" placeholder="base58 secret key" />
      <button type="submit" disabled={isLoading}>
        Import wallet
      </button>
    </form>
  )
}
```

:::

`import` returns the same `EmbeddedAccount` as `create`, sets the imported wallet as the active wallet, and refreshes the wallet list — so it slots into the existing `useEthereumEmbeddedWallet` / `useSolanaEmbeddedWallet` state machine just like `create()`.

## Options

`import` accepts every option from `CreateEmbeddedWalletOptions` plus the `privateKey` to import:

```ts
import({
  privateKey: string,                  // hex (EVM) or base58 (SVM)
  recoveryMethod?: RecoveryMethod,     // 'automatic' | 'password' | 'passkey'
  password?: string,                   // required when recoveryMethod === 'password'
  passkeyId?: string,                  // optional for 'passkey'
  otpCode?: string,                    // optional for 'automatic' with OTP
  accountType?: AccountTypeEnum,       // EVM only; defaults to Smart Account
  chainId?: number,                    // EVM only
})
```

## Recovery method

Importing a wallet stores a recovery share for it, exactly like creating one. Pick a recovery method up-front — it controls how the key is encrypted at rest. See the [recovery methods guide](/docs/configuration/recovery-methods) for help choosing.

### Automatic recovery

Requires an encryption session from your backend. Configure `createEncryptedSessionEndpoint` or `getEncryptionSession` in `walletConfig` (see the [Automatic Recovery session](/docs/products/embedded-wallet/server/automatic-recovery-session) guide), then pass `RecoveryMethod.AUTOMATIC`:

:::code-group

```tsx [Ethereum]
import { useEthereumEmbeddedWallet } from "@openfort/react/ethereum"
import { RecoveryMethod } from "@openfort/react"

function ImportWallet({ privateKey }: { privateKey: string }) {
  const { import: importWallet, isLoading } = useEthereumEmbeddedWallet()

  const handleImport = async () => {
    const wallet = await importWallet({
      privateKey,
      recoveryMethod: RecoveryMethod.AUTOMATIC,
    })
    console.log("Wallet imported:", wallet.address)
  }

  return <button onClick={handleImport} disabled={isLoading}>Import wallet</button>
}
```

```tsx [Solana]
import { useSolanaEmbeddedWallet } from "@openfort/react/solana"
import { RecoveryMethod } from "@openfort/react"

function ImportWallet({ privateKey }: { privateKey: string }) {
  const { import: importWallet, isLoading } = useSolanaEmbeddedWallet()

  const handleImport = async () => {
    const wallet = await importWallet({
      privateKey,
      recoveryMethod: RecoveryMethod.AUTOMATIC,
    })
    console.log("Wallet imported:", wallet.address)
  }

  return <button onClick={handleImport} disabled={isLoading}>Import wallet</button>
}
```

:::

### Password recovery

The user supplies a password that encrypts the recovery share. No backend is required:

:::code-group

```tsx [Ethereum]
import { useEthereumEmbeddedWallet } from "@openfort/react/ethereum"
import { RecoveryMethod } from "@openfort/react"

function ImportWallet() {
  {/* Same with useSolanaEmbeddedWallet from @openfort/react/solana */}
  const { import: importWallet, isLoading } = useEthereumEmbeddedWallet()

  const handleImport = async (privateKey: string, password: string) => {
    const wallet = await importWallet({
      privateKey,
      recoveryMethod: RecoveryMethod.PASSWORD,
      password,
    })
    console.log("Wallet imported:", wallet.address)
  }

  return (
    <form
      onSubmit={(e) => {
        e.preventDefault()
        const form = e.target as HTMLFormElement
        handleImport(form.privateKey.value, form.password.value)
      }}
    >
      <input name="privateKey" type="password" placeholder="Private key" />
      <input name="password" type="password" placeholder="Recovery password" />
      <button type="submit" disabled={isLoading}>Import wallet</button>
    </form>
  )
}
```

:::

### Passkey recovery

Pass `RecoveryMethod.PASSKEY` to bind the recovery share to a WebAuthn credential. The browser prompts the user to create a passkey (Face ID, Touch ID, fingerprint).

:::warning\[Domain-bound credentials]
WebAuthn credentials are bound to a specific domain. A passkey created for `example.com` cannot be used on a different domain. For multi-domain products, prefer automatic recovery.
:::

:::code-group

```tsx [Ethereum]
import { useEthereumEmbeddedWallet } from "@openfort/react/ethereum"
import { RecoveryMethod } from "@openfort/react"

function ImportWallet({ privateKey }: { privateKey: string }) {
  {/* Same with useSolanaEmbeddedWallet from @openfort/react/solana */}
  const { import: importWallet, isLoading } = useEthereumEmbeddedWallet()

  const handleImport = async () => {
    const wallet = await importWallet({
      privateKey,
      recoveryMethod: RecoveryMethod.PASSKEY,
    })
    console.log("Wallet imported:", wallet.address)
  }

  return (
    <button onClick={handleImport} disabled={isLoading}>
      Import wallet with passkey
    </button>
  )
}
```

:::
