Skip to content

Add ERC: Representable Contract State - #1396

Merged
eip-review-bot merged 90 commits into
ethereum:masterfrom
finmath:feature/resentable-contract-state
Jun 2, 2026
Merged

Add ERC: Representable Contract State#1396
eip-review-bot merged 90 commits into
ethereum:masterfrom
finmath:feature/resentable-contract-state

Conversation

@cfries

@cfries cfries commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

This proposal specifies a minimal interface IXMLRepresentableState that lets an EVM contract expose a canonical
representation of its state
via an XML (or JSON) 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.

Note: The corresponding interface IJSONRepresentableState ist part of the ERC, however the binding scheme is currently focussing on XML bindings.

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 IXMLRepresentableState with xmlTemplate() returning a UTF‑8 XML document.
  • Optional extensions:
    • IRepresentableStateVersioned with stateVersion() (monotonically increasing version of the representable state).
    • IRepresentableStateHashed with stateHash() (hash of a canonical state tuple for the representation).
    • Convenience combinations for XML: IXMLRepresentableStateVersioned, IXMLRepresentableStateHashed, IXMLRepresentableStateVersionedHashed.
  • A binding schema in the evmstate namespace, with attributes like:
    • single-binding attributes (no semicolons, exactly one binding):
      • evmstate:call / evmstate:selector / evmstate:returns
      • evmstate:format / evmstate:scale
      • evmstate:target (element text vs. attribute target)
    • multi-binding attributes (semicolon-separated lists, interpreted positionally):
      • evmstate:calls / evmstate:selectors / evmstate:returnsList
      • evmstate:formats / evmstate:scales / evmstate:targets

A renderer:

  • fetches xmlTemplate() at a fixed block tag B,
  • walks the XML, resolves each evmstate:* binding via eth_call at blockTag=B,
  • writes values into element text or attributes (single- or multi-binding mode),
  • 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.


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 example.
  • InterestRateSwapSettleToMarket – IRS with settle-to-market semantics and lastSettlement{time,value}.
  • BondDataTaxonomyDemo – ICMA BDT-inspired bond (issuer, ISIN, coupon, dates, etc.) rendered via evmstate bindings.

Project Homepage: http://finmath.gitlab.io/representable-contract-state

@eip-review-bot

eip-review-bot commented Dec 6, 2025

Copy link
Copy Markdown
Collaborator

✅ All reviewers have approved.

Comment thread ERCS/erc-rcs.md Outdated
Comment thread ERCS/erc-rcs.md Outdated
Comment thread ERCS/erc-rcs.md
cfries and others added 2 commits December 8, 2025 03:26
Co-authored-by: Andrew B Coathup <28278242+abcoathup@users.noreply.github.com>
Co-authored-by: Andrew B Coathup <28278242+abcoathup@users.noreply.github.com>
@github-actions github-actions Bot removed the w-ci label Dec 8, 2025
cfries and others added 2 commits December 8, 2025 03:28
Co-authored-by: Andrew B Coathup <28278242+abcoathup@users.noreply.github.com>
@eip-review-bot eip-review-bot changed the title Add ERC: Representable Contract State Add ERC: XML Representable Contract State Dec 8, 2025
@github-actions github-actions Bot added the w-ci label Dec 8, 2025
@eip-review-bot eip-review-bot changed the title Add ERC: XML Representable Contract State Add ERC: Representable Contract State Dec 8, 2025
@github-actions github-actions Bot added w-ci and removed w-ci labels Dec 8, 2025
@github-actions github-actions Bot removed the w-ci label Dec 8, 2025
@cfries
cfries marked this pull request as ready for review December 8, 2025 06:11
@cfries

cfries commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

Hi @SamWilsn — sorry for the ping. I believe I’ve addressed all of your comments.
The only open question is whether to keep package.json; I left it in for now, as in ERC-7573 and ERC-6123, because it helps with interface versioning while the ERC is in draft.

@cfries

cfries commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi @SamWilsn — just gently following up here.
I believe the review comments have been addressed. Is there anything else needed from my side before this can be merged / moved to Draft? I’d like to reference ERC-8100 from another ERC, so a merge to draft would be very helpful. Thanks!

@SamWilsn SamWilsn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are pretty minor, please fix them at your leisure.

Comment thread ERCS/erc-8100.md

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These may be common abbreviations in a specific domain, but not to general Ethereum developers.

Comment thread ERCS/erc-8100.md
This ERC RECOMMENDS the following minimal scheme for references to partial XML views:

```text
evmstate://self/part/{partId}[?key={application-specific-key}]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small aside, but might be worth reserving this scheme if it's important.

Comment thread ERCS/erc-8100.md

For the array binding profile defined below, array-valued return types MUST NOT be used in multi-binding mode. Implementations that support the array binding profile MUST treat a binding in multi-binding mode whose declared output type is an array as an error. Array handling in this ERC is restricted to single-binding mode on the array container and to single-binding nodes inside the template row.

#### Example with a Single Binding to the Element's Text:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Example with a Single Binding to the Element's Text:
#### Example with a Single Binding to the Element's Text

@eip-review-bot
eip-review-bot enabled auto-merge (squash) June 2, 2026 17:29

@eip-review-bot eip-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Reviewers Have Approved; Performing Automatic Merge...

@eip-review-bot
eip-review-bot merged commit fc3d53f into ethereum:master Jun 2, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants