Guest User

Untitled

a guest
Nov 12th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. pragma solidity ^0.4.19;
  2.  
  3. import "./dinoownership.sol";
  4. import "./dinofighter.sol";
  5.  
  6. contract DinoMarket is DinoFighter6, DinoOwnership {
  7.  
  8. event UpForSale(uint _dinoId, uint256 _price);
  9. event OffTheMarket(uint _dinoId);
  10.  
  11. mapping (uint => bool) public canyoubuyit;
  12. mapping (uint => uint) public dinomarketprice;
  13. mapping (uint => address) selleraddress;
  14.  
  15. //Allows seller to set price for their Dino.
  16. //Places their Dino on market
  17. function sellDino(uint _dinoId, uint _price) public onlyOwner(_dinoId) {
  18. dinomarketprice[_dinoId] = _price;
  19. canyoubuyit[_dinoId] = true;
  20. selleraddress[_dinoId] = msg.sender;
  21. UpForSale(_dinoId, _price);
  22. }
  23.  
  24. //allows user to buy Dino that is on the market
  25. function buyDino(uint _dinoId) public payable {
  26. require(dinomarketprice[_dinoId] == msg.value);
  27. require(canyoubuyit[_dinoId] == true);
  28. (selleraddress[_dinoId]).transfer(msg.value);
  29. transfer(msg.sender, _dinoId);
  30. canyoubuyit[_dinoId] = false;
  31.  
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment