Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed case of _generateDNA to match code #5

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 1/keccak256-and-typecasting.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chapter 11: Keccak256 and Typecasting

We want our `_generateRandomDna` function to return a (semi) random `uint256`. How can we accomplish this?
We want our `_generateRandomDNA` function to return a (semi) random `uint256`. How can we accomplish this?

Ethereum has the [hash function](https://en.wikipedia.org/wiki/Hash_function) `keccak256` built in, which is a version of SHA3. A hash function basically maps an input into a random 256-bit hexadecimal number. A slight change in the input will cause a large change in the hash.

Expand Down Expand Up @@ -46,7 +46,7 @@ All type conversions in Vyper must be made explicitly using the built-in `conver

## Put it to the test

Let's fill in the body of our `_generateRandomDna` function! Here's what it should do:
Let's fill in the body of our `_generateRandomDNA` function! Here's what it should do:

1. Generate `keccak256` hash of the `_name` argument.
2. Convert this hash into a `uint256` and assign its value to a `uint256` variable named `random`.
Expand Down