Skip to main content

Try it Live

Run ABI examples in the interactive playground

Overview

Abi.formatWithArgs renders a human-readable call string by inserting concrete argument values.

Quick Start

import { Abi } from '@tevm/voltaire/Abi';

const transfer = {
  type: 'function',
  name: 'transfer',
  inputs: [
    { type: 'address', name: 'to' },
    { type: 'uint256', name: 'amount' }
  ],
  outputs: [{ type: 'bool' }]
} as const;

const formatted = Abi.formatWithArgs(transfer, [
  '0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e',
  1000n
]);
// "transfer(0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e, 1000)"

Format Multiple Items

If you have a full ABI, you can format all items with an argument map keyed by name:
const abi = Abi([transfer] as const);

const formatted = abi.formatWithArgs({
  transfer: [
    '0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e',
    1000n
  ]
});

See Also