Relaycode

Account Input

Address input with wallet integration and SS58 validation

import { Account } from "@/components/params/inputs/account";

<Account
  name="dest"
  label="Destination"
  description="The recipient account"
  client={client}
  typeId={0}
  isRequired
  onChange={(address) => console.log("Selected:", address)}
/>

Account Input

The Account input provides a Substrate address field with connected wallet integration, recent address history, and SS58 format validation. It is used whenever a parameter expects an on-chain account identifier -- transfers, proxies, identity lookups, and any call that targets a specific address.

Supported Type Names

The Account component matches the following type names at priority 100 (highest in the registry):

  • AccountId
  • AccountId32
  • AccountId20
  • MultiAddress
  • Address
  • LookupSource
  • Any type name matching /^AccountId/ or /^MultiAddress/

Props

The component accepts the standard ParamInputProps interface:

PropTypeRequiredDescription
namestringYesField identifier used for the HTML id and form state
labelstringNoDisplay label shown above the input
descriptionstringNoHelp text shown below the input
typeNamestringNoThe SCALE type name (e.g. "AccountId32")
isDisabledbooleanNoDisables the input when true
isRequiredbooleanNoShows a red asterisk next to the label
errorstringNoValidation error message to display
clientDedotClient<PolkadotApi>YesConnected Dedot client for chain metadata and SS58 prefix
typeIdnumberNoMetadata type ID for this parameter
valueanyNoExternally controlled value (e.g. from hex decode)
onChange(value: unknown) => voidNoCallback fired with the formatted SS58 address

Features

  • Connected wallet accounts: Displays accounts from the connected wallet (via LunoKit) in a dropdown combobox, letting users pick from their own addresses.
  • Recent address history: Tracks previously entered addresses in local storage and surfaces them as suggestions for quick reuse.
  • SS58 validation: Uses Dedot's decodeAddress to validate any entered address. Invalid addresses are rejected at the schema level.
  • Chain-aware formatting: Automatically re-encodes addresses to the connected chain's SS58 prefix, so a Polkadot-formatted address pasted into a Kusama context is converted correctly.
  • Combobox interface: Combines a searchable text input with a dropdown, supporting both paste-in addresses and selection from the list.

Type Resolution

import { findComponent } from "@/lib/input-map";

// All of these resolve to the Account component
findComponent("AccountId32", typeId, client);
findComponent("MultiAddress", typeId, client);
findComponent("Address", typeId, client);
findComponent("LookupSource", typeId, client);

Usage

The Account component is typically rendered by the extrinsic builder after findComponent resolves the parameter type. Direct usage:

import { Account } from "@/components/params/inputs/account";

<Account
  name="dest"
  label="Destination"
  description="The recipient account"
  client={client}
  typeId={0}
  isRequired
  onChange={(address) => console.log("Selected:", address)}
/>

Validation

The component uses a Zod schema that calls decodeAddress from dedot/utils. Any string that fails SS58 decoding is rejected:

const schema = z.string().refine(
  (value) => {
    try {
      decodeAddress(value);
      return true;
    } catch {
      return false;
    }
  },
  { message: "Invalid Substrate address" }
);

Value Format

The onChange callback receives a string -- the SS58-encoded address formatted to the connected chain's prefix. If the input is cleared, undefined is emitted.