Skip to content

Commit

Permalink
Merge pull request #310 from Aryan9592/patch-3
Browse files Browse the repository at this point in the history
Update Marketplace.sol
  • Loading branch information
Vikash-8090-Yadav authored Oct 12, 2023
2 parents f354d78 + 44de294 commit 33ed6b2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Level2/Marketplace/Marketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ pragma solidity >=0.7.0 <0.9.0;

struct selling_item{
string Name;
uint Id;
uint Cost;
uint Time;
uint Id;
uint Cost;
uint Time;
}

contract shop{
string[] buyer;
mapping(uint=>string) itemlist; // this has been made to get the partcular name of the item through the id
mapping(uint=>string) itemlist; // this has been made to get the particular name of the item through the id
selling_item[] public selling_items; // this is the object of the struct
address seller; // address of the owner
mapping(uint=>uint) cost; // This is used to map b/w the id and the cost .
constructor(){
seller = msg.sender;
}

modifier onlyonwner(){
modifier onlyOwner(){
require(seller == msg.sender,"You are not allowed to do this ");
_;
}

function AllItem(string memory _Name , uint _Id, uint _Cost) public onlyonwner{
function AllItem(string memory _Name , uint _Id, uint _Cost) public onlyOwner{
itemlist[_Id] =_Name;
cost[_Id] = _Cost;
selling_items.push(selling_item(_Name,_Id,_Cost,block.timestamp));
Expand All @@ -33,12 +33,12 @@ contract shop{
function buy(uint _Id) public payable{
uint n = cost[_Id];
uint cost_ether=(n*10**18); // This is used to convert the amount into the ether
require(cost_ether==msg.value,"Less sufficent amount");
require(cost_ether==msg.value,"Less sufficient amount");
buyer.push(itemlist[_Id]);
}
function view_item() view public returns(string[]memory){
return buyer;
}


}
}

0 comments on commit 33ed6b2

Please sign in to comment.