diff --git a/src/dao_adventure/graduation.md b/src/dao_adventure/graduation.md index d154ad1..e67686b 100644 --- a/src/dao_adventure/graduation.md +++ b/src/dao_adventure/graduation.md @@ -63,7 +63,7 @@ Until now, we've only worked with applications that use a single canister. Today - Name: `motoko_bootcamp` - Associated Principal: `nkqop-siaaa-aaaaj-qa3qq-cai` -> You can decide to hardcode the initial setup or create an external one that will be executed canister upon deployment. +> You can decide to hardcode the initial setup or create an external one that will be executed upon canister deployment. 7. **Token Faucet** You are required to use the **Motoko Bootcamp Token**, a free, educational token faucet. It allows unlimited minting but holds no real economic value; it's solely for educational use. diff --git a/src/motoko_theory/appendix-1/APPENDIX-1.MD b/src/motoko_theory/appendix-1/APPENDIX-1.MD index 658ef92..62f2bb1 100644 --- a/src/motoko_theory/appendix-1/APPENDIX-1.MD +++ b/src/motoko_theory/appendix-1/APPENDIX-1.MD @@ -5,15 +5,15 @@

-Throughout history, humans have find different creative ways to organize in social groups and structures. They have done so different reasons such as safety, support, social identity, work, power or even economic. A few common groups include: family unit, tribes, clans, states, guilds, secrect societies, political parties... +Throughout history, humans have found different creative ways to organize in social groups and structures. They have done so for different reasons such as safety, support, social identity, work, power or even economics. A few common groups include: family unit, tribes, clans, states, guilds, secret societies, political parties... With the advent of the Internet, social networks, cryptocurriencies & smart contracts many believe that a new type of organization is about to start a new chapter of human history: **DAO**. A Decentralized Autonomous Organization (DAO) is a digital organization that is composed of members living all around the world, and is governend and organized through smart contracts. -Because smart contracts execute automatically, are decentralized, transparent, can't be censored or modified by any individual the same applies to **DAOs** in the sense that they are not controlled by any single individual or entity, they rather operate based on the collective decision-making of their members. +Smart contracts execute automatically, are decentralized, transparent and can't be censored or modified by any individual. The same applies to **DAOs** in the sense that they are not controlled by any single individual or entity, they rather operate based on the collective decision-making of their members. -A few usecases for DAOs include: +A few use cases for DAOs include: - **Decentralized venture capital**: DAOs can be used to enable decentralized venture capital funds, in which members can propose and vote on investments in projects. [The DAO](https://en.wikipedia.org/wiki/The_DAO_(organization)) was one of the first DAOs to be created and was designed to be a decentralized venture capital fund, although it was controversial and ultimately failed due to a hack. @@ -22,9 +22,9 @@ A few usecases for DAOs include: ## 🙁 Limitations of DAOs As we've said DAOs are formed through smart contracts. However, smart-contracts are pretty limited: - They can't store any meaningful amount of data (photos, videos, files...). [The cost of storing 1GB of data in the Ethereum blockchain has been estimated at around $5.5M](https://steemit.com/ethereum/@suryanshkumr/you-need-usd5-5m-to-save-1gb-data-in-ethereum-blockchain-d) -- It is not possible to interact with a smart contracts directly from a browser. A wallet needs to be installed and acts as relay. +- It is not possible to interact with smart contracts directly from a browser. A wallet needs to be installed and acts as a relay. - Smart contracts rely on oracles to gather information from the external world and facilitate communication with it, as they are unable to interact with anything outside of the blockchain on their own. -- Smart contracts are limited in term of computational power they have access to. +- Smart contracts are limited in terms of computational power they have access to. Those technical limitations results in concrete actions that a DAO would be unable to do: - 🌳 **Interact with the physical world**: DAOs are limited to the digital world and cannot interact with the physical world. A DAO could not plant a tree, turn on a light switch, or deliver a physical letter. @@ -32,7 +32,7 @@ Those technical limitations results in concrete actions that a DAO would be unab - 🔮 **Use advanced computational power**: For example, a DAO could not run simulations to predict the outcome of a complex system, such as the spread of a pandemic or the performance of a financial portfolio. - 🗂️ **Handle large amounts of data**: For example, a DAO could not store and process the complete medical records of millions of patients. -Those important limitations are preventing DAOs to have a meaningful impact in the world. +Those important limitations are preventing DAOs from having a meaningful impact in the world. ## 🚀 From smart-contracts to canisters Imagine that smart-contracts could: @@ -57,4 +57,4 @@ This concept is called Open Internet Services. The aim is to end the current mon

-> **A prediction?**
Open Internet Services are powerful and won't stop with social networks or messaging apps. They are here to revolutionize the way we work and live together. With unprecedented scalability of collaborative work enabled by the combined power of DAOs and OISs, the sky's the limit! Imagine the positive impact on humanity with projects like environmental conservation, medical research, and education all being amplified by this new level of coordination and collaboration. And this is just the tip of the iceberg, as this new technology could open the door to even more innovative solutions to some of the world's most pressing problems. This is an opportunity to make real progress and change the world in ways we never thought possible before. **Get ready, the future is here!** +> **A prediction?**
Open Internet Services are powerful and won't stop with social networks or messaging apps. They are here to revolutionize the way we work and live together. With unprecedented scalability of collaborative work enabled by the combined power of DAOs and OISs, the sky's the limit! Imagine the positive impact on humanity with projects like environmental conservation, medical research, and education all being amplified by this new level of coordination and collaboration. And this is just the tip of the iceberg, as this new technology could open the door to even more innovative solutions to some of the world's most pressing problems. This is an opportunity to make real progress and change the world in ways we never thought possible. **Get ready, the future is here!** diff --git a/src/motoko_theory/appendix-2/APPENDIX-2.MD b/src/motoko_theory/appendix-2/APPENDIX-2.MD index 9c7c13f..0d938d6 100644 --- a/src/motoko_theory/appendix-2/APPENDIX-2.MD +++ b/src/motoko_theory/appendix-2/APPENDIX-2.MD @@ -26,7 +26,7 @@ The proposals that can be voted on by the **NNS** (**Network Nervous System**) a - 🌏 Subnet management: proposals related to administering network subnets, such as creating new subnets, adding and removing subnet nodes, or splitting subnets. - 🧑‍⚖️ Governance: proposals related to administering governance, such as motions and configuring certain parameters. -To learn more about the incredible power of the NNS, check out the [Internet Computer Wiki](https://wiki.internetcomputer.org/wiki/Network_Nervous_System). +To learn more about the incredible power of the NNS, check out the [NNS Documentation](https://internetcomputer.org/docs/current/developer-docs/daos/nns/overview). The NNS is constitued of **different canisters**. Each canister is deployed on the same subnet which is also called the [NNS subnet](https://dashboard.internetcomputer.org/subnet/tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe). diff --git a/src/motoko_theory/lesson-1/LESSON-1.MD b/src/motoko_theory/lesson-1/LESSON-1.MD index a1fb3e8..8997c72 100644 --- a/src/motoko_theory/lesson-1/LESSON-1.MD +++ b/src/motoko_theory/lesson-1/LESSON-1.MD @@ -5,7 +5,7 @@ It's... 🥁... **CANISTER**! The Internet Computer is a platform that hosts a large number of applications, all of those applications run smoothly within special containers called **canisters**. -- The Internet Computer is responsible for smoothly and safely run all the canisters deployed on the platform in parallel. +- The Internet Computer is responsible for smoothly and safely running all the canisters deployed on the platform in parallel. - Developers build applications by writing the source code for those canisters. An application can be built into one or several canisters depending on the architecture. - Users will interact with applications by sending messages to canisters. This happens whenever you use an application on the Internet Computer and interact with it - a few examples of such interactions are: - When you post on a social network. @@ -25,12 +25,12 @@ Before we move on to Motoko - we actually need to explain another term: **WebAss If we zoom inside, a canister is composed of: - A **WebAssembly module** which is a piece of compiled code from languages such as Rust or Motoko. This is the code that is installed in the canister and is ultimately running. -- A **WebAssembly memory** - also called memory pages. This is where the state of the canister is stored and files are stored (photos, videos, tokens...). Code runs by the WebAssembly module will modify the memory. +- A **WebAssembly memory** - also called memory pages. This is where the state of the canister is stored and files are stored (photos, videos, tokens...). Code ran by the WebAssembly module will modify the memory.

What is WebAssembly ?

-WebAssembly is a low-level binary format for executing code in multiples environments (browsers, cloud platform, smart devices, virtual machine..). The main benefits of using WebAssembly are, +WebAssembly is a low-level binary format for executing code in multiple environments (browsers, cloud platform, smart devices, virtual machine..). The main benefits of using WebAssembly are, - **WebAssembly** supports code written in multiple languages (C, C++, Rust, Motoko) making it a versatile solution for developers. - **WebAssembly** code is portable and can run on almost any device. You write it once and you can run it everywhere! @@ -48,7 +48,7 @@ The only problem with **WebAssembly** is that it's a low-level language and it p That's why the [DFINITY Foundation](https://dfinity.org/) has introduced a new language called **Motoko**, which is a programming language specifically designed for creating decentralized applications (dApps) on the Internet Computer. Since Motoko code can directly be compiled into **WebAssembly**, it is an incredible language to build on the Internet Computer. Motoko is a high-level language, that is easy to use. You write in Motoko and then it compiles for you in WebAssembly.

-

In Motoko the code is spun, Into WebAssembly it does run.

+

In Motoko the code is spun into WebAssembly.

> It's worth noting that WebAssembly, was co-designed by [Andreas Rossberg](https://github.com/rossberg), who joined the DFINITY Foundation early in 2017 to work on its canister smart contract execution environment and is also the original designer of the Motoko language. The standard is maintained by the [World Wide Web Consortium](https://www.w3.org/). @@ -108,7 +108,7 @@ actor { }; ```` -An **actor** is how a canister is represented and abstracted in **Motoko**. This terms comes from the [Actor model](https://en.wikipedia.org/wiki/Actor_model) which is a way to write computer programs that can handle many tasks at the same time. It does this by treating **actors** as the basic building blocks of a program.
+An **actor** is how a canister is represented and abstracted in **Motoko**. This term comes from the [Actor model](https://en.wikipedia.org/wiki/Actor_model) which is a way to write computer programs that can handle many tasks at the same time. It does this by treating **actors** as the basic building blocks of a program.
An actor is a small computer program that can receive messages, do some work and then send messages to other actors. Actors can also create new actors and control them. All the actors talk to each other by sending messages. Since all interaction between actors is done via message passing, this allows for very high levels of concurrency and parallelism, making it well-suited for distributed systems. In that regards, **the Internet Computer is a distributed computer where each program is a canister !** Since canisters have been implemented to follow the actor model - you won't be surprised to learn that canisters: @@ -120,7 +120,7 @@ Since canisters have been implemented to follow the actor model - you won't be s

-

A canister receives a message, execute it, and possibilty send other messages to other canisters (or even create new ones) in response.

+

A canister receives a message, executes it, and possibilty send other messages to other canisters (or even create new ones) in response.

Let's now consider the following actor: ```motoko @@ -149,7 +149,7 @@ Have you noticed the `query` keyword in the previous example? ### Update calls Update calls are used when the user wants to modify the state of a canister. To ensure the integrity of the Internet Computer, these calls must be processed through consensus and by all nodes, which results in a delay of around 1-2 seconds. An update call would be used in the following situations: -- Posting on a social media, such as [DSCVR](https://dscvr.one/). +- Posting on social media, such as [DSCVR](https://dscvr.one/). - Sending a message on a messaging application, such as [OpenChat](https://oc.app/). - Liking or sharing a content on [Distrikt](https://az5sd-cqaaa-aaaae-aaarq-cai.ic0.app/). - Buying a NFT on [Entrepot](https://entrepot.app/). diff --git a/src/motoko_theory/lesson-10/LESSON-10.MD b/src/motoko_theory/lesson-10/LESSON-10.MD index bf64fad..78afafd 100644 --- a/src/motoko_theory/lesson-10/LESSON-10.MD +++ b/src/motoko_theory/lesson-10/LESSON-10.MD @@ -6,7 +6,7 @@ Whether you are interacting with the Internet Computer using [Internet Identity]

-- A **private key**, which grants you access to all the ICPs you own, allows you to manage canisters, and enables you to access your identity across various applications. +- A **private key**, which grants you access to all the ICP tokens you own, allows you to manage canisters, and enables you to access your identity across various applications. - A **public key**, from which your **principal** is derived. ## Managing identities with dfx diff --git a/src/motoko_theory/lesson-11/LESSON-11.MD b/src/motoko_theory/lesson-11/LESSON-11.MD index ba187b3..bf2f65c 100644 --- a/src/motoko_theory/lesson-11/LESSON-11.MD +++ b/src/motoko_theory/lesson-11/LESSON-11.MD @@ -42,7 +42,7 @@ public type Invoice = { ## Calling an actor by reference. -The most straighforward way to call another canister it's **by reference**. This technique will always work, whether you are working locally or on mainnet but it requires two informations about the canister you want to call: +The most straighforward way to call another canister is **by reference**. This technique will always work, whether you are working locally or on mainnet but it requires two things about the canister you want to call: 1. The canister id. 2. The interface of the canister (at least partially). @@ -75,7 +75,7 @@ let invoiceCanister = actor("rrkah-fqaaa-aaaaa-aaaaq-ca") : actor { ## Importing locally > For this section, check the source code in [ADD LINK]. -> When you a working locally, assuming that you canister is defined in `dfx.json` as follows. +> When you are working locally, assuming that your canister is defined in `dfx.json` as follows. ```json { @@ -128,7 +128,7 @@ Before calling another canisters, you might want to check its interface. To find 3. Scroll down through the list of methods until you reach the **Canister Interface** section.

-4. Here, you can view a list of all public types used and the interface of the service, that list all public methods. +4. Here, you can view a list of all public types used and the interface of the service, that lists all public methods.

5. You can use the different tabs to see the interface in different languages (**Candid**, **Motoko**, **Rust**, **JavaScript**, **Typescript**). @@ -141,7 +141,7 @@ A canister processes its messages sequentially (one at-a-time), with each messag Suppose you are **canister A** and you are calling **canister B**. The following sequence of events occurs: -- **Canister A** receives a message, which triggers a function. This function then initiates an inter-canister call which result in canister A sending a message to **canister B**. +- **Canister A** receives a message, which triggers a function. This function then initiates an inter-canister call which results in canister A sending a message to **canister B**. - Canister B already has a queue of 2 messages, so the new message is added to the end of the queue. - Canister A continues to receive and process additional messages, while canister B processes it's messages one-at-a time. - Canister B eventually sends a response to canister A. The message is added to the queue of canister A. @@ -154,7 +154,7 @@ As you can see, between the instant you call a canister and the moment you recei ### Intra-Subnet -When canister A and canister B belong to the same subnet, consensus is not required for inter-canister calls. This is because the inter-canister call results from a message being processed has already been agreed upon during the previous consensus round. There is an upper limit to the amount of computation that can be handled within a single consensus round; however, assuming this limit is not surpassed, **canister A will** receive its response in the same round. +When canister A and canister B belong to the same subnet, consensus is not required for inter-canister calls. This is because the inter-canister call results from a message being processed that had already been agreed upon during the previous consensus round. There is an upper limit to the amount of computation that can be handled within a single consensus round; however, assuming this limit is not surpassed, **canister A will** receive its response in the same round. ### Inter-Subnet diff --git a/src/motoko_theory/lesson-12/LESSON-12.MD b/src/motoko_theory/lesson-12/LESSON-12.MD index d904dd5..4db7f6f 100644 --- a/src/motoko_theory/lesson-12/LESSON-12.MD +++ b/src/motoko_theory/lesson-12/LESSON-12.MD @@ -18,13 +18,13 @@ A canister has access to two types of memories: ## Stable variables. When a canister is upgraded, the state is lost by default. This means all data application data will be lost, unless it's handled to persist when the canister is upgraded.
-This can be achieved by storing the data in stable variables, which will persist upgrades. To declare a variable as stable we use the `stable` keyword. +This can be achieved by storing the data in stable variables, which will persist during upgrades. To declare a variable as stable we use the `stable` keyword. ```motoko stable var m : Int = 0; ``` -The value of `m` will persits upgrades and not be lost. +The value of `m` will persist upgrades and not be lost. A stable variable is stored in the stable memory. ## Stable types. @@ -135,9 +135,9 @@ to getDiploma(p : Principal, bootcampYear: ?Nat) -> async ?Diploma; ``` -Would not cause an issue, when reading messages from old clients, who do not pass that argument, a `null` value is assumed. +Would not cause an issue. When reading messages from old clients, who do not pass that argument, a `null` value is assumed. -> In the following, all types and interfaces are exprimed in Candid format. +> In the following examples, all types and interfaces are expressed in Candid format. Let's look at more examples of what can and can't be done. Imagine the following service @@ -163,7 +163,7 @@ add : (int) -> (); This is possible because every `nat` is also an `int`. If a client provides a `Nat` it will be compatible with the new expected type. We say that `int` is a supertype of `nat`. However evolving the other way wouldn't be possible since all `int` are not `nat`. -Additionally the function `add` and `substract` could evolve from +Additionally the function `add` and `subtract` could evolve from ``` add : (nat) -> (); @@ -184,7 +184,7 @@ To safely upgrade a canister, follow those rules: - New methods can freely be added. - Existing methods can return additional values. Old clients will simply ignore additional values. - Existing methods can shorten their parameter list. Old clients will send the extra argument(s) but they will be ignored. -- Exisiting methods can only add optional types as new parameters (type `opt`). When reading messages from old clients, who do not pass that argument, a `null` value is assumed. +- Existing methods can only add optional types as new parameters (type `opt`). When reading messages from old clients, who do not pass that argument, a `null` value is assumed. - Existing parameter types may be changed, but only to a `supertype` of the previous type. For instance a `nat` parameter can be changed to a `int`. - Existing result types may be changed, but only to a `subtype` of the previous type. For instance an `int` result can be changed to a `nat`. @@ -226,7 +226,7 @@ The stable signature is used to automatically check type compatibility before an The Motoko compiler embeds the **Candid interface** and **stable signature** of a canister as canister metadata, recorded in additional Wasm custom sections of a compiled binary. -This metadata can be selectively exposed by the IC and used by tools such as `dfx` to verify upgrade. +This metadata can be selectively exposed by the IC and used by tools such as `dfx` to verify the upgrade. ``` $ dfx canister metadata [OPTIONS] diff --git a/src/motoko_theory/lesson-13/LESSON-13.MD b/src/motoko_theory/lesson-13/LESSON-13.MD index 5b91208..df9272e 100644 --- a/src/motoko_theory/lesson-13/LESSON-13.MD +++ b/src/motoko_theory/lesson-13/LESSON-13.MD @@ -39,7 +39,7 @@ To serve web content on the Internet Computer, a canister should have a method t ## The `http_request` query method -Once the boundary node has received the request. It will encode it into Candid and automatically call the `http_request` method of the canister. reachable by browsers, you need to implement an `http_request` query method as part of the public interface of your actor.
+Once the boundary node has received the request. It will encode it into Candid and automatically call the `http_request` method of the canister, reachable by browsers. You need to implement an `http_request` query method as part of the public interface of your actor.
```motoko import Text "mo:base/Text"; diff --git a/src/motoko_theory/lesson-2/LESSON-2.MD b/src/motoko_theory/lesson-2/LESSON-2.MD index f093c28..71f095b 100644 --- a/src/motoko_theory/lesson-2/LESSON-2.MD +++ b/src/motoko_theory/lesson-2/LESSON-2.MD @@ -110,7 +110,7 @@ To declare a function in Motoko, you must specify the types of the arguments and 1. Assign the value of `count` to the value of `n`. 2. Return the current value of `count`. -Motoko allows to omit the `return` at the end of the body of the function, because a block always evaluates to its last expression. Which means, we could rewrite the code in the following way and it would still be valid: +Motoko allows the `return` at the end of the body of a function to be omitted, because a block always evaluates to its last expression. Which means, we could rewrite the code in the following way and it would still be valid: ```motoko public func setCount(n : Nat) : async Nat { diff --git a/src/motoko_theory/lesson-3/LESSON-3.MD b/src/motoko_theory/lesson-3/LESSON-3.MD index 546b8c6..8e7e8a3 100644 --- a/src/motoko_theory/lesson-3/LESSON-3.MD +++ b/src/motoko_theory/lesson-3/LESSON-3.MD @@ -60,7 +60,7 @@ let b : Nat = 3 % 2; // 1 ## ➖ Int. -Integers represents whole numbers that can be positive or negative. The same mathematical operations seen earlier (addition, multiplication, subtraction, division, and modulo) can be performed on both `Int` and `Nat`. +Integers represent whole numbers that can be positive or negative. The same mathematical operations seen earlier (addition, multiplication, subtraction, division, and modulo) can be performed on both `Int` and `Nat`. ```motoko let i : Int = -3; diff --git a/src/motoko_theory/lesson-4/LESSON-4.MD b/src/motoko_theory/lesson-4/LESSON-4.MD index 8284ee8..90ab302 100644 --- a/src/motoko_theory/lesson-4/LESSON-4.MD +++ b/src/motoko_theory/lesson-4/LESSON-4.MD @@ -220,6 +220,6 @@ After importing the Candid interface we can now use the public backend service, const greeting = await greet_backend.greet(name); ``` -The update function `greet()` is called with the name as a parameter, which will return the greeting message. The call is asynchronous so an **await** is added so the front end is waiting for a response before moving on. +The update function `greet()` is called with the name as a parameter, which will return the greeting message. The call is asynchronous so an **await** is added to make the front end wait for a response before moving on. Several agents are developed by both DFINITY and the community to easily integrate the Candid interface in different programming languages. See the [documentation](https://internetcomputer.org/docs/current/developer-docs/build/agents/) for a list of the available agents. diff --git a/src/motoko_theory/lesson-6/LESSON-6.MD b/src/motoko_theory/lesson-6/LESSON-6.MD index 96b48f3..6cac237 100644 --- a/src/motoko_theory/lesson-6/LESSON-6.MD +++ b/src/motoko_theory/lesson-6/LESSON-6.MD @@ -38,7 +38,7 @@ let names : [Text] = ["Emma Smith", "Olivia Johnson", "Ava Brown", "Isabella Dav let size = names.size(); // 4 ``` -To loop over an array we can use the `.vals()` iterator. Here is an example that would gave us the sum of an array. +To loop over an array we can use the `.vals()` iterator. Here is an example that would give us the sum of an array. ```motoko actor { @@ -54,9 +54,9 @@ actor { }; ``` -In Motoko, arrays have a fixed size that is determined when the array is created. This means that the size cannot be increased later on. To add a new element to an array, a new array must be created and all of the existing elements must be transferred to the new array manually. This makes `Array` not really adapted for datastructures that needs be constantly updated. +In Motoko, arrays have a fixed size that is determined when the array is created. This means that the size cannot be increased later on. To add a new element to an array, a new array must be created and all of the existing elements must be transferred to the new array manually. This makes `Array` not really suitable for data structures that need to be constantly updated. -Concatenating two arrays to an `Array` can be done using `Array.append()` - a function from the [Array](https://internetcomputer.org/docs/current/motoko/main/base/Array) module. +Concatenating two arrays to one `Array` can be done using `Array.append()` - a function from the [Array](https://internetcomputer.org/docs/current/motoko/main/base/Array) module. ```motoko let array1 = [1, 2, 3]; @@ -64,7 +64,7 @@ let array2 = [4, 5, 6]; Array.append(array1, array2) // [1, 2, 3, 4, 5, 6]; ``` -However, this function is **depreceated**. It is recommended to avoid it in production code. That's because as we've said before it is impossible to simply add elements to an array. Under the hood, `Array.append()` will create a new array and copy the values of the two existing arrays which is not efficient. +However, this function is **deprecated**. It is recommended to avoid it in production code. That's because as we've said before it is impossible to simply add elements to an array. Under the hood, `Array.append()` will create a new array and copy the values of the two existing arrays which is not efficient. ## 🥞 Buffer @@ -211,7 +211,7 @@ To add a new entry to the `map` we can use the `.put()` method. map.put(principal, student); ``` -This will insert the value `student` with key `principal` and overwrites any previous value. We can use this method to create a `register` function that students would need to call and provide all their relevant informations. +This will insert the value `student` with key `principal` and overwrite any previous value. We can use this method to create a `register` function that students would need to call and provide all their relevant information. ```motoko public shared ({ caller }) func register(name : Text, age : Nat, favoriteLanguage : Text) : async () { @@ -235,7 +235,7 @@ Once a value has been inserted in the `map`, we can access it using the `.get()` map.get(principal); ``` -This will return an optional value `?Student` associated with the provided principal. We can use this method to create a `getStudent` `query` function that would return information on students. +This will return an optional value `?Student` associated with the provided principal. We can use this method to create a `getStudent` `query` function that returns information about students. ```motoko public query func getStudent(p : Principal) : async ?Student { diff --git a/src/motoko_theory/lesson-7/LESSON-7.MD b/src/motoko_theory/lesson-7/LESSON-7.MD index b4aa8a7..af610b1 100644 --- a/src/motoko_theory/lesson-7/LESSON-7.MD +++ b/src/motoko_theory/lesson-7/LESSON-7.MD @@ -27,7 +27,7 @@ Objects are more readable than tuples since each field has a name. The different - name which is a `Text` indicating the name of the student. - age which is a `Nat` indicating the age of the student. - favoriteLanguage which is a `Text` indicating the favorite programming language of the student. -- graduate which is a `Bool` indicating if the students has already graduated from the Motoko Bootcamp. +- graduate which is a `Bool` indicating whether the student graduated from the Motoko Bootcamp. ```motoko let student = { @@ -64,7 +64,7 @@ let student = { student.age += 1; ``` -Objects are often assigned types. In this case we need to create **custom type**. Let's define a type called `Student` which corresponds the object we've previously created. +Objects are often assigned types. In this case we need to create a **custom type**. Let's define a type called `Student` which corresponds to the object we've previously created. ```motoko type Student = { diff --git a/src/motoko_theory/lesson-8/LESSON-8.MD b/src/motoko_theory/lesson-8/LESSON-8.MD index 0bd9ada..5a555c6 100644 --- a/src/motoko_theory/lesson-8/LESSON-8.MD +++ b/src/motoko_theory/lesson-8/LESSON-8.MD @@ -150,9 +150,9 @@ We will encounter the following error: `Error in file Main.mo:3:28 shared functi A very important rule to remember: **every mutable state is always private to an actor.** -To put it short - anything that you can modify in your the state of your canister should be consider private and you won't be able to share it with other actors.

-

If it's a var your can't share it outside!

+

If it's a var you can't share it outside!

> For a complete overview of all the shared types, [refer to the Motoko Book](https://web3.motoko-book.dev/internet-computer-programming-concepts/async-data/shared-types.html?highlight=Shared%20types#shared-types). diff --git a/src/motoko_theory/lesson-9/LESSON-9.MD b/src/motoko_theory/lesson-9/LESSON-9.MD index 2f7ac2f..ddd1f8d 100644 --- a/src/motoko_theory/lesson-9/LESSON-9.MD +++ b/src/motoko_theory/lesson-9/LESSON-9.MD @@ -69,7 +69,7 @@ Using `Result` to report errors in your API offers a significant benefit: it all A **trap** is a type of error that occurs during the execution of a message and cannot be resolved. The most common causes of traps are: -- Division by zero. +- Division by zero ```motoko let a : Nat = 5; @@ -77,7 +77,7 @@ let b : Nat = 0; let c = a / b; ``` -- Index is out of bounds. +- Index out of bounds ```motoko let names : [Text] = []; @@ -91,7 +91,7 @@ assert(false); In some situations, it can be useful to trap on purpose, with a defined message. -The best way to do so if to use the `Debug.trap()` method from the [Debug library](https://internetcomputer.org/docs/current/motoko/main/base/Debug) which allows you to pass an error message along the `trap`. +The best way to do so is to use the `Debug.trap()` method from the [Debug library](https://internetcomputer.org/docs/current/motoko/main/base/Debug) which allows you to pass an error message along the `trap`. ```motoko func trap(errorMessage : Text) : None @@ -168,7 +168,7 @@ The `try/catch` pattern in Motoko is particularly useful when you are attempting - The function being called traps, either due to a programming error or because it has run out of resources. - The function being called throws an error that needs to be handled. -Assuming this is our canister A - deployed with canister id: +Assuming this is our canister A - deployed with the canister id `xxx` ```motoko actor {