Skip to content

Instantly share code, notes, and snippets.

@alexroan
Created March 27, 2020 15:19
Show Gist options
  • Save alexroan/b9b6b0e147d2bf2355adfc54b6c4fa92 to your computer and use it in GitHub Desktop.
Save alexroan/b9b6b0e147d2bf2355adfc54b6c4fa92 to your computer and use it in GitHub Desktop.
ethermon.sol@2
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