Created
March 27, 2020 15:19
-
-
Save alexroan/b9b6b0e147d2bf2355adfc54b6c4fa92 to your computer and use it in GitHub Desktop.
ethermon.sol@2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.5.5; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
contract Ethermon is ERC721 { | |
struct Monster { | |
string name; | |
uint level; | |
} | |
Monster[] public monsters; | |
address public gameOwner; | |
constructor() public { | |
gameOwner = msg.sender; | |
} | |
function createNewMonster(string memory _name, address _to) public { | |
require(msg.sender == gameOwner, "Only game owner can create new monsters"); | |
uint id = monsters.length; | |
monsters.push(Monster(_name, 1)); | |
_safeMint(_to, id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment