Lesson

Crypto Zombies Lesson 2, Chapter 7, Storage vs Memory

Lesson Summary

In this CryptoZombies tutorial we look at the difference between storing variables in storage or keeping them temporarily in memory. We learn that by default, Solidity variables outside of functions are considered state variables and will therefore be storage. This means variables outside of functions are by default permanently written to the blockchain. Variables that are within functions will disappear after the function call is over. Once the function call ends Solidity clears those variables from memory, like RAM in a computer. In this challenge we create a function called feedAndMultiply which takes 2 parameters. Both are uints, one is our _zombieId and the other is _targetDna. We then make sure that zombie belongs to that zombieOwner which called the function. Finally we get the zombies DNA by creating a local Zombie named myZombie which we set equal to the _zombieId i the zombes array.

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required


Share: