Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-5289 proposes a standardized interface for associating smart contract interactions with legal documents and recording acceptance of those documents.

This article translates, summarizes, and expands on the following proposal.

ERC-5289 was at the Review stage as of January 8, 2024, the reference date used in the original article.

More EIP explainers:

Overview

The proposal addresses the gap between executing smart contract code and establishing a legally enforceable agreement.

It introduces an interface through which a contract can provide immutable references to legal documents, preferably hosted using IPFS, and record whether particular accounts have accepted those documents.

This allows applications to associate on-chain interactions with the relevant legal terms and provide evidence of acceptance.

However, using this interface does not automatically make a smart contract or document legally binding. Enforceability depends on the applicable law, the parties' authority and capacity, the validity of consent, the terms themselves, and other circumstances.

The proposal's author notes that the document is not intended as legal advice. Its technical purpose is to connect smart contract execution with accessible legal documentation and a verifiable record of acceptance.

Motivation

NFTs are sometimes described as mechanisms for transferring or proving copyright ownership. However, ownership of an NFT does not automatically establish ownership of the copyright in its associated work.

An NFT project may grant its initial holder a limited license to use the associated artwork without transferring the copyright itself. Whether that license also applies to subsequent holders depends on the license terms.

The proposal aims to provide a standard mechanism for explicitly associating such legal terms with on-chain assets and interactions, rather than relying on assumptions about the rights conveyed by token ownership.

Specification

javascript
/// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;

import "./IERC165.sol";

interface IERC5289Library is IERC165 {
    /// @notice Emitted when signDocument is called
    event DocumentSigned(address indexed signer, uint16 indexed documentId);
    
    /// @notice An immutable link to the legal document (RECOMMENDED to be hosted on IPFS). This MUST use a common file format, such as PDF, HTML, TeX, or Markdown.
    function legalDocument(uint16 documentId) external view returns (string memory);
    
    /// @notice Returns whether or not the given user signed the document.
    function documentSigned(address user, uint16 documentId) external view returns (bool signed);

    /// @notice Returns when the the given user signed the document.
    /// @dev If the user has not signed the document, the timestamp may be anything.
    function documentSignedAt(address user, uint16 documentId) external view returns (uint64 timestamp);

    /// @notice Sign a document
    /// @dev This MUST be validated by the smart contract. This MUST emit DocumentSigned or throw.
    function signDocument(address signer, uint16 documentId) external;
}

IERC5289Library extends ERC-165 and defines operations for referencing legal documents, recording acceptance, and querying the resulting records.

For ERC-165, see the following article.

ERC-165: Detecting supported smart contract interfaces

  • The DocumentSigned event records the signer's address and document ID following a successful signing operation.
  • The legalDocument function returns an immutable reference to a legal document, preferably hosted using IPFS. The document must use a common format such as PDF, HTML, TeX, or Markdown.
  • The documentSigned function indicates whether an account has signed a particular document.
  • The documentSignedAt function returns the recorded signing timestamp. Its value is unspecified if the account has not signed the document.
  • The signDocument function records acceptance of a document. The smart contract must validate the operation and either emit DocumentSigned or revert.

These operations provide a common interface for discovering documents and recording acceptance on-chain.


legalDocument

javascript
function legalDocument(uint16 documentId) external view returns (string memory);

Overview

Returns an immutable reference to the legal document associated with a specified document ID.

Details

The function retrieves the reference associated with documentId. IPFS hosting is recommended, and the referenced document must use a common file format such as PDF, HTML, TeX, or Markdown.

Parameter

  • documentId
    • The identifier of the requested document.

Return value

  • string memory
    • The reference to the specified document.

documentSigned

javascript
function documentSigned(address user, uint16 documentId) external view returns (bool signed);

Overview

Determines whether a specified account has signed a particular document.

Details

The function accepts an account address and a document ID, returning a Boolean indicating whether the contract records that account as having signed the document.

Parameters

  • user
    • The account address to check.
  • documentId
    • The document identifier.

Return value

  • bool signed
    • True if the account has signed the document; otherwise false.

documentSignedAt

javascript
function documentSignedAt(address user, uint16 documentId) external view returns (uint64 timestamp);

Overview

Retrieves the recorded timestamp at which an account signed a particular document.

Details

The function accepts an account address and document ID. If the account has not signed the document, the returned timestamp may be unspecified.

Applications should therefore check documentSigned before interpreting this timestamp as evidence of acceptance.

Parameters

  • user
    • The account address to check.
  • documentId
    • The document identifier.

Return value

  • uint64 timestamp
    • The recorded signing timestamp.

signDocument

javascript
function signDocument(address signer, uint16 documentId) external;

Overview

Records a user's acceptance of a particular document.

Details

The smart contract must validate the signing operation. It must emit DocumentSigned on success or revert.

The implementation must establish that the operation is authorized by the specified signer. Accepting an arbitrary signer address as an argument is not sufficient authentication.

Parameters

  • signer
    • The address of the account signing the document.
  • documentId
    • The identifier of the document being signed.

Return value

The function does not return a value. A successful operation emits DocumentSigned.


Requesting a signature

A contract can request acceptance of a particular document through an ERC-5568 wallet signal encoded in revert data.

The instruction data contains an ABI-encoded pair consisting of the legal agreement library address and a uint16 document ID.

javascript
throw WalletSignal24(0, 5289, abi.encode(0xcbd99eb81b2d8ca256bb6a5b0ef7db86489778a7, 12345));

The example requests acceptance of document 12345 in the library at address 0xcbd99eb81b2d8ca256bb6a5b0ef7db86489778a7.

The excerpt preserves the original proposal's illustrative notation. The throw syntax shown is not valid modern Solidity syntax for a custom error; implementations must use compiler-compatible revert syntax and the encoding required by the applicable wallet-signal interface.

A compatible wallet can interpret the signal and present the requested document to its user. The revert itself does not sign the document or automatically deliver a notification to wallets that do not support the signal.

For ERC-5568, see the following article.

ERC-5568: Notifying wallets that an additional action is required

Signing a document

When a compatible wallet receives a document-signing request, it can call legalDocument to retrieve the document reference and display the document to the user.

The wallet should then allow the user to accept the document or cancel the operation.

If the user chooses to accept, the wallet initiates an authorized signDocument operation to record that acceptance in the contract.

The intended workflow makes the document accessible before the user authorizes acceptance. It does not guarantee that the user has read or understood every provision.

Example wallet confirmation dialog

Source: https://eips.ethereum.org/EIPS/eip-5289

Rationale

The proposal uses uint64 for signing timestamps, reflecting the practicality of a 64-bit representation for time values.

Document IDs use uint16, providing 65,536 possible values per library. Applications requiring additional document identifiers can deploy additional libraries and identify documents by both their library address and document ID.

The signDocument function does not require a particular ECDSA signature format. This leaves room for account abstraction and other authorization mechanisms. Future extensions could introduce interfaces for additional signing methods.

The proposal favors IPFS because content-addressed references can help verify that retrieved document bytes correspond to the originally referenced content.

The interface documentation reproduced above recommends IPFS rather than making IPFS itself mandatory. The immutable-reference requirement is distinct from the choice of storage system.

Content addressing also does not guarantee permanent availability, document authorship, or legal validity. Applications must make appropriate arrangements for content retention and verification.

Compatibility

The proposal identifies no specific backward-compatibility issues. It introduces an additional application-level interface rather than changing existing Ethereum transaction rules.

Implementation

The following reference implementations are linked in the original article:

The code excerpts and reference links are preserved from the original article. They have not been independently compiled, audited, or checked for current availability as part of this translation.

Security

A compromised private key can allow an unauthorized party to perform actions that appear to originate from the affected account. A recorded acceptance may consequently be disputed by the account's legitimate controller.

The proposal suggests favoring permissive documents, such as a license granting an NFT holder permission to use associated artwork, over documents imposing restrictive obligations. This can reduce certain practical disputes but does not eliminate the risk of unauthorized acceptance.

Implementations must distinguish cryptographic account authorization from the legal identity, authority, and intent of a person.

Applications should also ensure that users see the correct immutable document, understand the operation they are authorizing, and can identify the relevant document version and library.

The legal consequences of a disputed acceptance depend on the applicable jurisdiction and circumstances. A blockchain record is evidence of an on-chain operation, not conclusive proof of legally valid consent.

Citation

Gavin John (@Pandapip1), "ERC-5289: Ethereum Notary Interface [DRAFT]," Ethereum Improvement Proposals, no. 5289, July 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5289.

Conclusion

ERC-5289 proposes a common interface for referencing legal documents and recording account-level acceptance. Combined with compatible wallet signals, it can help applications present relevant terms before recording an authorized acceptance operation.

The interface provides technical infrastructure for connecting legal agreements with smart contract interactions, rather than automatically establishing their enforceability.

Questions are welcome via Twitter @cardene777.

Other publications:

https://chaldene.net/