diff --git a/lesson-1/chapter-13/Contract.sol b/lesson-1/chapter-13/Contract.sol index 8e834a2..84a1b64 100644 --- a/lesson-1/chapter-13/Contract.sol +++ b/lesson-1/chapter-13/Contract.sol @@ -1,7 +1,8 @@ -pragma solidity ^0.4.25; +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; contract ZombieFactory { - + // declare our event here event NewZombie(uint zombieId, string name, uint dna); uint dnaDigits = 16; @@ -14,19 +15,20 @@ contract ZombieFactory { Zombie[] public zombies; - function _createZombie(string _name, uint _dna) private { - uint id = zombies.push(Zombie(_name, _dna)) - 1; + function _createZombie(string memory _name, uint _dna) private { + zombies.push(Zombie(_name, _dna)); + uint id = zombies.length -1; emit NewZombie(id, _name, _dna); } - function _generateRandomDna(string _str) private view returns (uint) { + function _generateRandomDna(string memory _str) private view returns (uint) { uint rand = uint(keccak256(abi.encodePacked(_str))); return rand % dnaModulus; } - function createRandomZombie(string _name) public { + function createRandomZombie(string memory _name) public { uint randDna = _generateRandomDna(_name); _createZombie(_name, randDna); } -} \ No newline at end of file +}