Skip to content

Consolidating chapters content

Bhaskar Singh edited this page May 2, 2020 · 11 revisions

Chapter 1: Intro to SmartyPy

In Lesson 1, you're going to build a "Plant Incubator" for growing your seed into plant to defend against the upcoming zombie apocalypse.

  • Our Incubator will maintain a database of all plants in our team
  • Our Incubator will have a function for creating a new plant
  • Each plant will have the power to shoot to kill zombies

In later lessons, we'll add more functionality, like giving you the ability to buy plants from others! But before we get there, we have to add the basic functionality of creating new plants.

How Plant Incubation works

Plant growth occurs in six stages randomly between as you progress through the chapters. At every stage, a body part will grow which will be selected at random giving each plant a unique trait.

Before we start evolving our plant, allow us to give you a quick primer on:

  • What are smart contracts, anyway?
  • What is SmartPy?

What are smart contracts, anyway?

Smart contracts are scripts stored on a blockchain that enable users to define custom rules and protocols for various purposes. Some typical examples include escrow accounts, insurance-like contracts, decentralized applications — frequently called dApps, multi-signatures (multi-sig) contracts, security tokens, and virtual or physical tokenized assets.

What is Smartpy?

By default, smart contracts on Tezos are written in Michelson, but it is an hard to learn low level formal language. SmartPy is a high-level smart contract library in Python that offers a simple, intuitive and powerful syntax, enabling developers to easily define Michelson smart contracts for the Tezos blockchain.

Enough talk, let's code:

Let's start our journey in evolving our seed by first incubating it.

All SmartPy source code should start by importing the smartpy library. To do the same, type out out the following statement in the box to your right:

import smartpy as sp

When you're finished:

  • Click on "Check" to check your submission with the correct answer.
  • Click on "Show Answer" in case you get stuck.