Skip to content

Export Wallet

Let users export their seed phrase or private key

The SDK supports exporting the user's wallet as a seed phrase or private key. The key material is displayed inside a secure iframe and never touches your application code.

Hooks

Example

import { useState } from 'react'
import { useExportWallet, useExportPrivateKey } from '@zerodev/wallet-react'
 
function ExportModal() {
  const [showExport, setShowExport] = useState(false)
  const exportWallet = useExportWallet()
  const exportPrivateKey = useExportPrivateKey()
 
  return (
    <div>
      <button onClick={() => setShowExport(true)}>
        Export Wallet
      </button>
 
      {showExport && (
        <div className="modal">
          <h3>Export Options</h3>
 
          {/* Container where the export iframe will render */}
          <div id="export-container" style={{ minHeight: '200px' }} />
 
          <button
            onClick={() =>
              exportWallet.mutateAsync({
                iframeContainerId: 'export-container',
                iframeStyles: {
                  width: '400px',
                  height: '200px',
                  border: 'none',
                },
              })
            }
            disabled={exportWallet.isPending}
          >
            {exportWallet.isPending ? 'Exporting...' : 'Show Seed Phrase'}
          </button>
 
          <button
            onClick={() =>
              exportPrivateKey.mutateAsync({
                iframeContainerId: 'export-container',
                keyFormat: 'Hexadecimal',
                iframeStyles: {
                  width: '400px',
                  height: '100px',
                  border: 'none',
                },
              })
            }
            disabled={exportPrivateKey.isPending}
          >
            {exportPrivateKey.isPending ? 'Exporting...' : 'Show Private Key'}
          </button>
 
          <button onClick={() => setShowExport(false)}>
            Close
          </button>
        </div>
      )}
    </div>
  )
}

How it works

  1. You provide a container element ID where the secure iframe will be rendered.
  2. The SDK initiates a secure export session.
  3. The seed phrase or private key is rendered inside a secure iframe.
  4. The key material is displayed directly to the user — it never passes through your application.

Iframe styling

Customize the iframe appearance with iframeStyles:

exportWallet.mutateAsync({
  iframeContainerId: 'export-container',
  iframeStyles: {
    width: '100%',
    height: '250px',
    border: '1px solid #ccc',
    borderRadius: '8px',
    padding: '16px',
  },
})

Private key formats

useExportPrivateKey supports two key formats:

FormatDescription
'Hexadecimal'Standard hex-encoded private key (default)
'Solana'Solana-compatible key format