# Dao

Aside from the P2P relationship mentioned before, grouping relationships are also important in a social network. With this relationship, users with common interests can interact and communicate more effectively.

In the Relation Protocol, DAOs serve the follow purposes:

* Provide a social platform

  With DAOs, people with common interests can build or join groups to create an interactive community.
* DAO management

  The Relation Protocol provides certain management functions for DAOs. DAO creators can manage the DAO, add or remove members. These features are important for a DAO and its stability.
* Increase user interaction and participation

  With DAOs, users can participate in social groupings more effectively to share their views and experience, thus increasing user interaction and participation.

## Schema

### DaoRegister

The [schema](https://arweave.net/7mRfawDArdDEcoHpiFkmrURYlMSkREwDnK3wYzZ7-x4) corresponding to the DaoRegister contract is saved to Arweave in the form of a ttl file, with the transaction hash on Arweave as the schemaURI to be passed to the contract during its initialization stage. For example:

```
ar://7mRfawDArdDEcoHpiFkmrURYlMSkREwDnK3wYzZ7-x4
```

A complete rdf example to describe a DAO contract created by an address is as follows:

```
:Soul_0x0000000000000000000000000000000000000011 p:daoContract :Contract_0x1110000000000000000000000000000000000022 .
```

The schema consists of:

* The list of prefixes.

```
PREFIX : <http://relationlabs.ai/entity/>
PREFIX p: <http://relationlabs.ai/property/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
```

* Class

:Soul represents the address binded with a domain name record resolved. Contract represents the address of the DAO contract.

```
:Soul a rdfs:Class ;
    rdfs:label "Soul" ;
    rdfs:comment "A soul." .

:Contract a rdfs:Class ;
    rdfs:label "Contract" ;
    rdfs:comment "A contract." .
```

* Predicate

p:daoContract is used to describe the DAO contract address owned by an address

```
p:daoContract a rdf:Property ;
    rdfs:label "daoContract" ;
    rdfs:comment "The dao contract." ;
    rdfs:domain :Soul ;
    rdfs:range :Contract .
```

### Dao

The [schema](https://arweave.net/UTbYdbPy5Ov2bZ1ikWm_4RhMT5GJPvasE57qtSfL1oQ) corresponding to a DAO contract is stored on Arweave in the form of a ttl file, with the transaction hash as the schemaURI to be passed to the contract during its initialization stage. For example:

```
ar://UTbYdbPy5Ov2bZ1ikWm_4RhMT5GJPvasE57qtSfL1oQ
```

A complete rdf example to describe that a certain address has joined a certain DAO:

```
:Soul_0x0000000000000000000000000000000000000022 p:join :Dao_0x0000000000000000000000000000000000000011 .
```

The schema consists of:

* schema's prefixes of namespaces

```
PREFIX : <http://relationlabs.ai/entity/>
PREFIX p: <http://relationlabs.ai/property/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
```

* Class

:Soul represents the addresses of the members who joined the group. :Dao represents the group

```
:Soul a rdfs:Class ;
    rdfs:label "soul" ;
    rdfs:comment "A soul" .

:Dao a rdfs:Class ;
    rdfs:label "dao" ;
    rdfs:comment "A dao" .
```

* Predicate

p:join is used to describe the relationship between an address and a group.

```
p:join a rdf:Property ;
    rdfs:comment "Join a dao" ;
    rdfs:domain :Soul ;
    rdfs:range :Dao .

```

## Contract

The DAO module consists of the DaoRegister contract and the DAO contract. We use the DaoRegister contract as the factory pattern and registration center to deploy and record the DAO contracts created by users.

### DaoRegister

```solidity
interface IDaoRegister is ISemanticSBT {
   /**
    * Deploy a DAO contract.
    * @param to 
    * @param name 
     * @return tokenId 
     */
    function deployDaoContract(address to,string memory name) external returns (uint256);

   /**
     * Lookup the information on a DAO.
     * @param tokenId 
     * @return owner  
     * @return contractAddress  
     */
    function daoOf(uint256 tokenId) external view returns (address owner, address contractAddress);
}
```

### Dao

```solidity
interface IDao is ISemanticSBT {

    //Contract initialization. The daoRegister initializes the contract:
    function initialize(
        address owner,
        address minter,
        string memory name_,
        string memory symbol_,
        string memory baseURI_,
        string memory schemaURI_,
        string[] memory classes_,
        Predicate[] memory predicates_
    ) external;

   /**
     * Set the information for a DAO. 
     * @param daoURI  This should be a hash on Arweave.
     */
    function setDaoURI(string memory daoURI) external;

    /**
     * Is this an open dao?
     * @param isFreeJoin true--free to join;false--closed to the public
     */
    function isFreeJoin() external view returns (bool);

    /**
     * Add the specified address to dao in batches.
     * @param addr The specified address.
     */
    function addMember(address[] memory addr) external;

    /**
     * Join a dao
     * @param tokenId  The tokenId for this member in the dao.
     */
    function join() external returns (uint256 tokenId);

    /**
     * Removed from a dao(calls the method "burn")
     * @param addr 
     */
    function remove(address addr) external;

    /**
     * The URI for a dao
     * @param daoURI  A resource address pointing to the data of a dao's information. It is a transaction hash on Arweave.
     */
    function daoURI() external view returns (string memory daoURI);

    /**
     * The owner of a dao
     * @param owner The owner of a dao
     */
    function ownerOfDao() external view returns (address owner);

    /**
      * Is a member of the dao?
      * @param addr 
      * @return isMember: true--is a member of the dao;false--not a member of the dao
     */
    function isMember(address addr) external view returns (bool isMember);

}
```

Full source code:

* [DaoRegister](https://github.com/relationlabs/semanticSBT/blob/main/contracts/template/DaoRegister.sol)
* [Dao](https://github.com/relationlabs/semanticSBT/blob/main/contracts/template/Dao.sol)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://relationlabs.gitbook.io/protocol/contract-open-standard/relationship/dao.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
