Skip to content

Components

Contract Form

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

Point it at a contract and an ABI and get a card per function: typed inputs, Read for view functions, and a Transaction Button 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.

readname()→ string
readbalanceOf(address)→ uint256
readallowance(address, address)→ uint256
writetransfer(address, uint256)→ bool

writeapprove(address, uint256)→ bool

Terminal window
npx shadcn@latest add @0xui/contract-form
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.

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).