# Contract Form

> Read and write forms for any contract, generated from its ABI.

- Install: `npx shadcn@latest add @0xui/contract-form`
- Registry JSON: https://0xui.io/r/contract-form.json
- Source: https://github.com/fimbul-lab/0xui/blob/main/registry/default/components/contract-form.tsx

Point it at a contract and an ABI and get a card per function: typed inputs, **Read** for view functions, and a [Transaction Button](https://0xui.io/components/transaction-button.md) for writes. Useful for admin panels, debugging, and tools an agent builds on the fly.

The demo is USDC on Ethereum. Reads are real. Writes go through the Demo Wallet and aren't broadcast.

## Installation

```bash
npx shadcn@latest add @0xui/contract-form
```

## Usage

```tsx
import { ContractForm } from "@/components/contract-form";

<ContractForm address={vault} abi={vaultAbi} chainId={8453} />;

// Just some functions, in this order
<ContractForm address={token} abi={erc20Abi} functions={["balanceOf", "transfer"]} />;

// Only reads
<ContractForm address={token} abi={erc20Abi} show="read" />;
```

Render one function with `ContractFunction`.

## Input rules

| Solidity type | Enter | Checks |
| --- | --- | --- |
| `uint*` / `int*` | `1000` or `1_000` | Whole number, within the type's range |
| `address` | `0x…` | Valid, and the checksum must match if mixed-case |
| `bool` | select | — |
| `bytes` / `bytesN` | `0x…` | Hex, exact length for `bytesN` |
| `string` | text | — |
| arrays, tuples | JSON: `["1", "2"]`, `{ "to": "0x…", "amount": "5" }` | Each element by its type |

Payable functions get an ETH value field. The write button names the first field to fix, e.g. "Check amount".

Pure helpers: `parseAbiInput(param, text)` and `formatAbiValue(value)`.
