I'm doing the chapter 1 of the crypto zombies course.

        uint id = zombies.push(Zombie(_name, _dna)) - 1;
        NewZombie(id, _name, _dna);

    function _generateRandomDna(string _str) private view returns (uint) {
        uint rand = uint(keccak256(_str));
        return rand % dnaModulus;

the return of this is supposed to be a number of 16 numbers. per exemple "8356281049284737". But for return rand % dnaModulus; . but i cant figure out what is the return of uint(keccak256(_str)).

1 Answer 1


Keccak256 is the EVM hash function that is used in Ethereum. It's quite similar to SHA3-256. You can also use this hash function outside of the EVM with tools like Web3js, ethers.js or just try it online here. In Solidity the call will return a hash in bytes32 form which can then easily be converted to a number by casting it to uint256.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.