top of page

LEVEL 2

Congratulations Fury! You have taken the first step towards creating your avenger ARMY !!

​

​

​

Now you need to start creating variables that will store the details of the avengers that you create.

​

"Variables" are used to store information to be referenced and manipulated in a computer program. Most of the business logic in applications is about writing code to change the state of the variables.

​

Let us start with the mutable state and how Sophia records it. We introduce two keywords here  - "record" and "state" to store our list of created avengers.

​

We will create the following 3 variables to track in our blockchain:

- Represents the number of our avenger(index)

- A map that would store the relationship between the index and our avenger(map_avengers)

- A true/false value that would mark if an avenger's power is created or not(power)

​

The variables are created similar to a json format which looks something like this:

"variableName : variableType"

​

All the variables are created and enclosed in curly brackets({}).

​

Here is an example of a record state that records the id, map and dna of a hamster:

record state = {

id: int,

map_hamsters = map(int, hamster),

dna: string }

​

Similar to the above, you need to create a record state to record the variables connected to your SuperHero. Variable names are mentioned in the bracket next to their desription. Do not worry about the "avenger" record(similar to the hamster record). We will create it in the next step.

​

If you want more information on the variable types in Sophia, refer to this link here: https://github.com/aeternity/aesophia/blob/lima/docs/sophia.md

avengers.jpg
Try the code
Show the code
Refresh
bottom of page