Save
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Cryptozombies

Creating a zombie factory

TermDefinition
An empty contract named HelloWorld would look like this: contract HelloWorld { }
A bare-bones starting contract pragma solidity >=0.5.0 <0.6.0; contract ContractName { }
What is a contract? A contract is the fundamental building block of Ethereum applications.
All solidity source code should start with a ____________ version pragma
Create an empty contract called ZombieFactory. contract zombieFactory {}
What are state variables What are state variables
State variable example The uint data type is an unsigned integer, meaning its value must be non-negative.
The following operations are the same as in most programming languages: Addition: x + y Subtraction: x - y, Multiplication: x * y Division: x / y Modulus / remainder: x % y (for example, 13 % 5 is 3, because if you divide 5 into 13, 3 is the remainder)
Example of an exponential operator in solidity uint x = 5 ** 2; // equal to 5^2 = 25
Create a uint named dnaModulus, and set it equal to 10 to the power of dnaDigits. uint dnaModulus = 10 ** dnaDigits;
Sometimes you need a more complex data type. For this, Solidity provides ________: structs
Example of struct struct Person { uint age; string name; }
Structs allow you to create more _________ data types that have ___________ properties. complicated, multiple
Create a struct named Zombie and let it have 2 properties: name (a string), and dna (a uint). struct Zombie { string name; uint dna; }
When you want a collection of something, you can use an ______. array
There are two types of arrays in Solidity: ________ arrays and ______ arrays: fixed, dynamic
// Array with a fixed length of 2 elements: uint[2] fixedArray;
// another fixed Array, can contain 5 strings: string[5] stringArray;
// a dynamic Array - has no fixed size, can keep growing: uint[] dynamicArray;
Example of an array of structs. Person[] people; // dynamic Array, we can keep adding to it
You can declare an array as public, and Solidity will automatically create a getter method for it. The syntax looks like: Person[] public people;
Create a public array of Zombie structs, and name it zombies. Zombie[] public zombies;
A function declaration in solidity looks like the following: function myFunction(string memory _name, uint _amount) public { }
There are two ways in which you can pass an argument to a Solidity function: By value and by reference
What is required for all reference types such as arrays, structs, mappings, and strings? It is required that variables should be stored- in memory
Note: It's convention (but not required) to start function parameter variable names with an ____________ in order to differentiate them from global variables. underscore (_)
Create a public function named createZombie. It should take two parameters: _name (a string), and _dna (a uint). Don't forget to pass the first argument by value by using the memory keyword Leave the body empty. function createZombie (string memory _name, uint _dna) public { }
function createZombie (string memory _name, uint _dna) public { // start here } In one line of code, fill in the function body so it creates a new Zombie, and adds it to the zombies array. The name and dna for the new Zombie should come from the zombies.push(Zombie(_name, _dna));
Example how to declare a private function: uint[] numbers; function _addToArray(uint _number) private { numbers.push(_number); }
it's convention to start private function names with an _____________. underscore (_)
function createZombie(string memory _name, uint _dna) public { zombies.push(Zombie(_name, _dna)); } Our contract's createZombie function is currently public by default — this means anyone could call it and create a new Zombie in our contract! Le function _createZombie(string memory _name, uint _dna) private { zombies.push(Zombie(_name, _dna)); }
To return a value from a function, the declaration looks like this: string greeting = "What's up dog"; function sayHello() public returns (string memory) { return greeting; }
Solidity also contains _____ functions, which means you're not even accessing any data in the app. pure
Create a private function called _generateRandomDna. It will take one parameter named _str (a string), and return a uint. Don't forget to set the data location of the _str parameter to memory. Mark it as view and allow the function body empty. function _generateRandomDna(string memory _str) private view returns (uint) { }
Created by: jauvany
Popular Computers sets

 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards