Due: Sunday, March 25th at 10pm
Overview: Build a simple ecommerce DApp store where everyone can sell/buy products. You'll be using Truffle to build the entire app end-to-end.
We'll be utilizing IPFS to host our site to make it truly decentralized. The contract will also feature an escrow system, which involves a 3-person approval to release funds. This means that instead of the buyer sending money to the sender directly, a third person holds the funds until the others have agreed funds should be released (or refunded).
The following user stories must be completed:
- Users can see products for sale, and buy them through a web interface.
- Users can add products for sale using a web interface.
- Product images and frontend assets are hosted on IPFS.
- A functioning escrow system:
- Instead of transferring money directly to the buyer, money is sent to an "escrow" holder.
- This person will release funds or refund funds based on consensus from 2 out of the 3 parties.
- The escrow contract will deduct a 1% fee for these services.
- The WebUI is updated as the user makes transactions, by listening to Solidity Events.
- User is able to filter products based on category and sold/unsold status. To do this, you'll have to implement an off-blockchain store.
- Define a struct for Product information. I recommend using an enum for ProductStatus to represent whether it's available, buying, or sold.
struct Product {
string name;
string category;
string imageLink;
string descLink;
uint price;
ProductStatus status;
}
- If you want to update the page in real time as different transactions occur, you'll want to use Events in Solidity. You can read more about them here.
The following advanced user stories are optional. You're not required to do these, but you will learn more from doing them:
- Write unit tests for your contract functionality. Examples are verifying that money is debited correctly, product availability is updated correctly, products are added correctly.
- Allow quantity for products in the store.
- Whatever else you can think of!
Prerequisites
$ truffle compile
$ truffle migrate
$ ipfs daemon
If you have problem with CORS access, run below command and restart your deamon:
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
$ npm install
$ npm run dev