Awarizon
DOCS/@awarizon/cli — Code Generation

@awarizon/cli — Code Generation

Generate a fully-typed contract client class and React hooks from any ABI file. Run once — the generated files work without the CLI installed in production.

CLI — GENERATE FROM ABI
$npx @awarizon/cli generate --name MyToken --abi ./abi.json --address 0x... --out ./src/contracts
FLAGS
--name / -nstringREQContract name in PascalCase. "MyToken" → MyTokenClient.
--abi / -apathREQPath to the ABI JSON file (Solidity output or Hardhat artifact).
--addressAddressDeployed contract address. Baked into the generated file.
--out / -opathOutput directory. Defaults to the current working directory.
--langts | js"ts" for TypeScript (default), "js" for JavaScript.
--no-reactflagSkip generating React hooks — output the client class only.

Two files are generated:

MyTokenClient.ts (auto-generated)
import { AwarizonWeb3 } from "@awarizon/web3"

const CONTRACT_ADDRESS = "0xYourDeployedAddress"

export class MyTokenClient {
  private _contract: any

  static async create(awz: AwarizonWeb3): Promise<MyTokenClient> {
    const client = new MyTokenClient()
    client._contract = await awz.contract({ address: CONTRACT_ADDRESS, abi: ABI })
    return client
  }

  // Read methods
  async balanceOf(owner: `0x${string}`): Promise<bigint> { return this._contract.balanceOf(owner) }
  async symbol():   Promise<string> { return this._contract.symbol() }
  async decimals(): Promise<number> { return this._contract.decimals() }

  // Write methods
  async transfer(to: `0x${string}`, amount: bigint): Promise<TransactionResult> {
    return this._contract.transfer(to, amount)
  }
}
useMyToken.ts (React hooks — auto-generated)
import { contract, useRead, useWrite } from "@awarizon/react"

const CONTRACT_ADDRESS = "0xYourDeployedAddress"
const TOKEN = contract(CONTRACT_ADDRESS, MYTOKEN_ABI)

export function useReadBalanceOf(owner: `0x${string}`) {
  return useRead(TOKEN.balanceOf(owner))
}
export function useReadSymbol() {
  return useRead(TOKEN.symbol())
}
export function useWriteTransfer() {
  return useWrite(TOKEN.transfer)
}

// Usage:
// const { data: balance }   = useReadBalanceOf(userAddress)
// const { write: transfer } = useWriteTransfer()
CLI — VERSION INFO
$npx @awarizon/cli info