Skip to content

Commit

Permalink
馃馃椏 -> Setting dna function for #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Feb 3, 2022
1 parent 5a9c10c commit 011b00d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
29 changes: 23 additions & 6 deletions contracts/GearToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contr
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";

contract GearToken is ERC721, Ownable {
constructor(string memory _name, string memory _symbol)
ERC721(_name, _symbol)
{}

uint256 COUNTER; // Incremental function for indexing of NFTs

struct Gear {
Expand All @@ -18,15 +22,28 @@ contract GearToken is ERC721, Ownable {

Gear[] public gears;

constructor(string memory _name, string memory _symbol)
ERC721(_name, _symbol)
{}
event NewGear(address indexed owner, uint256 id, uint256 dna);

// Helpers
function _genRandomDna(string memory _str) internal pure returns(uint256) { // generate DNA
uint256 randomNum
}

// Minting function
// Minting/creation stage of the token
function _createGear(string memory _name, uint256 _dna) internal {
Gear memory newGear = Gear(_name, COUNTER, _dna, 1, 50);
gears.push(newGear); // Adds the new gear onto the array
/*_safeMint(_to, COUNTER); // Who is the NFT for?, what is the identifier of the NFT that's being minted?
COUNTER++;*/
_safeMint(msg.sender, COUNTER); // Send the token to the account that initialised the transaction?, what is the identifier of the NFT that's being minted?
emit NewGear(msg.sender, COUNTER, _dna);
COUNTER++;
}

function createRandomGear(string memory _name) public {
_createGear(_name, _dna);
}

// Getter functiongs
function getGears() public view returns(Gear[] memory){
return gears;
}
}

0 comments on commit 011b00d

Please sign in to comment.