Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.19;
- import "./dinoownership.sol";
- import "./dinofighter.sol";
- contract DinoMarket is DinoFighter6, DinoOwnership {
- event UpForSale(uint _dinoId, uint256 _price);
- event OffTheMarket(uint _dinoId);
- mapping (uint => bool) public canyoubuyit;
- mapping (uint => uint) public dinomarketprice;
- mapping (uint => address) selleraddress;
- //Allows seller to set price for their Dino.
- //Places their Dino on market
- function sellDino(uint _dinoId, uint _price) public onlyOwner(_dinoId) {
- dinomarketprice[_dinoId] = _price;
- canyoubuyit[_dinoId] = true;
- selleraddress[_dinoId] = msg.sender;
- UpForSale(_dinoId, _price);
- }
- //allows user to buy Dino that is on the market
- function buyDino(uint _dinoId) public payable {
- require(dinomarketprice[_dinoId] == msg.value);
- require(canyoubuyit[_dinoId] == true);
- (selleraddress[_dinoId]).transfer(msg.value);
- transfer(msg.sender, _dinoId);
- canyoubuyit[_dinoId] = false;
- }
- }
Add Comment
Please, Sign In to add comment