Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 12th, 2018 75 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top