# Grant Proposal - Anon Exchange
Project: AX - Anonymous Exchange
## Project Overview :page_facing_up:
### Overview
The AX - Anonymous Exchange is an innovative project with a goal to establish an anonymous marketplace for NFTs using Semaphore. The marketplace will allow NFT buyers and sellers to make deposits of NFTs and ETH to the contract respectively. After a purchase is completed, the Semaphore identity will enable the NFT seller to claim the ETH and the buyer to claim the NFT. These claims will be made to new addresses, thereby ensuring that the addresses cannot be mapped back to the original NFT and ETH depositors.
### Project Details
#### Project Goal
The central goal of the AX - Anonymous Exchange project is to illustrate a potential use case for the Semaphore protocol within an NFT marketplace context, thereby inspiring the broader community. It's crucial to clarify that this project isn't intended to be a production-ready solution for NFT trading. Instead, it stands as a demonstration of how the Semaphore protocol can be employed to create a secure and anonymous trading platform.
#### Assumptions for Simplicity
Initially, the project assumes that all NFTs traded are worth 0.1 ETH. This model is scalable and can be expanded to include multiple price tiers, such as 0.5 ETH, 1 ETH, etc.
#### Technology Stack
**Smart contract:** This project will utilize the Semaphore protocol in the development of smart contracts, ensuring transaction anonymity. The Semaphore's zero-knowledge proofs play a pivotal role in maintaining privacy within this ecosystem.
**Frontend:** The frontend of this project will be built using a standard React-based DApp template, with more details provided in the roadmap section.
**Backend:** The project will integrate a relayer to submit anonymous transactions. The team plans to explore the feasibility of employing third-party services, such as OpenZeppelin Defender, Biconomy, or Gelato, to host a relayer on a testnet.
#### Semaphore Groups and Transaction Flow
Two main Semaphore groups will be established:
1. Buyers Group: This includes buyers who have deposited ETH. Membership is granted when a buyer deposits.
2. Sellers Group: This includes sellers whose NFTs have been sold. Membership is granted when an NFT is sold.
The transaction process requires buyer who is interested in an NFT to prove their membership in the Buyers Group and provide a new address to receive the NFT. On the other hand, a seller wishing to claim ETH will need to verify their membership in the Sellers Group and provide a new address to receive the ETH. The Semaphore Nullifier is used when presenting the membership proof, preventing the buyer and seller from double spending or double claiming the ETH.
#### Maintaining Anonymity with Relayers
A critical feature of the platform's architecture is the use of a relayer to submit transactions and pay gas fees. This step is crucial in maintaining anonymity throughout the transaction process. Future iterations of the project may consider incentivizing relayers with fees collected from sellers and buyers.
#### Prior Work and Research
The project is currently in its early stages, with a Proof of Concept (PoC) under development. Preliminary research suggests that the Semaphore protocol provides a robust solution for maintaining anonymity in the context of an NFT marketplace.
#### Future Directions
Although the project is not meant to be a production-ready solution, there is considerable scope for further development and expansion. Future project iterations could incorporate more price levels, develop a network of relayers for sustainability, and extend the trades to ERC20. These enhancements will continue to showcase the flexibility and potential of the Semaphore protocol in various applications.
## Team :busts_in_silhouette:
### Team members
Name: Hung Cheng
Email: lilioo826@gmail.com
Telegram handle: @lilioo826
### Team Website
currently not applicable.
### Team’s experience
I am a smart contract developer who has experiences in projects related to Defi, MEV, and MPC wallets. My portfolio page can be a good reference about my past experience.
https://www.notion.so/lilioo826/Portfolio-89deb16b44f24c568a5994c52bcdaf64
### Team Code Repos
https://github.com/hcheng826/anon-exchange
## Development Roadmap :nut_and_bolt:
<!-- This section should break out the development roadmap into a number of milestones. Since the milestones will appear in the grant contract, it helps to describe the functionality we should expect, plus how we can check that such functionality exists.
Below we provide an **example roadmap**. We recommend that the scope of the work can fit within a 3 month period and that teams structure their roadmap as 2 weeks = 1 milestone.
For each milestone:
- Please be sure to include a specification of the software. The level of detail must be enough so that we are able to verify that the software meets the specification.
- Please include total amount of funding requested per milestone.
- Please note that we require documentation (e.g. tutorials, API specifications, architecture details) in each milestone. This ensures that the code can be widely used by the community.
- Please provide a test suite, comprising unit and integration tests, along with a guide on how to run these.
- Please indicate the milestone duration, as well as number of Full-Time Employees working on each milestone, and include the number of days along with their cost per day. -->
### Overview
- Total Estimated Duration: 10 weeks
- Full-time equivalent (FTE): 0.5
- Total Costs: $10,000
The cost of a full-stack + smart contract engineer is $50 per hour, 20 hours work per week. 20 * 50 * 10 = 10000
### Milestone 1: System Design and Smart Contract Implementation
- Estimated Duration: 4 weeks
- FTE: 0.5
- Costs: $4,000
- Duration: Aug 14th - Sep 8th, 2023
#### Deliverables and Specifications
##### 0b. Documentation
1. Detailed system design, transaction flow and the Semaphore groups setup description
1. Comprehensive inline documentation of the Solidity code
2. Thorough documentation about how developer can use these functions
##### 0c. Testing Guide
The smart contract code will have proper unit-test coverage (e.g. 90%) to ensure functionality and robustness. In the guide we will describe how to run these tests.
##### 1. Functionality: Semaphore groups
A code segment that will establish Semaphore groups for buyers and sellers, manage membership, and regulate access based on group roles.
##### 2. Functionality: List NFT
The function that allows sellers to list their NFTs on the marketplace. It will create the Semaphore identity when the NFT is deposited.
##### 3. Functionality: Deposit ETH
The function that enables buyers to deposit ETH into the contract. It will create the Semaphore identity when the ETH is deposited. And it will be added to the Buyers group.
##### 4. Functionality: Buy NFT
The function that allows users to buy the NFT in the marketplace. User needs to submit the identity proof of membership in Buyers group and the address to receive the NFT. The function will
1. Verify the proof
2. Apply the nullifier so the ETH of corresponding identity cannot be double spent
3. Add the identity of NFT seller to the Seller group, so that identity is eligible to claim the ETH
4. Send the NFT to the receiving address
##### 5. Functionality: Claim ETH
The function to let seller claim ETH after the NFT is sold. User needs to submit the identity proof of membership in Sellers group and the address to receive the ETH. The function will
1. Verify the proof
2. Apply the nullifier so the ETH can not be double claimed by same identity
3. Send the ETH to the receiving address
### Milestone 2: Frontend Application
- Estimated Duration: 5 weeks (each milestone 1 week)
- FTE: 0.5
- Costs: $5,000
- Duration: Sep 18th - Oct 20th, 2023 (Skipped 1 week between Milestone 1 and 2 to attend Token2049 events)
#### Deliverables and Specifications
##### 0. Documentation and Testing Guide
The team will provide a local setup and testing guide.
Some draft of frontend design can be found here: https://docs.google.com/presentation/d/1NnqCqLupJibjHSZEL3IJy4hvpbIiMGBwcmV8-JflqVc/edit?usp=sharing
##### 1. List NFT page
The page will include the following functionalities.
- Connect wallet
- Mint test NFT (for showcase)
- List the NFTs in the connected wallet
- Show status for each NFT
- not listed (and a button to approve and list the NFT)
- listed and not sold
- sold NFTs
- Before listing, user needs to use a secret message to generate Sempahore Id. User is supposed to note the secret message down
- If the listing operation is not successful, display the error message
##### 2. Deposit ETH page
The page will include the following functionalities.
- Connect wallet
- Button to deposit fixed amount of ETH (0.01 ETH)
- Before depositing, user needs to use a secret message to generate Sempahore Id. User is supposed to note the secret message down
- if the deposit is not successful, display the error message
##### 3. View and Buy NFT page
The page will include the following functionalities.
- No need to connect wallet (use relayer to submit the transaction)
- User can see the all the NFTs listed in marketplace
- Next to each NFT listing there's a button to buy NFT
- after clicking the buy button it prompts for input of Semaphore info (secret message) and wallet address to receive the NFT
- When user submits the data, Dapp will compute the proof and submit the proof
##### 4. Claim ETH page
The page will include the following functionalities.
- No connect wallet (use relayer to submit the transaction)
- User can input Semaphore info(secret message) and wallet address to receive the ETH
- When user submits the data, Dapp will compute the proof and submit the proof
##### 5. Setup and integrate relayer
The page will include the following functionalities.
- Using 3rd party services like OpenZeppelin Defender, Gelato or Biconomy (need investigation)
- Will just put a balance on the relayer account
### Milestone 3: Wrap Up and Documentation
- Estimated Duration: 1 week
- FTE: 0.5
- Costs: $1,000
- Duration: Oct 21st - Oct 27th, 2023
##### 1. Documentation Revisit and Polishing
We will revisit and update all project documentation to ensure accuracy and relevance.
##### 2. Blogpost
A blog post will be written to share the project and its potential for inspiring the community, including ideas for future development.
## Additional Information :heavy_plus_sign:
What work has been done so far?
This project was initialized in the hackathon ETHTaipei. The basic smart contract design and idea has been drafted.