--- eip: ERC-1643 title: Document Management Standard (part of the ERC-1400 Security Token Standards) author: Adam Dossa (@adamdossa), Pablo Ruiz (@pabloruiz55), Fabian Vogelsteller (@frozeman), Stephane Gosselin (@thegostep) discussions-to: #1411 status: Draft type: Standards Track category: ERC created: 2018-09-09 require: None --- ## Simple Summary This standard sits under the ERC-1400 (#1411) umbrella set of standards related to security tokens. Provides a standard to support attaching documentation to smart contracts, specifically security token contracts in the context of ERC-1400 (#1411). ## Abstract Allows documents to be associated with a smart contract and a standard interface for querying / modifying these contracts, as well as receiving updates (via events) to changes on these documents. Examples of documentation could include offering documents and legends associated with security tokens. ## Motivation Accelerate the issuance and management of securities on the Ethereum blockchain by specifying a set of standard interfaces through which security tokens can be operated on and interrogated by all relevant parties. Since security tokens and their ownership usually entails rights and obligations either from the investor or the issuer, the ability to associate legal documents with the relevant contracts is important. Doing this in a standardised way allows wallets, exchanges and other ecosystem members to provide a standard view of these documents, and allows investors to subscribe to updates in a standardised manner. ## Requirements See ERC-1400 (#1411) for a full set of requirements across the library of standards. The following requirements have been compiled following discussions with parties across the Security Token ecosystem. - MUST support querying and subscribing to updates on any relevant documentation for the security. ## Rationale Being able to attach documents to a security token allows the issuer, or other authorised entities, to communicate documentation associated with the security to token holders. An attached document can optionally include a hash of its contents in order to provide an immutability guarantee. ## Specification These functions are used to manage a library of documents associated with the token. These documents can be legal documents, or other reference materials. A document is associated with a short name (represented as a `bytes32`), a modified timestamp, and can optionally have a hash of the document contents associated with it on-chain. It is referenced via a generic URI that could point to a website or other document portal. ### getDocument Used to return the details of a document with a known name (`bytes32`). Returns the URI associated with the document (`string`), the hash (of the contents) of the document (`bytes32`), and the timestamp at which the document was last modified via `setDocument` (`uint256`). ``` solidity function getDocument(bytes32 _name) external view returns (string, bytes32, uint256); ``` ### setDocument Used to attach a new document to the contract, or update the URI or hash of an existing attached document. `setDocument` MUST throw if the document is not successfully stored. `setDocument` MUST emit a `DocumentUpdated` event with details of the document being attached or modified. ``` solidity function setDocument(bytes32 _name, string _uri, bytes32 _documentHash) external; ``` ### removeDocument Used to remove an existing document from the contract by giving the name of the document. `removeDocument` MUST throw if the document is not successfully removed. `removeDocument` MUST emit a `DocumentRemoved` event with details of the document being attached or modified. ``` solidity function removeDocument(bytes32 _name) external; ``` ### getAllDocuments Used to retrieve a full list of documents attached to the smart contract. Any document added via `setDocument` and not subsequently removed via the `removeDocument` function MUST be returned. ``` solidity function getAllDocuments() view returns (bytes32[]); ``` ## Interface ``` solidity /// @title IERC1643 Document Management (part of the ERC1400 Security Token Standards) /// @dev See https://github.com/SecurityTokenStandard/EIP-Spec interface IERC1643 { // Document Management function getDocument(bytes32 _name) external view returns (string, bytes32, uint256); function setDocument(bytes32 _name, string _uri, bytes32 _documentHash) external; function removeDocument(bytes32 _name) external; function getAllDocuments() external view returns (bytes32[]); // Document Events event DocumentRemoved(bytes32 indexed _name, string _uri, bytes32 _documentHash); event DocumentUpdated(bytes32 indexed _name, string _uri, bytes32 _documentHash); } ``` ## References - [EIP 1400: Security Token Standard With Partitions](https://github.com/ethereum/EIPs/issues/1411) - [EIP Draft](https://github.com/SecurityTokenStandard/EIP-Spec)