# DAO IPCI on Everscale
At the end of 2022, a team of [Multi-agent Systems](https://multi-agent.io/) engineers migrated a set of [DAO IPCI](https://ipci.io/) smart contracts to the [Everscale network](https://everscale.network/).
Initially, the DAO IPCI project was implemented on the [Ethereum](https://ethereum.org/en/) network that brought "Blockchain technology for carbon markets, environmental assets and liabilities". Source code of the contracts is [here](https://github.com/DAO-IPCI/DAO-IPCI).
The original version contained a large number of smart contracts. When transferring the project to the Everscale network, it was decided to simplify their structure while retaining functionality. As a result, the following roles remained:
* An operator who deploys his DAO and adds auditors
* An auditor who has the right to issue and transfer tokens to the user's address
* A user who has the right to request the issuance of a token by providing the confirmations necessary for the issuance of green tokens
In addition, an off-chain agent was made for auditors, which allows checking confirmations from the user and minting the corresponding number of tokens.
## Usage Scenario
### Beginning
1. *Operator* creates a wallet on the Everscale network
2. *Operator* creates its own DAO by deploying the AssetFactory contract
### Adding Auditors
*Operator* adds to the whitelist (inside AssetFactory `addAuditor()`) auditors.
### Issue of a New Token
1. *User* (regular wallet) chooses an auditor off-chain, asks the auditor to create a token.
2. *User* and *Auditor* off-chain agree on the parameters of the token (initial emission, token name, symbol, decimals...).
3. *Auditor* creates a token through the factory (calls `deployRoot()` in the AssetFactory contract).
4. *Auditor* transfers the initial issue to the *User*.
### Next Steps
As *User* produces green energy, he can agree with the *Auditor* on the proportional issue of tokens to *User*'s account.
## Everscale and Ethereum Differences
The Everscale network has several differences compared to Ethereum. For us the most important were:
* **Account** == smart contract. Account address - a uniquely calculated value from the code and initial data: `address = hash[hash(smart_contract_code), hash(initial_data)]`
* **External message** - if the contract is deployed using such a message, the account owner will be 0:000...00. The message is "free" - the validator allocates credit gas and calls the contract, which must agree to pay for the transaction (or not agree).
* **Internal message** - the gas fee is debited from the message account. When deploying a contract via an internal message, the sender of the message will be set as the owner. ⇒ Our Asset Factory contract is deployed by the Operator using an internal message
At Everscale, users pay for data storage. Therefore, it is unprofitable to have one contract with a list of owners. In order not to pay for the storage of other people's data, it is customary in ES to deploy a small wallet (e.g. contract) to each user who stores only his balance.
For our scenario, the `TokenFactory` contract was ideal. We took the factory contract from [Broxus](https://github.com/broxus/tip3/blob/master/contracts/additional/TokenFactory.tsol) and modified it to suit our needs. It was necessary that only auditors had the right to issue tokens, for this, a view function for checking `isAuditor` appeared in our contract. In addition, we have added the `addAuditor` and `removeAuditor` functions to allow the operator to add and remove auditors, respectively. Since storage in Everscale is not free, a TokenWallet is deployed for each owner, which provides an API for the user (`transfer()`, `burn()`, etc.).
## Results
As a result of alteration of contracts, the following [repository](https://github.com/Multi-Agent-io/dao-ipci-everscale) was obtained
And we have prepared a [DApp](https://dapp-ipci-everscale.multi-agent.io/#/) for interacting with contracts.
An example of interaction with dapp
{%youtube otXLBOwccnA %}
## Mainnet Addresses
```
AssetFactory:
0:e54c6a9817b5c5a24fd3496cbaa0aefa7dc6a59cf8e3f896f5567029626ce45
Auditor:
0:3a32bec610f8a8aed317d869b861f3ef294b716007705880383628bd0c794dca
User:
0:8378231949d0945553926f0fd4798c48bcfb4343bea528b6f6383e6bd1b8e4ba
GreenAsset:
0:0fe37dee2a89250a685f9a8a08c0c68b7a7bca542a68059d41ad145d788372ef
```
## Acknowledgement
Thanks to [@tubleronchik](https://github.com/tubleronchik/) and [@fourlen](https://github.com/fourlen) for making this project happen!