Skip to content

useExportWallet

Hook for exporting the wallet seed phrase

Import

import { useExportWallet } from '@zerodev/wallet-react'

Usage

import { useExportWallet } from '@zerodev/wallet-react'
 
function ExportSeedPhrase() {
  const exportWallet = useExportWallet()
 
  return (
    <div>
      <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...' : 'Export Seed Phrase'}
      </button>
    </div>
  )
}

Parameters

iframeContainerId

string

Required. The id of the DOM element where the secure export iframe will be rendered. The seed phrase is displayed inside this iframe.

iframeStyles

Record<string, string> | undefined

Optional CSS styles to apply to the export iframe element. Accepts a dictionary of CSS property names to values.

connector

Connector | undefined

The Wagmi connector to export the wallet for. If omitted, uses the currently active connector.

Return Types

TanStack Query mutation docs

mutate

(variables: { iframeContainerId: string; iframeStyles?: Record<string, string>; connector?: Connector }) => void

The mutation function to initiate the wallet export. Renders a secure iframe containing the seed phrase in the specified container.

mutateAsync

(variables: { iframeContainerId: string; iframeStyles?: Record<string, string>; connector?: Connector }) => Promise<void>

Similar to mutate but returns a promise. Resolves when the export iframe is rendered.

data

void

This mutation does not return data. The seed phrase is displayed inside the secure iframe.

error

Error | null

The error object for the mutation, if an error was encountered.

isError / isIdle / isPending / isSuccess

boolean

Boolean variables derived from status.

isPaused

boolean

  • will be true if the mutation has been paused.
  • see Network Mode for more information.

status

'idle' | 'pending' | 'error' | 'success'

  • 'idle' initial status prior to the mutation function executing.
  • 'pending' if the mutation is currently executing.
  • 'error' if the last mutation attempt resulted in an error.
  • 'success' if the last mutation attempt was successful.

reset

() => void

A function to clean the mutation internal state (e.g. it resets the mutation to its initial state).