{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "send",
  "title": "Send",
  "description": "Send block for ETH and ERC-20s: AddressInput (address or ENS) + TokenInput (token, amount, balance, Max) + TransactionButton + TransactionStatus. The button names the next missing thing (Enter a recipient / Enter an amount / Insufficient <symbol> balance) before 'Send <symbol>'. Native currency is sent as value, ERC-20s via transfer(). Exports the sendBlocker and sendRequest helpers.",
  "dependencies": [
    "viem"
  ],
  "registryDependencies": [
    "@0xui/address-input",
    "@0xui/token-input",
    "@0xui/token-select",
    "@0xui/transaction-button",
    "@0xui/transaction-status"
  ],
  "files": [
    {
      "path": "registry/default/components/send.tsx",
      "content": "// Docs: https://0xui.io/blocks/send.md\nimport { useState, type ReactNode } from \"react\";\nimport { erc20Abi, type Address, type Hash, type TransactionReceipt } from \"viem\";\nimport { AddressInput, type AddressInputState } from \"@/components/address-input\";\nimport { TokenInput, type TokenInputState } from \"@/components/token-input\";\nimport { isNativeToken, type Token, type TokenPrices } from \"@/components/token-select\";\nimport { TransactionButton } from \"@/components/transaction-button\";\nimport { TransactionStatus } from \"@/components/transaction-status\";\nimport { cn } from \"@/lib/utils\";\n\nexport type SendDraft = {\n  recipient: Address | undefined;\n  token: Token;\n  amount: bigint | undefined;\n};\n\n/**\n * Why the draft can't be sent yet, as button text, or undefined when it's\n * ready. Order matches how people fill in the form.\n */\nexport function sendBlocker(\n  draft: SendDraft,\n  { recipientPhase, insufficient }: { recipientPhase: AddressInputState[\"phase\"]; insufficient: boolean }\n) {\n  if (recipientPhase === \"empty\") return \"Enter a recipient\";\n  if (recipientPhase === \"resolving\") return \"Looking up name…\";\n  if (!draft.recipient) return \"Enter a valid recipient\";\n  if (!draft.amount) return \"Enter an amount\";\n  if (insufficient) return `Insufficient ${draft.token.symbol} balance`;\n  return undefined;\n}\n\n/** The transaction for a draft: a value transfer for the native currency, `transfer` for ERC-20s. */\nexport function sendRequest(draft: Required<Pick<SendDraft, \"recipient\" | \"amount\">> & { token: Token }) {\n  return isNativeToken(draft.token)\n    ? { transaction: { to: draft.recipient, value: draft.amount } }\n    : {\n        contract: {\n          address: draft.token.address,\n          abi: erc20Abi,\n          functionName: \"transfer\" as const,\n          args: [draft.recipient, draft.amount] as const,\n        },\n      };\n}\n\nexport type SendProps = {\n  /** Tokens the user can send. Pass one to lock the token. */\n  tokens: readonly Token[];\n  /** Initially selected token. Defaults to the first in `tokens`. */\n  defaultToken?: Token;\n  /** Symbols or addresses for quick picks. */\n  popular?: readonly string[];\n  /** Prices keyed by `chainId:address`, address or symbol, for the fiat line. */\n  prices?: TokenPrices;\n  /** Called once the wallet returns a hash. */\n  onSubmitted?: (hash: Hash) => void;\n  onSuccess?: (receipt: TransactionReceipt) => void;\n  /** Heading. Pass null to hide. */\n  title?: ReactNode;\n  className?: string;\n};\n\n/**\n * Send form: recipient (address or ENS), token and amount with balance,\n * and a send button that names whatever is missing. Shows the\n * transaction's status once sent.\n */\nexport function Send({\n  tokens,\n  defaultToken,\n  popular,\n  prices,\n  onSubmitted,\n  onSuccess,\n  title = \"Send\",\n  className,\n}: SendProps) {\n  const [recipientText, setRecipientText] = useState(\"\");\n  const [recipient, setRecipient] = useState<AddressInputState>();\n  const [token, setToken] = useState<Token>(defaultToken ?? tokens[0]!);\n  const [amountText, setAmountText] = useState(\"\");\n  const [amount, setAmount] = useState<TokenInputState>();\n  const [hash, setHash] = useState<Hash>();\n\n  const draft: SendDraft = {\n    recipient: recipient?.address,\n    token,\n    amount: amount?.amount,\n  };\n  const blocker = sendBlocker(draft, {\n    recipientPhase: recipient?.phase ?? \"empty\",\n    insufficient: amount?.insufficient ?? false,\n  });\n  const request =\n    !blocker && draft.recipient && draft.amount\n      ? sendRequest({ recipient: draft.recipient, amount: draft.amount, token })\n      : undefined;\n\n  return (\n    <div data-slot=\"send\" className={cn(\"flex w-full max-w-md flex-col gap-3\", className)}>\n      {title && <h3 className=\"text-lg font-semibold\">{title}</h3>}\n      <AddressInput\n        value={recipientText}\n        onValueChange={setRecipientText}\n        onResolve={setRecipient}\n        label=\"Recipient\"\n      />\n      <TokenInput\n        label=\"Amount\"\n        value={amountText}\n        onValueChange={(next, state) => {\n          setAmountText(next);\n          setAmount(state);\n        }}\n        token={token}\n        onTokenChange={(next) => {\n          setToken(next);\n          setAmount(undefined);\n          setAmountText(\"\");\n        }}\n        tokens={tokens.length > 1 ? tokens : undefined}\n        popular={popular}\n        prices={prices}\n      />\n      <TransactionButton\n        {...request}\n        chainId={token.chainId}\n        disabledReason={blocker}\n        onSubmitted={(h) => {\n          setHash(h);\n          onSubmitted?.(h);\n        }}\n        onSuccess={onSuccess}\n        hideStatus\n        className=\"w-full [&>button]:h-11 [&>button]:w-full\"\n      >\n        Send {token.symbol}\n      </TransactionButton>\n      {hash && (\n        <TransactionStatus hash={hash} chainId={token.chainId}>\n          Send {amountText} {token.symbol}\n          {recipient?.ensName ? ` to ${recipient.ensName}` : \"\"}\n        </TransactionStatus>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Docs: https://0xui.io/blocks/send.md",
  "categories": [
    "blocks"
  ],
  "type": "registry:block"
}