# Impact Certificates Specs
## IC creation
### Smart contracts
Each IC is represented by an ERC-20 token. The token should be Ownable. An extra field is required for storing the IPFS hash of the metadata of the IC, which should be modifiable by the contract owner.
We can use something like [LexToken](https://github.com/lexDAO/LexCorpus/blob/master/contracts/token/lextoken/solidity/LexToken.sol) that uses EIP-1167, in order to minimize the gas cost of deploying an IC on Mainnet.
#### IC sale
We can use [Bancor Formula](https://github.com/bancorprotocol/contracts-solidity/blob/master/solidity/contracts/converter/BancorFormula.sol) or [Aragon Fundraising](https://fundraising.aragon.black/) to create a bonding curve sale, in order to do price discovery for the IC and do the initial distribution.
### Front end
The userflow of creating an IC has the following steps:
1. Enter project information (metadata)
* Should have multimedia support
* Expected results
* Use of funds
* Contact info
* Past work
* e.g. climate change, malaria, children
* Useful for the [Merkle drop tool](#Merkle-drop-tool)
2. Enter IC token information
* Name, symbol, decimals
* Initial supply
* Whether future minting is allowed
* Contract owner address
3. Deploy IC smart contract
4. Decide on what to do with the minted IC tokens
* Create a bonding curve sale
* Do a merkle drop
* Redirect to [Merkle drop tool](#Merkle-drop-tool)
* Create a Uniswap pool and provide initial liquidity
* Redirect to Uniswap
* A combination of the above
5. The user receives the link to their IC details page in the marketplace
## IC marketplace
### Front end
* Should provide an indexed list of IC-issuing projects
* Filter by tags
* Should have a details page for each project displaying its metadata
* Should provide link to Uniswap pair
* Should have a button for creating a Merkle drop for holders of the project's ICs
* Redirect to [Merkle drop tool](#Merkle-drop-tool), with query params in the URL
* Should display information about the [IC sale](#IC-sale) if one was created
* Should display the past & present Merkle drops where holders of the IC received tokens
### Back end
We can use the Graph protocol for indexing ICs, by creating a subgraph. This would require the IC contracts to emit useful events that provide the data we need for the marketplace. We can also store the info in the IPFS metadata file in the subgraph to avoid querying IPFS directly.
## Merkle drop tool
### Smart contract
We will use the [Uniswap Merkle Distributor](https://github.com/Uniswap/merkle-distributor) for handling Merkle drops.
We will also have an EIP-1167 based factory contract for cheaply deploying Merkle drop contracts.
### Back end
We need a database for storing the Merkle trees, so that claimants can query it to acquire the Merkle proof needed for claiming the tokens.
We also need a server for creating the list of claimants (& the amount each of them can claim) and the Merkle tree, since it's too computationally intensive to be put on client-side.
### Front end
#### Merkle drop creation
1. A Merkle drop can only distribute a single ERC-20 token (DAI, WETH,...) so the user needs to select the token they want to distribute.
2. The user should be able to provide a list of claimants and the amount of tokens each should receive.
* Can import a CSV file containing (claimant address, claim amount)
* Can add holders of all ICs with a certain tag to the list
* Can search & add all holders of an IC to the list
* Can manually add claimants
* Can set claim amounts in bulk
* Given the total amount of tokens a user is distributing to holders of an IC, can divide them pro rata among the IC holders.
* Addition should add the new token amounts to existing claim amounts
* e.g. If a claimant holds multiple ICs I'm distributing tokens to, the claimant should receive tokens for each IC they hold
* Given the total amount of tokens a user is distributing, can divide them equally among all claimants
* Can reset all claim amounts to 0
* Assignments should disregard existing claim amounts
3. The user provides details of the drop
* Can provide a list of ICs the user is distributing to, so that IC holders can know which ICs are responsible for them receiving this drop.
* This should be automatically filled out, unless the user uploaded a CSV or manually entered the claimant info
4. The user submits 2 transactions, first to deploy the Merkle drop contract, then to send the tokens to it.
5. The user receives a link to their Merkle drop claim page
#### Claimant page
Users should be able to see a list of all Merkle drops they are eligible for, the tokens they can receive, and the ICs responsible for their eligibility. If possible also display the dollar amount per IC each IC has provided to the user.
#### Claiming tokens from a Merkle drop
1. Open drop link either provided by drop creator or from the claimant page
2. The details of the drop should be displayed
3. Connect wallet and see the amount of tokens the user can claim
4. Click "claim" and submit transaction