ERC-8100 · Draft · ERC · 2025-12-01
ERC-8100: Representable Contract State
Lets a contract publish an XML template whose attributes bind to its view functions, so off-chain renderers can produce a canonical, block-pinned XML document of the contract's state, aimed at financial instruments and reporting.
What problem does it solve?
Smart contracts can manage the whole lifecycle of a financial product, such as a derivative or a bond, to the point where the contract effectively is the product. But the surrounding world still needs a document describing it: valuation oracles need inputs for settlement, tokenized bonds need term sheets and regulatory reports, and auditors want reproducible snapshots.
Traditional finance handles this with XML-based standards such as FpML, where the XML document is the source of truth. ERC-8100 flips that around: the contract is the source of truth, and it exposes a standard way for generic tools to render its current state as XML, without project-specific adapters.
How it works
- The interface. A contract implements
IXMLRepresentableState.stateXmlTemplate(), which returns an effectively constant XML string. - Bindings. Elements in the template carry attributes in the
urn:evm:state:1.0namespace (prefixevmstate).evmstate:call="notional()(uint256)"tells the renderer which view function to call and how to decode the result.evmstate:formatandevmstate:scalecontrol formatting (scale 2 turns100000000into1000000.00), andevmstate:targetwrites into an attribute instead of the element text. Several bindings per element are allowed via semicolon-separated lists, and an optional array profile expands arrays (for example a payment schedule) into repeated rows. - Consistent snapshots. Renderers must pick a single block
Bup front and run everyeth_callat that block, so the document reflects one consistent state. The root element getsevmstate:chain-id(the EIP-155 chain ID),evmstate:contract-addressandevmstate:block-number. - XML-complete. A contract is XML-complete if its rendering covers all semantically relevant mutable state. This is a promise by the author, not something enforced on-chain.
- Optional extras.
stateVersion()for cheap change detection and caching,stateHash()for integrity checks, andstatePartXmlTemplate(partId)for partial views (for example a settlement context). Events can refer to such views by URI, e.g.evmstate://self/part/{partId}, instead of logging large data blobs.
Sample code
A template fragment and what a renderer produces from it:
<!-- returned by stateXmlTemplate() -->
<Swap xmlns="urn:example:instrument"
xmlns:evmstate="urn:evm:state:1.0"
evmstate:chain-id="" evmstate:contract-address="" evmstate:block-number="">
<Notional evmstate:call="notional()(uint256)" evmstate:format="decimal" evmstate:scale="2"/>
<Party evmstate:call="partyALEI()(string)" evmstate:target="id"/>
</Swap>
<!-- rendered at a fixed block (evmstate:* binding attributes may be stripped) -->
<Swap xmlns="urn:example:instrument" xmlns:evmstate="urn:evm:state:1.0"
evmstate:chain-id="1337" evmstate:contract-address="0x..." evmstate:block-number="37356">
<Notional>1000000.00</Notional>
<Party id="LEI-of-Party-A"/>
</Swap>
Solidity side:
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.19;
interface IXMLRepresentableState {
function stateXmlTemplate() external view returns (string memory);
}
Things to know
- Status: Draft. The binding schema and profiles may still change.
- Bind only to deterministic views. Functions that read
block.timestampor call other contracts can make the rendering unstable. - A contract can claim XML-completeness while leaving things out. Review the code, and where provided use
stateHash()to check that a rendering matches on-chain state. - Correctness ultimately depends on the off-chain renderer; independent implementations and tests are recommended.
- Large templates mean many
eth_calls, which can be slow or rate-limited on public RPCs. - Can be implemented alongside ERC-20, ERC-721, ERC-1155 or any other standard.