Skip to content

Commit

Permalink
Update EIP-4824: start
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
ipatka authored Jun 1, 2023
1 parent f5179fa commit b5eabd7
Showing 1 changed file with 198 additions and 38 deletions.
236 changes: 198 additions & 38 deletions EIPS/eip-4824.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ An API standard for decentralized autonomous organizations (DAOs), focused on re

## Motivation

DAOs, since being invoked in the Ethereum whitepaper, have been vaguely defined. This has led to a wide range of patterns but little standardization or interoperability between the frameworks and tools that have emerged. Standardization and interoperability are necessary to support a variety of use-cases. In particular, a standard daoURI, similar to tokenURI in [EIP-721](./eip-721), will enhance DAO discoverability, legibility, proposal simulation, and interoperability between tools. More consistent data across the ecosystem is also a prerequisite for future DAO standards.
DAOs, since being invoked in the Ethereum whitepaper, have been vaguely defined. This has led to a wide range of patterns but little standardization or interoperability between the frameworks and tools that have emerged. Standardization and interoperability are necessary to support a variety of use-cases. In particular, a standard daoURI, similar to tokenURI in [ERC-721](./eip-721), will enhance DAO discoverability, legibility, proposal simulation, and interoperability between tools. More consistent data across the ecosystem is also a prerequisite for future DAO standards.

## Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Every contract implementing this EIP MUST implement the `EIP4824` interface below:
Every contract implementing this EIP MUST implement the [ERC-4824](./eip-4824) interface below:

```solidity
pragma solidity ^0.8.1;
/// @title EIP-4824 Common Interfaces for DAOs
/// @dev See https://eips.ethereum.org/EIPS/eip-4824
/// @title ERC-4824 DAOs
/// @dev See <https://eips.ethereum.org/EIPS/eip-4824>
interface IERC-4824 {
event DAOURIUpdate(address daoAddress, string daoURI);
interface EIP4824 {
/// @notice A distinct Uniform Resource Identifier (URI) pointing to a JSON object following the "EIP-4824 DAO JSON-LD Schema". This JSON file splits into four URIs: membersURI, proposalsURI, activityLogURI, and governanceURI. The membersURI should point to a JSON file that conforms to the "EIP-4824 Members JSON-LD Schema". The proposalsURI should point to a JSON file that conforms to the "EIP-4824 Proposals JSON-LD Schema". The activityLogURI should point to a JSON file that conforms to the "EIP-4824 Activity Log JSON-LD Schema". The governanceURI should point to a flatfile, normatively a .md file. Each of the JSON files named above can be statically-hosted or dynamically-generated.
function daoURI() external view returns (string _daoURI);
/// @notice A distinct Uniform Resource Identifier (URI) pointing to a JSON object following the "ERC-4824 DAO JSON-LD Schema". This JSON file splits into four URIs: membersURI, proposalsURI, activityLogURI, and governanceURI. The membersURI should point to a JSON file that conforms to the "ERC-4824 Members JSON-LD Schema". The proposalsURI should point to a JSON file that conforms to the "ERC-4824 Proposals JSON-LD Schema". The activityLogURI should point to a JSON file that conforms to the "ERC-4824 Activity Log JSON-LD Schema". The governanceURI should point to a flatfile, normatively a .md file. Each of the JSON files named above can be statically-hosted or dynamically-generated.
function daoURI() external view returns (string memory _daoURI);
}
```

Expand All @@ -47,55 +48,133 @@ The DAO JSON-LD Schema mentioned above:
"membersURI": "<URI>",
"proposalsURI": "<URI>",
"activityLogURI": "<URI>",
"governanceURI": "<URI>"
"governanceURI": "<URI>",
"contractsURI": "<URI>"
}
```

A DAO MAY inherit the above interface above or it MAY create an external registration contract that is compliant with this EIP. The external registration contract MUST store the DAO’s primary address.
A DAO MAY inherit the above interface above or it MAY create an external registration contract that is compliant with this EIP. If a DAO creates an external registration contract, the registration contract MUST store the DAO’s primary address.

If the DAO inherits the above interface, it SHOULD define a method for updating daoURI. If the DAO uses an external registration contract, the registration contract SHOULD contain some access control logic to enable efficient updating for daoURI.

```solidity
pragma solidity ^0.8.1;
/// @title EIP-4824 Common Interfaces for DAOs
/// @title ERC-4824 Common Interfaces for DAOs
/// @dev See <https://eips.ethereum.org/EIPS/eip-4824>
/// @title ERC-4824: DAO Registration
contract ERC-4824Registration is IERC-4824, AccessControl {
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
error NotOwner();
error NotOffered();
contract EIP4824Registration is EIP4824 {
string private _daoURI;
address daoAddress;
event NewURI(string daoURI);
address daoAddress;
constructor() {
daoAddress = address(0xdead);
}
function initialize(address _daoAddress, string memory daoURI_) external {
/// @notice Set the initial DAO URI and offer manager role to an address
/// @dev Throws if initialized already
/// @param _daoAddress The primary address for a DAO
/// @param _manager The address of the URI manager
/// @param daoURI_ The URI which will resolve to the governance docs
function initialize(
address _daoAddress,
address _manager,
string memory daoURI_,
address _ERC-4824Index
) external {
initialize(_daoAddress, daoURI_, _ERC-4824Index);
_grantRole(MANAGER_ROLE, _manager);
}
/// @notice Set the initial DAO URI
/// @dev Throws if initialized already
/// @param _daoAddress The primary address for a DAO
/// @param daoURI_ The URI which will resolve to the governance docs
function initialize(
address _daoAddress,
string memory daoURI_,
address _ERC-4824Index
) public {
if (daoAddress != address(0)) revert AlreadyInitialized();
daoAddress = _daoAddress;
_daoURI = daoURI_;
_setURI(daoURI_);
_grantRole(DEFAULT_ADMIN_ROLE, _daoAddress);
_grantRole(MANAGER_ROLE, _daoAddress);
ERC-4824Index(_ERC-4824Index).logRegistration(address(this));
}
/// @notice Update the URI for a DAO
/// @dev Throws if not called by dao or manager
/// @param daoURI_ The URI which will resolve to the governance docs
function setURI(string memory daoURI_) public onlyRole(MANAGER_ROLE) {
_setURI(daoURI_);
}
function setURI(string memory daoURI_) external {
if (msg.sender != daoAddress) revert NotOwner();
function _setURI(string memory daoURI_) internal {
_daoURI = daoURI_;
emit NewURI(daoURI_);
emit DAOURIUpdate(daoAddress, daoURI_);
}
function daoURI() external view returns (string memory daoURI_) {
return _daoURI;
}
function supportsInterface(
bytes4 interfaceId
) public view virtual override returns (bool) {
return
interfaceId == type(IERC-4824).interfaceId ||
super.supportsInterface(interfaceId);
}
}
```

### Indexing

If a DAO inherits the ERC-4824 interface from a 4824-compliant DAO factory, then the DAO factory SHOULD incorporate a call to an indexer contract as part of the DAO's initialization to enable efficient network indexing. If the DAO is [ERC-165](./eip-165)-compliant, the factory can do this without additional permissions. If the DAO is _not_ compliant with ERC-165, the factory SHOULD first obtain access control rights to the indexer contract and then call logRegistration directly with the address of the new DAO and the daoURI of the new DAO. Note that any user, including the DAO itself, MAY call logRegistration and submit a registration for a DAO which inherits the ERC-4824 interface and which is also ERC-165-compliant.

```solidity
pragma solidity ^0.8.1;
error ERC-4824InterfaceNotSupported();
contract ERC-4824Index is AccessControl {
using ERC165Checker for address;
bytes32 public constant REGISTRATION_ROLE = keccak256("REGISTRATION_ROLE");
event DAOURIRegistered(address daoAddress);
constructor() {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(REGISTRATION_ROLE, msg.sender);
}
function logRegistrationPermissioned(
address daoAddress
) external onlyRole(REGISTRATION_ROLE) {
emit DAOURIRegistered(daoAddress);
}
function logRegistration(address daoAddress) external {
if (!daoAddress.supportsInterface(type(IERC-4824).interfaceId))
revert ERC-4824InterfaceNotSupported();
emit DAOURIRegistered(daoAddress);
}
}
```

If a DAO uses an external registration contract, the DAO SHOULD use a common registration factory contract to enable efficient network indexing.
If a DAO uses an external registration contract, the DAO SHOULD use a common registration factory contract linked to a common indexer to enable efficient network indexing.

```solidity
pragma solidity ^0.8.1;
/// @title EIP-4824 Common Interfaces for DAOs
/// @title ERC-4824 Common Interfaces for DAOs
/// @dev See <https://eips.ethereum.org/EIPS/eip-4824>
contract CloneFactory {
Expand All @@ -118,30 +197,69 @@ contract CloneFactory {
}
}
contract EIP4824RegistrationFactory is CloneFactory {
contract ERC-4824RegistrationSummoner {
event NewRegistration(
address indexed daoAddress,
string daoURI,
address registration
);
address public ERC-4824Index;
address public template; /*Template contract to clone*/
constructor(address _template) public {
constructor(address _template, address _ERC-4824Index) {
template = _template;
ERC-4824Index = _ERC-4824Index;
}
function summonRegistration(string calldata daoURI_) external {
EIP4824Registration reg = EIP4824Registration(createClone(template)); /*Create a new clone of the template*/
reg.initialize(msg.sender, daoURI_);
emit NewRegistration(msg.sender, daoURI_, address(reg));
function registrationAddress(
address by,
bytes32 salt
) external view returns (address addr, bool exists) {
addr = Clones.predictDeterministicAddress(
template,
_saltedSalt(by, salt),
address(this)
);
exists = addr.code.length > 0;
}
function summonRegistration(
bytes32 salt,
string calldata daoURI_,
address manager,
address[] calldata contracts,
bytes[] calldata data
) external returns (address registration, bytes[] memory results) {
registration = Clones.cloneDeterministic(
template,
_saltedSalt(msg.sender, salt)
);
if (manager == address(0)) {
ERC-4824Registration(registration).initialize(
msg.sender,
daoURI_,
ERC-4824Index
);
} else {
ERC-4824Registration(registration).initialize(
msg.sender,
manager,
daoURI_,
ERC-4824Index
);
}
results = _callContracts(contracts, data);
emit NewRegistration(msg.sender, daoURI_, registration);
}
}
```

### Members

Members JSON-LD Schema.
Members JSON-LD Schema. Every contract implementing this EIP SHOULD implement a membersuRI pointing to a JSON object satisfying this schema.

```json
{
Expand All @@ -163,7 +281,7 @@ Members JSON-LD Schema.

### Proposals

Proposals JSON-LD Schema. Every contract implementing this EIP should implement a proposalsURI pointing to a JSON object satisfying this schema.
Proposals JSON-LD Schema. Every contract implementing this EIP SHOULD implement a proposalsURI pointing to a JSON object satisfying this schema.

In particular, any on-chain proposal MUST be associated to an id of the form CAIP10_ADDRESS + “?proposalId=” + PROPOSAL_COUNTER, where CAIP10_ADDRESS is an address following the CAIP-10 standard and PROPOSAL_COUNTER is an arbitrary identifier such as a uint256 counter or a hash that is locally unique per CAIP-10 address. Off-chain proposals MAY use a similar id format where CAIP10_ADDRESS is replaced with an appropriate URI or URL.

Expand Down Expand Up @@ -196,7 +314,7 @@ In particular, any on-chain proposal MUST be associated to an id of the form CAI

### Activity Log

Activity Log JSON-LD Schema.
Activity Log JSON-LD Schema. Every contract implementing this EIP SHOULD implement a activityLogURI pointing to a JSON object satisfying this schema.

```json
{
Expand All @@ -208,8 +326,8 @@ Activity Log JSON-LD Schema.
"id": "<activity ID>",
"type": "activity",
"proposal": {
"id": "<proposal ID>",
"type": "proposal"
"id": "<proposal ID>",
},
"member": {
"type": "EthereumAddress",
Expand All @@ -222,8 +340,8 @@ Activity Log JSON-LD Schema.
"id": "<activity ID>",
"type": "activity",
"proposal": {
"id": "<proposal ID>",
"type": "proposal"
"id": "<proposal ID>",
},
"member": {
"type": "EthereumAddress",
Expand All @@ -234,9 +352,43 @@ Activity Log JSON-LD Schema.
}
```

### Contracts

Contracts JSON-LD Schema. Every contract implementing this EIP SHOULD implement a contractsURI pointing to a JSON object satisfying this schema.

Further, every contractsURI SHOULD include at least the contract inheriting the ERC-4824 interface.

```
{
"@context": "<http://www.daostar.org/schemas>",
"type": "DAO",
"name": "<name of the DAO>",
"contracts": [
{
"type": "EthereumAddress",
"id": "<address or other identifier>",
"name": "<name, e.g. Treasury>",
"description": "<description, e.g. Primary operating treasury for the DAO>"
},
{
"type": "EthereumAddress",
"id": "<address or other identifier>",
"name": "<name, e.g. Governance Token>",
"description": "<description, e.g. ERC20 governance token contract>"
}
{
"type": "EthereumAddress",
"id": "<address or other identifier>",
"name": "<name, e.g. Registraction Contract>",
"description": "<description, e.g. ERC-4824 registration contract>"
}
]
}
```

## Rationale

In this standard, we assume that all DAOs possess at least two primitives: *membership* and *behavior*. *Membership* is defined by a set of addresses. *Behavior* is defined by a set of possible contract actions, including calls to external contracts and calls to internal functions. *Proposals* relate membership and behavior; they are objects that members can interact with and which, if and when executed, become behaviors of the DAO.
In this standard, we assume that all DAOs possess at least two primitives: _membership_ and _behavior_. _Membership_ is defined by a set of addresses. _Behavior_ is defined by a set of possible contract actions, including calls to external contracts and calls to internal functions. _Proposals_ relate membership and behavior; they are objects that members can interact with and which, if and when executed, become behaviors of the DAO.

### APIs, URIs, and off-chain data

Expand Down Expand Up @@ -277,15 +429,21 @@ Proposals have become a standard way for the members of a DAO to trigger on-chai

The activity log JSON is intended to capture the interplay between a member of a DAO and a given proposal. Examples of activities include the creation/submission of a proposal, voting on a proposal, disputing a proposal, and so on.

*Alternatives we considered: history, interactions*
_Alternatives we considered: history, interactions_

### governanceURI

Membership, to be meaningful, usually implies rights and affordances of some sort, e.g. the right to vote on proposals, the right to ragequit, the right to veto proposals, and so on. But many rights and affordances of membership are realized off-chain (e.g. right to vote on a Snapshot, gated access to a Discord). Instead of trying to standardize these wide-ranging practices or forcing DAOs to locate descriptions of those rights on-chain, we believe that a flatfile represents the easiest and most widely-acceptable mechanism for communicating what membership means and how proposals work. These flatfiles can then be consumed by services such as Etherscan, supporting DAO discoverability and legibility.

We chose the word “governance” as an appropriate word that reflects (1) the widespread use of the word in the DAO ecosystem and (2) the common practice of emitting a governance.md file in open-source software projects.

*Alternative names considered: description, readme, constitution*
_Alternative names considered: description, readme, constitution_

### contractsURI

Over the course of community conversations, multiple parties raised the need to report on, audit, and index the different contracts belonging to a given DAO. Some of these contracts are deployed as part of the modular design of a single DAO framework, e.g. the core, voting, and timelock contracts within Open Zeppelin / Compound Governor. In other cases, a DAO might deploy multiple multsigs as treasuries and/or multiple subDAOs that are effectively controlled by the DAO. ContractsURI offers a generic way of declaring these many instruments.

_Alternative names considered: contractsRegistry, contractsList_

### Why JSON-LD

Expand All @@ -300,6 +458,7 @@ The initial draft standard was developed as part of the DAOstar One roundtable s
In-person events will be held at Schelling Point 2022 and at ETHDenver 2022, where we hope to receive more comments from the community. We also plan to schedule a series of community calls through early 2022.

## Backwards Compatibility

Existing contracts that do not wish to use this specification are unaffected. DAOs that wish to adopt the standard without updating or migrating contracts can do so via an external registration contract.

## Security Considerations
Expand All @@ -309,5 +468,6 @@ This standard defines the interfaces for the DAO URIs but does not specify the r
Indexers that rely on the data returned by the URI should take caution if DAOs return executable code from the URIs. This executable code might be intended to get the freshest information on membership, proposals, and activity log, but it could also be used to run unrelated tasks.

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).

0 comments on commit b5eabd7

Please sign in to comment.