Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeReact

usePrepare

Plans a write without sending it: its steps, calls and warnings, for a review screen before the wallet prompt. Signature, result and examples for usePrepare.

Write hookstable
Since v1.0.0View source

Plans a write without sending it: its steps, calls and warnings, for a review screen before the wallet prompt.

When to use

Use to show what a write will do (how many transactions, approvals, warnings) and to disable the submit button while it cannot be planned, e.g. when the account lacks permission.

Signature

function usePrepare<action extends PreparableAction>(action: action, options: ActionOptions<action["prepare"]> | undefined, config?: ReadConfig): ReadResult<Plan, ActionError<action["prepare"]>>

Examples

Reviewing a records update
import { Actions } from "@ensforge/sdk"
import { usePrepare } from "@ensforge/react"

function Review({ name, url }: { name: string; url: string }) {
  const { data: plan, error } = usePrepare(Actions.record.set, { name, texts: { url } })
  if (error) return <p>{error.message}</p>
  return <p>{plan?.steps.length} transaction(s)</p>
}

See also

  • The hook types: ReadResult, WriteResult and ReadConfig.

Was this page helpful?