Skip to content

Commit

Permalink
module-1 fine-tuned, and mark down rendering tweeked.
Browse files Browse the repository at this point in the history
  • Loading branch information
manangouhari committed Mar 16, 2021
1 parent 5090115 commit c27978e
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 113 deletions.
93 changes: 41 additions & 52 deletions lessons/introduction-to-smartpy/01/01.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,97 +16,86 @@ editor:
## Editor Instructions:
## 1️⃣ After you have read the instructions,
##### begin typing your code here. ⌨️
## 1️⃣ After you have read the instructions, begin typing your code here. ⌨️
## 2️⃣ If you get stuck =>
##### click on "Show Answer" button to activate 🧞‍♂️ mode!
##### When clicked, a bottom menu opens up
##### and you will be guided to the correct answer!
##### click on "Show Answer" button to get help!
##### When clicked, a bottom menu opens up and you will be guided to the correct answer!
##### Click on X to hide the bottom menu.
## 3️⃣ When you are happy with your code =>
##### click on "Check Answer" button!
##### If you get your code correct,
##### you will be able to proceed to the next chapter 🙏!
##### If you get your code correct, you will be able to proceed to the next chapter 🙏!
##### If you don't get your code correct,
##### the editor will respond with error messages!
##### Think of them as clues to help you get to correct answer!
##### If you don't get your code correct, the editor will respond with error messages!
#### Think of them as clues to help you get to correct answer!
answer: |
## Welcome learners, hackers and #build-ers!
## Welcome learners, hackers and #build-ers!
## As this an interactive coding school,
## you will be reading instructions present on the left
## and then typing your code on this editor!
## As this an interactive coding school,
## you will be reading instructions present on the left
## and then typing your code on this editor!
## Editor Instructions:
## 1️⃣ After you have read the instructions,
##### begin typing your code here. ⌨️
## Editor Instructions:
## 1️⃣ After you have read the instructions, begin typing your code here. ⌨️
## 2️⃣ If you get stuck =>
##### click on "Show Answer" button to activate 🧞‍♂️ mode!
##### When clicked, a bottom menu opens up
##### and you will be guided to the correct answer!
##### Click on X to hide the bottom menu.
## 2️⃣ If you get stuck =>
##### click on "Show Answer" button to get help!
##### When clicked, a bottom menu opens up and you will be guided to the correct answer!
##### Click on X to hide the bottom menu.
## 3️⃣ When you are happy with your code =>
##### click on "Check Answer" button!
## 3️⃣ When you are happy with your code =>
##### click on "Check Answer" button!
##### If you get your code correct,
##### you will be able to proceed to the next chapter 🙏!
##### If you get your code correct, you will be able to proceed to the next chapter 🙏!
##### If you don't get your code correct,
##### the editor will respond with error messages!
##### Think of them as clues to help you get to correct answer!
##### If you don't get your code correct, the editor will respond with error messages!
#### Think of them as clues to help you get to correct answer!
---
# Welcome aboard **learners** and **#build-ers**!

This is is the beginning of **first module** of **Cryptoverse Wars** - an interactive code school that teaches you how to write smart contracts in SmartPy!

## Prerequisites for the course

Welcome aboard **learners** and **#build-ers**!

This is is the beginning of **Lesson 1** of **Cryptobots vs Aliens** - an interactive code school that teaches you how to write smart contracts in SmartPy!

## Prerequisites for the course
The course only expects you to be familiar with the following:
The course only expects you to be familiar with the following:

1. You are generally familiar with software development, writing code, and running your code.
2. You have working knowledge of Python and its basic concepts.

2. You have working knowledge of Python and its basic concepts.

## What will you build or #buidl?
## What will you build or #buidl?

In the [previous chapter](/tezos/storyline), you got a magical **gem** that gives alien-killing cosmic superpowers to any cryptobot!
In the [previous module](/tezos/academy/module-0), you learned about blockchain and smart contracts, it's time to finally code smart contracts!

Your mission is to build and assemble your cryptobot from scratch and then use the gem to power it in order to stop the incoming alien invasion!
Your mission is to build and assemble your cryptobot from scratch and then use the magical gem to power it in order to stop the incoming alien invasion!

<img src="https://media.giphy.com/media/tnqluTBR5y4ve/giphy.gif" alt="drawing" style="display: block;width: 80%; margin: 40px auto"/>
<img
src="https://media.giphy.com/media/tnqluTBR5y4ve/giphy.gif"
alt="drawing"
style="display: block;width: 80%; margin: 40px auto"
/>

To build the alien-killer cryptobot, you are going to learn to write a basic **`Cryptobot` smart contract** that will contain all defense and offense functionalities to blast aliens off in style!

If you're not familiar with the term ["smart contracts"](tezos/academy/module-0/chapter-04), read through [this chapter](tezos/academy/module-0/chapter-04).

To build the alien-killer cryptobot, you are going to learn to write a basic **`Cryptobot` smart contract** that will contain all defense and offense functionalities to blast aliens off in style!

Don't worry if you are not familiar with the terminology of "smart contracts" as you will be learning about them in [Chapter 2](/lesson/chapter-02).

By the end of lesson 1, your `Cryptobot` will:
By the end of lesson 1, your `Cryptobot` will:

1. have the ability to **move around to hunt for aliens**!
2. have the ability to **shoot plasma bullets to kill aliens**!
3. have the ability to **record alien kills for post kill analysis**!

In later lessons, we’ll learn to add more functionality to your cryptobot like ability to use special moves that can blast multiple aliens in single fire, the ability to trade your cryptobot with other #builder-s on the planet etc.

3. have the ability to **record alien kills for post kill analysis**!

In later lessons, we’ll learn to add more functionality to your cryptobot like ability to use special moves that can blast multiple aliens in single fire, the ability to trade your cryptobot with other #builder-s on the planet etc.

## What to do if I get lost and need help?
No worries!

If you get lost, we recommend using the curriculum index present at the bottom left corner of your screen to reorient yourself.
No worries!

If you get lost, we recommend using the chapter list present at the top left corner of your screen to find your way.

If you need help, you can either:

Expand Down
14 changes: 7 additions & 7 deletions lessons/introduction-to-smartpy/02/02.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ editor:
showEditor: true
language: python
startingCode: |
## 🚨Quiz Time 🚨
## 🚨 Quiz Time 🚨
## What is the name of the currency used on the Tezos blockchain?
## Hint: You will find the answer by
## reading through the chapter on the left side 😉
## Hint: You will find the answer by reading through the chapter on the left side 😉
## Store the name in the variable below:
name_of_currency_on_tezos_blockchain = ""
answer: |
## 🚨Quiz Time 🚨
## 🚨 Quiz Time 🚨
## What is the name of the currency used on the Tezos blockchain?
## Hint: You will find the answer by
## reading through the chapter on the left side 😉
## Hint: You will find the answer by reading through the chapter on the left side 😉
## Store the name in the variable below:
Expand All @@ -35,11 +33,13 @@ editor:

Before we kick start writing code, this chapter serves as a helpful primer to quickly ramp up why blockchain and smart contracts are game changing technologies!

We recommend going through the [previous module](/tezos/academy/module-0) to understand blockchain, but this chapter serves that purpose fine as well.

Buckle in for this is a long chapter, though we try our best to blow your mind through explaining each technologies usecase more than how they work under the hood.

<img src="https://media.giphy.com/media/fhAwk4DnqNgw8/giphy.gif" alt="drawing" style="display: block;width: 80%; margin: 40px auto"/>

Readers who are familiar with these concepts can feel free to skip to the next chapter!
Readers who are familiar with these concepts or have gone through the previous module can feel free to skip to the next chapter!



Expand Down
6 changes: 3 additions & 3 deletions lessons/introduction-to-smartpy/03/03.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ editor:

### Intro:

SmartPy is a high-level smart contracts library built to greatly ease the accessibility, understandability and probability of smart contracts that can be used to write and test smart contracts that are deployable on the Tezos blockchain.
SmartPy is a high-level smart contracts library built to greatly ease the accessibility, understandability, and probability of smart contracts that can be used to write and test smart contracts that are deployable on the Tezos blockchain.

It uses the widely popular programming language Python to reduce the barrier of entry for smart contracts builders and empower a large crowd of potential developers of dApps and other smart contracts to contribute to the Tezos ecosystem.
It uses the widely popular programming language Python to reduce the barrier of entry for smart contract builders and empower a large crowd of potential developers of dApps and other smart contracts to contribute to the Tezos ecosystem.



Expand Down Expand Up @@ -48,7 +48,7 @@ When you’re finished:

1. [SmartPy's website](https://smartpy.io/)
2. [Intro of SmartPy](https://medium.com/@SmartPy_io/introducing-smartpy-and-smartpy-io-d4013bee7d4e) - written by SmartPy’s team.
3. [SmartPy's online IDE](https://smartpy.io/demo/) - where you can test and see how your contract is getting compiled.
3. [SmartPy's online IDE](https://smartpy.io/ide) - where you can test and see how your contract is getting compiled.



2 changes: 1 addition & 1 deletion lessons/introduction-to-smartpy/05/05.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ These are primarily used to :
2. change current state:
* Eg: "Reduce amount of money stored in World Bank by $50,000"

by functions inside the contract, which will be learning in [Chapter 7.](/lesson/chapter-07)
by functions inside the contract, which will be learning in [Chapter 7.](/tezos/academy/module-01/chapter-07)


### Example of initializing contract storage:
Expand Down
2 changes: 1 addition & 1 deletion lessons/introduction-to-smartpy/06/06.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Explaining the code above:
2. To do the above, we first created a new initialized instance contract from our `Bank` class and stored it in `bank_test_contract`.
3. Then we add this instance to the scenario to drop our contract inside our simulation environment.

You can also tinker around with the above code on [SmartPy’s online IDE](https://smartpy.io/demo/index.html?code=eJxtkEtqwzAQhvc@xU@6cSj4AAVDH1coZKlMpTEVtUZGmjS0p68kx00L0WKkef3fjHxYYlLkQEmXL1BGXrrOzpQznkk@@rwML1E0kdX9QwfA8QRjvHg1ps88T2u4nuoNNdMLBcaI3SGm2TWh3X6r2m50j0WcnDPK@dryWpzWgY1bWiu0VV1g2bJQ8rE0FI2aMVuoX0HN3OHAmHwqijYxKYMgfEad0dPsv9mVd1YSy7AXHKYUA@Ip4VjHOKL9xrAqvpVIm9f8lo9Yf@ov90kc9J0FZ4ZLcSmOz1eCF42NkH04zaQ@SlsPLJ8@RQks@n_P@_EG@gq8ZX4An5CSAw--). Try running the test by clicking on the ▶️ button!
You can also tinker around with the above code on [SmartPy’s online IDE](https://smartpy.io/ide?code=eJxtkEtqwzAQhvc@xU@6cSj4AAVDH1coZKlMpTEVtUZGmjS0p68kx00L0WKkef3fjHxYYlLkQEmXL1BGXrrOzpQznkk@@rwML1E0kdX9QwfA8QRjvHg1ps88T2u4nuoNNdMLBcaI3SGm2TWh3X6r2m50j0WcnDPK@dryWpzWgY1bWiu0VV1g2bJQ8rE0FI2aMVuoX0HN3OHAmHwqijYxKYMgfEad0dPsv9mVd1YSy7AXHKYUA@Ip4VjHOKL9xrAqvpVIm9f8lo9Yf@ov90kc9J0FZ4ZLcSmOz1eCF42NkH04zaQ@SlsPLJ8@RQks@n_P@_EG@gq8ZX4An5CSAw--). Try running the test by clicking on the ▶️ button!


### Python concept refresher:
Expand Down
22 changes: 8 additions & 14 deletions lessons/introduction-to-smartpy/07/07.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In this chapter, you will learn to add a functionality that enables you to chang

Entry functions are basically class methods with the added superpowers to modify a contract's local storage!

As we learnt about the concept of <span class="string-highlight">"state"</span> and <span class="string-highlight">"state variables"</span> in <br /> [Chapter 5](/lesson/chapter-05), these functions are mainly used to access and modify a contract's state by altering state variables values after the contract is deployed.
As we learnt about the concept of <span class="string-highlight">"state"</span> and <span class="string-highlight">"state variables"</span> in <br /> [Chapter 5](/tezos/academy/module-01/chapter-05), these functions are mainly used to access and modify a contract's state by altering state variables values after the contract is deployed.

### Show me an example:

Expand All @@ -94,20 +94,14 @@ class Bank(sp.Contract):

Explaining the code above:

1. We add a `@sp.entry_point` decorator to instruct the compiler that the following function is an entry point function.

2. We then define the `modify_name` function and pass `self` and `new_name` as function arguments.
* `new_name` will contain the new name that we would pass to this function

3. Then we access `name`, which is a variable stored inside our contract storage, by using `self.data`.
* **This is an important concept to remember, for anytime you need to access anything from the contract storage, you need to use `self.data`.**

4. We assign `new_name` to `self.data.name`.
* This line of code will change the `name` contents to whatever you send in the `new_name` variable!
* We add a `@sp.entry_point` decorator to instruct the compiler that the following function is an entry point function.
* We then define the `modify_name` function and pass `self` and `new_name` as function arguments - `new_name` will contain the new name that we would pass to this function.
* Then we access `name`, which is a variable stored inside our contract storage, by using `self.data`. **This is an important concept to remember, for anytime you need to access anything from the contract storage, you need to use `self.data`.**
* We assign `new_name` to `self.data.name`. This line of code will change the `name` contents to whatever you send in the `new_name` variable!

Simple, right?

Let us use our testing skills that we gained from [Chapter 6](/lesson/chapter-06) to test our newly created `modify_name` function!
Let us use our testing skills that we gained from [Chapter 6](/tezos/academy/module-01/chapter-06) to test our newly created `modify_name` function!


```python
Expand Down Expand Up @@ -141,14 +135,14 @@ As we know the above testing code simulates how smart contract code will behave
The above code when simulated, will change the `name` variable's content from "World Bank" to "Local Bank"


You can also tinker around with the above code on [SmartPy’s online IDE](https://smartpy.io/demo/index.html?code=eJyNUkFq5DAQvPsVRXKZYYMfEBjIJtc9LuSodKT2RKzcMpImYfL6SO1xbEIWYrBBcndVV3X5cYqpII@UynQGZeSp62ygnHFP8m@Xp_4hSklky_62A@B4gDFefDFmlzkM83V72qlvf3ZCI@OAq8eYglOgq32rau9dheSKeDZT9FIWzDE6P5xN61TYG0yUaMwr_PVM4KgQfMYps0OJIGu5TmsvUyKXmOjIPZa@tZ@P_YrR65CJB04sFQLlhaF3r5Q8PQdWKHZrv5fsHWvhVzrEQXWutF@IDhc9vfCbqtS6ruuaH@ScKZxX4_7Wg@Jhcb8a2GzSqosn2bLUUWNtqBjtj1mudvvuU_o1HhmDTxXRJqbCINQh0DblKfj36mNVVqi6sOoaUhwRTwlPbYwnaCYu6p7rjc5rPssPmPOy5f0trnkleGO4FKd68JtF1eVHZch@PAUqPorKA8urT1FGntOx6vx1@IZ6Q_hAIXg56oI2eYLGDRo3DCexM1WEfSE5zkv_AVG_jeiyxbasP9FS2KQc__18AI8cFc4-). Try running the test by clicking on the ▶️ button.
You can also tinker around with the above code on [SmartPy’s online IDE](https://smartpy.io/ide?code=eJyNUkFq5DAQvPsVRXKZYYMfEBjIJtc9LuSodKT2RKzcMpImYfL6SO1xbEIWYrBBcndVV3X5cYqpII@UynQGZeSp62ygnHFP8m@Xp_4hSklky_62A@B4gDFefDFmlzkM83V72qlvf3ZCI@OAq8eYglOgq32rau9dheSKeDZT9FIWzDE6P5xN61TYG0yUaMwr_PVM4KgQfMYps0OJIGu5TmsvUyKXmOjIPZa@tZ@P_YrR65CJB04sFQLlhaF3r5Q8PQdWKHZrv5fsHWvhVzrEQXWutF@IDhc9vfCbqtS6ruuaH@ScKZxX4_7Wg@Jhcb8a2GzSqosn2bLUUWNtqBjtj1mudvvuU_o1HhmDTxXRJqbCINQh0DblKfj36mNVVqi6sOoaUhwRTwlPbYwnaCYu6p7rjc5rPssPmPOy5f0trnkleGO4FKd68JtF1eVHZch@PAUqPorKA8urT1FGntOx6vx1@IZ6Q_hAIXg56oI2eYLGDRo3DCexM1WEfSE5zkv_AVG_jeiyxbasP9FS2KQc__18AI8cFc4-). Try running the test by clicking on the ▶️ button.


## #buidl-ing time:

Let’s change our Cryptobot’s name from <span class="string-highlight">"terminator"</span> to <span class="string-highlight">"punky terminator"</span> by doing the following:

1. Add a `change_name` entry point function just after the scope of `__init__` initialization function finishes.
* Add a `change_name` entry point function just after the scope of `__init__` initialization function finishes.
* Pass `self` and `new_name` as arguments to `change_name` function.
* Use `self.data.name` to access `Cryptobot` contract’s internal storage. And assign it the value of `new_name`.

Expand Down
13 changes: 6 additions & 7 deletions lessons/introduction-to-smartpy/08/08.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ editor:
showEditor: false
language: python
startingCode: |
## 🚨Quiz Time 🚨
## 🚨 Quiz Time 🚨
## In Cryptobot contract shown below,
## what is the data type of `name` that SmartPy will automatically infer?
Expand All @@ -21,7 +21,7 @@ editor:
answer: |
## 🚨Quiz Time 🚨
## 🚨 Quiz Time 🚨
## In Cryptobot contract shown below,
## what is the data type of `name` that SmartPy will automatically infer?
Expand All @@ -35,21 +35,20 @@ editor:
---

### Intro:
## Intro:
As readers familiar with Python would know that Python is a dynamically typed language.

This is in contrast to languages like C, Rust, OCaml (the language with which Tezos blockchain is built in) which are statically typed languages.

For example, let us contrast how one would define a variable that stores the number 5 in C and Python.

##### C Code:

C Code -
```cpp
int number = 5
```
<br />

##### Python Code:

Python Code -
```python
number = 5
```
Expand Down
4 changes: 1 addition & 3 deletions lessons/introduction-to-smartpy/09/09.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,17 @@ But at the moment, there is no way to know whether your Cryptobot is dead or ali
#### Step by step walkthrough:

1. Let us add `is_alive` variable to our `Cryptobot` contract storage which takes in the current state of life from the user at the time of contract initialization.

2. Since we want to let user initialize `is_alive` value at class invocation time, add `life_state` as an argument to the `__init__` function.

3. Assign `life_state` argument to `is_alive` state variable.



#### Testing our code:

1. In our test function, pass `life_state = True` as an argument when invoking `Cryptobot` class

2. We will use `scenario.verify`, to check the current whether Cryptobot is alive or not by checking the current value of `is_alive` state variable:

<br />

```python
## Syntax for using `scenario.verify`:
Expand Down
Loading

0 comments on commit c27978e

Please sign in to comment.