Vishnu Praneeth Palavali - 2020A7PS0126H
Chetan Akash Vankadara - 2020A7PS2196H
Srikanth Mangipudi - 2020A8PS1162H
Ch Sree Nihitha - 2020B4TS1384H
Suppose you want to buy some items like spectacles, clothes, etc. the go to place for us is either Amazon or Flipkart. Suppose there is a new website named xyz.com which is offering heavy discounts and also there is a website abc.com which is offering high-quality items at the same price as of Amazon. But any normal user will be hesitant to buy any item from abc.com or xyz.com due to the lack of trust (ie after payment xyz.com may not deliver the item, etc) although xyz.com and abc.com are offering better products at a lower price.
So you need to try to solve this problem by building a smart contract that sends the amount to xyz.com only when the item has been delivered to the user and off- loading of the item starts only when the user has paid the amount of the item to the smart contract which is deployed on the blockchain.
- Sellers can register new products on the platform.
- Buyers can buy the registered products.
- The product is deployed after the buyer pays the price of the item .
- The Seller gets the amount only after the buyer confirms that the item is delivered
- Users can view all the registered products and their availability
- Users can cancel their product anytime and they'll be refunded.
- Load the file in Remix ide.
- Deploy the smart contract.
- Functions can be triggered by using the gui functionalities present in the panel on the left side.
- The sender and the amount sent can also be changed from the left side panel to simulate different users.
Smart contracts are simply programs stored on a blockchain that run when predetermined conditions are met. They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any intermediary’s involvement or time loss. They can also automate a workflow, triggering the next action when conditions are met.
To buy the product, the buyer has to pay the price of the item to the smart contract. This amount is held by the contract till the buyer confirms that the item is delivered. Upon the confirmation, the amount held by the smart contract is transferred to the seller. If the seller doesn't deliver the product, the buyer can cancel the order and get a refund from the smart contract. The smart contract thus ensures that a seller couldn't default on the product, they make the platform trustworthy.
Title of the product, description of the product, seller address, buyer address, price, itemId, availability, delivered, deployed
- registerProduct() - The function takes inputs(title, descrip, price) and creates a new product with the given arguments, the address of the seller and the generated itemId. The function also checks if the product's price is greater than zero.
- buy() - The function takes the itemID as an input, collects payment from the buyer. After checking if the payment is valid, the function confirms that the buyer has bought the item. The function deploys the product bought after the payment(calls the deployProduct function).
- deployProduct() - The function takes itemID as an argument and deploys the item selected.
- cancelProduct() - The function takes itemID as an argument and checks if the msg sender is the buyer of the product and the product hasn't been delivered yet. If yes, the amount held by the contract is transferred to the owner and the product is made available again.
- delivery() - The function takes itemID as an argument. The function checks if the user trying to mark the item as delivered is actually the buyer, if yes, the amount held by the contract is transferred to the seller.