ERC-8100: Representable Contract State (IXMLRepresentableState)
Representable Contract State – an XML-based canonical view of EVM contract state
This proposal specifies a minimal interface IXMLRepresentableState that lets an EVM contract expose a canonical representation of its state via an XML template with machine-readable bindings to its state and view functions. Off-chain renderers use only eth_call at a specific block to materialize that representation.
Abstract
This ERC introduces IXMLRepresentableState, a standard interface and XML binding schema that allows an EVM smart contract to define a static XML template with machine-readable bindings to its state and view functions. Off-chain renderers use this template to build a canonical XML document representing the contract’s state at a specific block, without incurring any on-chain gas cost.
A contract that claims to implement IXMLRepresentableState MUST be XML-complete: every piece of mutable state that the author considers semantically relevant MUST be represented in the XML via bindings, so that the rendered XML is a complete representation of the contract at a given (chain-id, address, block-number).
Motivation
Smart contracts can efficiently orchestrate and process the life-cycle of a financial (derivative) product to an extent that they finally represent the financial product itself.
At the same time, many applications require a human-readable, machine-parseable representation of that product and its state: valuation oracles need inputs for settlements, smart bonds and other tokenized instruments need legal terms, term sheets or regulatory reports, and on-chain registries, governance modules or vaults benefit from a stable “document view” of their state.
In the traditional off-chain world, such needs are addressed by standards like FpML, the ISDA Common Domain Model, or the ICMA Bond Data Taxonomy. A common pattern is to treat an XML (or similar) document as the definitive source defining the financial product and then generate code to interact with the corresponding data. When a process modifies or updates properties of the product, developers must synchronize the smart contract’s internal state with the off-chain XML representation. Today, each project typically invents its own set of view functions and off-chain conventions, so clients need bespoke code to map contract state into XML, JSON, or PDF. This makes interoperability, independent auditing, and reuse of tooling harder.
This ERC inverts that pattern by putting the smart contract in the centre. A contract declares that it implements IXMLRepresentableState and defines an interface of representable state. Off-chain renderers can then derive a canonical XML document that reflects the semantically relevant state of the contract at a given (chain-id, address, block-number), using only eth_call and a standardized XML binding schema. Rendering happens entirely off-chain and does not change state, so there is no gas cost, yet the resulting XML remains cryptographically anchored to the chain.
Typical use cases include:
- Smart derivative contracts that must present their current state to a valuation oracle or settlement engine.
- Smart bonds and other tokenized financial instruments that must generate legal terms, term sheets, or regulatory and supervisory reports.
- On-chain registries, governance modules, and vaults that want a reproducible, auditable document-style snapshot of their state.
By standardizing the Solidity interface and the XML attribute schema, this ERC allows generic tools to consume any compliant contract without project-specific adapters, and to plug directly into existing XML-based workflows in finance and beyond.
Specification sketch (informal)
Very briefly, beyond the header/abstract/motivation above, the ERC specifies:
- A minimal interface
IXMLRepresentableStatewithstateXmlTemplate()returning a UTF-8 XML document. - Optional extensions:
IRepresentableStateVersionedwithstateVersion()(monotonically increasing version of the representable state).IRepresentableStateHashedwithstateHash()(hash of a canonical state tuple for the representation).- Convenience combinations for XML:
IXMLRepresentableStateVersioned,IXMLRepresentableStateHashed,IXMLRepresentableStateVersionedHashed.
- An optional interface
IXMLRepresentableStatePartwith
statePartXmlTemplate(uint256 partId):partIdselects a partial / projected view of the state (e.g. “settlement context”, “risk summary”).- Partial views are not required to be XML-complete; they’re just reusable slices of the canonical state.
- A binding schema in the
evmstatenamespace, with attributes like:- single-binding attributes (no semicolons, exactly one binding):
evmstate:call/evmstate:selector/evmstate:returnsevmstate:format/evmstate:scaleevmstate:target(element text vs. attribute target)
- multi-binding attributes (semicolon-separated lists, interpreted positionally):
evmstate:calls/evmstate:selectors/evmstate:returnsListevmstate:formats/evmstate:scales/evmstate:targets
- an array binding profile that lets a single array-valued binding drive a repeated list of child elements:
- If a binding returns
T[]ortuple(T0,...,Tn-1)[], the container element can be marked as an array container viaevmstate:item-element="RowName". - The first direct child
<RowName>acts as a template row and is deep-cloned once per array item. - Inside the row, descendants can use
evmstate:item-field="k"(0-based index into the tuple / scalar wrapped as(v0)) to bind individual fields to element text or attributes, using the existing scalarformat/scalerules. - More complex shapes (inline lists, aggregates, summaries) are expected to be produced by XSLT or similar post-processing from this repeated-row representation.
- If a binding returns
- single-binding attributes (no semicolons, exactly one binding):
Very roughly, a renderer:
- fetches
stateXmlTemplate()at a fixed block tagB, - walks the XML, resolves each
evmstate:*binding viaeth_callatblockTag = B, - writes values into element text or attributes (single- or multi-binding mode),
- applies the array profile where present by expanding array containers into repeated rows,
- and fills the context attributes (
evmstate:chain-id,evmstate:contract-address,evmstate:block-number).
Snapshot consistency is guaranteed by always using the same block B for all calls.
A renderer that does not support the array profile can simply treat evmstate:item-element / evmstate:item-field and array-typed outputs as errors; it still fully implements the core scalar profile of the ERC.
Reference implementation / demos
We have a small set of demo contracts and a Java-based reference renderer (Web3j + DOM XML), including:
MinimalInstrument– owner, notional, currency, maturity, active flag.TestContract– exercises many type/format combinations (uint/int, hex, decimal+scale, iso8601 date/datetime, bytes as hex/base64, etc.) including a multi-binding and array-binding example.InterestRateSwapSettleToMarket– IRS with settle-to-market semantics andlastSettlement{time,value}.BondDataTaxonomyDemo– ICMA BDT-inspired bond (issuer, ISIN, coupon, dates, etc.) rendered via evmstate bindings.
(work done in personal capacity; does not represent an official position of any employer or institution).
Architecture Overview
The following diagram gives an overview of a potential architecture using this ERC.
Repository: finmath.net / representable-contract-state · GitLab
Project Homepage: finmath Representable Contract State

