Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
154 lines (111 sloc) 7.15 KB

ERC-1497: Evidence Standard

Note

See the original proposal of the standard here.

Warning

Smart contracts in this tutorial are not intended for production but educational purposes. Beware of using them on main network.

In SimpleEscrow contract, we used a string to store the agreement between the parties. The deployer could format that string anyway they like, as there are many ways to signal the information about the agreement.

Instead, having a standard would allow interoperability. That's why ERC-1497: Evidence Standard describes a standard approach for this. It has two categories of information: evidence and meta-evidence.

Evidence, as the name hints, is a piece of information to support a proposition. Meta-evidence is the information about the dispute itself: the agreement, parties involved, the thing that is to be decided, ruling options etc.

ERC-1497 introduces three new events: MetaEvidence, Evidence and Dispute.

erc1497.png

.. literalinclude:: ../contracts/erc-1497/IEvidence.sol
    :language: javascript

  • event MetaEvidence provides the context of the dispute, the question the arbitrators have to answer, the human readable meanings of rulings and specific modes of display for evidence. We use _metaEvidenceID to uniquely identify a piece of meta-evidence. This is necessary when there are multiple meta-evidence use-cases. _evidence contains the URI for meta-evidence JSON file.
  • event Evidence links a piece of evidence with an arbitrator, sending party and dispute. _evidence contains the URI for evidence JSON file.
  • event Dispute is raised when a dispute is created to link the proper meta-evidence and evidence group to the dispute. The event includes a reference to the arbitrator, a unique identifier for the dispute itself, the identifier to look up the meta-evidence event log and the identifier of the evidence group that can be used to look up all evidence submitted in the grouping.

Note

See the original proposal for standard evidence and meta-evidence JSON formats.

Let's return to SimpleEscrow and refactor it to implement ERC-1497 interface. Recall SimpleEscrow:

.. literalinclude:: ../contracts/examples/SimpleEscrow.sol
    :language: javascript

Now, first let's implement IEvidence:

And then, we will get rid of string agreement. Instead we need uint metaevidenceID, string _metaevidence that contains the URI to metaevidence JSON that is formatted according to the standard and we have to emit MetaEvidence event.

.. literalinclude:: ../contracts/examples/SimpleEscrowWithERC1497.sol
    :language: javascript
    :lines: 1-24,26-65,67-86
    :emphasize-lines: 24,26,32


We set the identifier of meta-evidence to constant zero, as there won't be multiple meta-evidence for this contract. Any constant number would do the job. Then we emit MetaEvidence with the provided _metaevidence. This string contains the URI from where the content of meta-evidence can be fetched.

Also, we need to emit Dispute when we create a new dispute:

.. literalinclude:: ../contracts/examples/SimpleEscrowWithERC1497.sol
    :language: javascript
    :lines: 1-86
    :emphasize-lines: 25,67


There will be only one dispute in this contract so we can use a constant zero for evidenceGroupID.

Lastly, we need a function to let parties submit evidence:

.. literalinclude:: ../contracts/examples/SimpleEscrowWithERC1497.sol
    :language: javascript
    :emphasize-lines: 90-95

Congratulations, now your arbitrable is ERC-1497 compatible!

You can’t perform that action at this time.