Display-rule engine for ERC-7730 descriptors.
Applies a single field's format rule to the value resolved at its path,
producing a %{label, value, formatted_value, raw} map:
raw— the canonical decoded value (address as a 20-byte binary, numbers as integers, booleans, byte strings).value— a JSON-friendly normalization ofraw(address as an EIP-55 checksummed hex string, bytes as0x-hex; numbers/booleans/strings as-is).formatted_value— the human-readable string per the field's format rule.
Path resolution
| Prefix | Root |
|---|---|
#.name (or bare name) | decoded message / calldata params |
@.to / @.value / @.from | transaction envelope |
$.a.b.c | the descriptor document (constants, metadata, enums) |
Supported formats (first pass)
raw, amount (native currency), tokenAmount, addressName, date,
duration, unit, enum. calldata (embedded calls) and nftName (needs an
on-chain name lookup) are deferred and fall back to raw rendering.
Token metadata resolution
tokenAmount needs a token's decimals/symbol. Resolution order:
opts[:tokens]— caller map%{lowercase_hex => %{decimals:, symbol:}}.metadata.tokenin the descriptor (for single-token EIP-712 descriptors).opts[:rpc_url]— liveOnchain.ERC20.decimals/2+symbol/2lookup.- Otherwise the raw integer is shown unscaled.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
format_field | 4 | Apply a descriptor field's format rule to its resolved value. | field: value, resolution: value, descriptor: value, opts: value |
Summary
Functions
Apply a descriptor field's format rule to its resolved value.
Types
Functions
@spec format_field( Onchain.ERC7730.Descriptor.field(), map(), Onchain.ERC7730.Descriptor.t(), keyword() ) :: {:ok, result()} | {:error, {atom(), term()}}
Apply a descriptor field's format rule to its resolved value.
Parameters
field- A parsed display field (see Onchain.ERC7730.Descriptor) (value)resolution- Binding resolution (%{message, types, envelope}) from Onchain.ERC7730.Binding (value)descriptor- Parsed %Onchain.ERC7730.Descriptor{} (for $. paths) (value)opts- Resolution opts: :tokens, :rpc_url, :native_symbol, :native_decimals, :names (default:[], value)
Returns
Rendered field, or {:error, {:unresolved_path, path}} for a missing visible field ({:ok, %{label, value, formatted_value, raw}} | {:error, {tag, reason}})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Resolution opts: :tokens, :rpc_url, :native_symbol, :native_decimals, :names",
kind: :value
},
field: %{
description: "A parsed display field (see Onchain.ERC7730.Descriptor)",
kind: :value
},
descriptor: %{
description: "Parsed %Onchain.ERC7730.Descriptor{} (for $. paths)",
kind: :value
},
resolution: %{
description: "Binding resolution (%{message, types, envelope}) from Onchain.ERC7730.Binding",
kind: :value
}
},
returns: %{
type: "{:ok, %{label, value, formatted_value, raw}} | {:error, {tag, reason}}",
description: "Rendered field, or {:error, {:unresolved_path, path}} for a missing visible field"
}
}