From b5f0ea919066f5470e453b74229965e80ad07d32 Mon Sep 17 00:00:00 2001 From: Tim McMackin Date: Thu, 15 Feb 2024 11:54:44 -0500 Subject: [PATCH 1/3] Update to use separate entrypoints (#314) --- docs/smart-contracts/languages/ligo.md | 72 +++++++++++++------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/docs/smart-contracts/languages/ligo.md b/docs/smart-contracts/languages/ligo.md index 9da88a75c..9670dc729 100644 --- a/docs/smart-contracts/languages/ligo.md +++ b/docs/smart-contracts/languages/ligo.md @@ -1,7 +1,7 @@ --- title: LIGO last_update: - date: 29 June 2023 + date: 8 February 2024 --- LIGO is a functional programming language that is intended to be both user-friendly and to avoid patterns that make formal verification difficult. @@ -18,57 +18,55 @@ To learn LIGO, see these tutorials: - [Deploy a smart contract with CameLIGO](../../tutorials/smart-contract/cameligo) - [Deploy a smart contract with JsLIGO](../../tutorials/smart-contract/jsligo) -Let's define a LIGO contract in the two flavours above. +Here are examples of straightforward LIGO contracts. +Each contract stores an integer and provides entrypoints that increase or decrease the integer or reset it to zero. ## CameLIGO -``` +```ocaml type storage = int -type parameter = - Increment of int -| Decrement of int -| Reset +type returnValue = operation list * storage + +// Increment entrypoint +[@entry] let increment (delta : int) (store : storage) : returnValue = + [], store + delta -type return = operation list * storage +// Decrement entrypoint +[@entry] let decrement (delta : int) (store : storage) : returnValue = + [], store - delta -let main (action, store : parameter * storage) : return = - [], - (match action with - Increment n -> store + n - | Decrement n -> store - n - | Reset -> 0) +// Reset entrypoint +[@entry] let reset (() : unit) (_ : storage) : returnValue = + [], 0 ``` ## JsLIGO -``` -type storage = int; - -type parameter = - ["Increment", int] -| ["Decrement", int] -| ["Reset"]; - -type return_ = [list, storage]; - -let main = (action: parameter, store: storage) : return_ => { - return [ - list([]), - match(action, { - Increment: n => store + n, - Decrement: n => store - n, - Reset: () => 0 - }) - ]; -}; +```ts +namespace Counter { + type storage = int; + type returnValue = [list, storage]; + + // Increment entrypoint + @entry + const increment = (delta : int, store : storage) : returnValue => + [list([]), store + delta]; + + // Decrement entrypoint + @entry + const decrement = (delta : int, store : storage) : returnValue => + [list([]), store - delta]; + + // Reset entrypoint + @entry + const reset = (_p : unit, _s : storage) : returnValue => + [list([]), 0]; +} ``` -This LIGO contract accepts the following LIGO expressions: `Increment(n)`, `Decrement(n)` and `Reset`. Those serve as `entrypoint` identification. - ## Further reading - [LIGO documentation](https://ligolang.org/docs/intro/introduction?lang=jsligo) - [LIGO tutorials](https://ligolang.org/docs/tutorials/getting-started?lang=jsligo) - [OpenTezos](https://opentezos.com/ligo) - From 61a13d51a31d5816f9ed1e02d45069365c724b42 Mon Sep 17 00:00:00 2001 From: Tim McMackin Date: Thu, 15 Feb 2024 13:56:44 -0500 Subject: [PATCH 2/3] Nairobi protocol (#322) * add nairobi to amendment history * updat framing information --- .../governance/amendment-history.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/architecture/governance/amendment-history.md b/docs/architecture/governance/amendment-history.md index 26a64eb2d..f36a8aef4 100644 --- a/docs/architecture/governance/amendment-history.md +++ b/docs/architecture/governance/amendment-history.md @@ -2,10 +2,11 @@ title: History of amendments authors: 'Thomas Zoughebi, Aymeric Bethencourt, and Maxime Fernandez' last_update: - date: 30 June 2023 + date: 14 February 2024 --- -As presented in [Governance](../governance), the Tezos blockchain is constantly evolving, through new amendments. In this chapter, we will present an overview of past proposals and the reasons for their approval or disapproval. +As presented in [Governance](../governance), the Tezos blockchain is constantly evolving, through new amendments. +These are the past proposals to amend the Tezos protocol. ## [Athens](https://tezos.gitlab.io/protocols/004_Pt24m4xi.html) (Pt24m4xiP) @@ -196,8 +197,14 @@ Mumbai's main changes are: For more information, see the blog post from [Nomadic Labs](https://research-development.nomadic-labs.com/mumbai-announcement.html) and the [reference documentation](https://tezos.gitlab.io/protocols/016_mumbai.html). -## What have we learned so far? +## [Nairobi](https://tezos.gitlab.io/protocols/017_nairobi.html) (PtNairob) -In this chapter, we went through the past proposals' history and how and why they were approved or rejected. +*Nairobi* was autonomously [activated](https://tzstats.com/3760129) in June 2023. -In the next chapter, we will see the details of operations costs and various rewards calculations. +Nairobi's main changes are: + +* Increased TPS thanks to a new gas model for signature verification. +* Renaming endorsements to attestations to specify the behavior of these consensus operations. +* Smart Rollups can now be aware of protocol updates happening on the L1. + +For more information, see the blog post from [Nomadic Labs](https://research-development.nomadic-labs.com/nairobi-announcement.html) and the [reference documentation](https://tezos.gitlab.io/protocols/017_nairobi.html). From 135c9019b4696acf194f67be0e8d81202754ab5b Mon Sep 17 00:00:00 2001 From: Tim McMackin Date: Fri, 16 Feb 2024 11:29:15 -0500 Subject: [PATCH 3/3] Smart contract clarifications (#326) * typos * Warning about the contract address * Clarification * endpoint -> entrypoint --- docs/tutorials/smart-contract/archetype.md | 8 ++++---- docs/tutorials/smart-contract/cameligo.mdx | 20 ++++++++++++-------- docs/tutorials/smart-contract/jsligo.mdx | 20 ++++++++++++-------- docs/tutorials/smart-contract/smartpy.mdx | 10 +++++----- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/docs/tutorials/smart-contract/archetype.md b/docs/tutorials/smart-contract/archetype.md index 035ad6cfd..3a8c42bc6 100644 --- a/docs/tutorials/smart-contract/archetype.md +++ b/docs/tutorials/smart-contract/archetype.md @@ -44,9 +44,9 @@ For more information about Archetype, see https://archetype-lang.org/. The contract that you deploy in this tutorial stores a single integer. It provides entrypoints that clients can call to change the value of that integer: -- The `increment` endpoint accepts an integer as a parameter and adds that integer to the value in storage -- The `decrement` endpoint accepts an integer as a parameter and subtracts that integer from the value in storage -- The `reset` endpoint takes no parameters and resets the value in storage to 0 +- The `increment` entrypoint accepts an integer as a parameter and adds that integer to the value in storage +- The `decrement` entrypoint accepts an integer as a parameter and subtracts that integer from the value in storage +- The `reset` entrypoint takes no parameters and resets the value in storage to 0 After you deploy the contract, you or any other user can call it through the command line or a distributed application (dApp). @@ -320,4 +320,4 @@ Now the contract is running on the Tezos blockchain. You or any other user can call it from any source that can send transactions to Tezos, including command-line clients, dApps, and other contracts. If you want to continue working with this contract, try creating a dApp to call it from a web application, similar to the dApp that you create in the tutorial [Build a simple web application](../build-your-first-app/). -You can also try adding your own endpoints and originating a new contract, but you cannot update the existing contract after it is deployed. +You can also try adding your own entrypoints and originating a new contract, but you cannot update the existing contract after it is deployed. diff --git a/docs/tutorials/smart-contract/cameligo.mdx b/docs/tutorials/smart-contract/cameligo.mdx index 77524c426..c9edd97e1 100644 --- a/docs/tutorials/smart-contract/cameligo.mdx +++ b/docs/tutorials/smart-contract/cameligo.mdx @@ -41,15 +41,16 @@ A smart contract has these parts: The contract that you deploy in this tutorial stores a single integer. It provides entrypoints that clients can call to change the value of that integer: -- The `increment` endpoint accepts an integer as a parameter and adds that integer to the value in storage -- The `decrement` endpoint accepts an integer as a parameter and subtracts that integer to the value in storage -- The `reset` endpoint takes no parameters and resets the value in storage to 0 +- The `increment` entrypoint accepts an integer as a parameter and adds that integer to the value in storage +- The `decrement` entrypoint accepts an integer as a parameter and subtracts that integer from the value in storage +- The `reset` entrypoint takes no parameters and resets the value in storage to 0 After you deploy the contract, you or any other user can call it from a variety of Tezos clients and decentralized applications (dApps). ## Creating and funding a wallet To deploy and work with the contract, you need a wallet and some tez tokens. +You can get test tokens for free on the Ghostnet test network: 1. Install a Tezos-compatible wallet. Which wallet you install is up to you and whether you want to install a wallet on your computer, in a browser extension, or as a mobile app. @@ -128,7 +129,7 @@ You can work with LIGO code in any IDE, but this online IDE keeps you from havin type storage = int ``` -1. Add this code to define the return type for the endpoints. +1. Add this code to define the return type for the entrypoints. Tezos entrypoints return two values: a list of other operations to call and the new value of the contract's storage. ```ocaml @@ -202,7 +203,7 @@ Before you can deploy the contract to Tezos, you must compile it to Michelson, t At the bottom of the window, the Result field shows the response `(LIST_EMPTY(), 42)`. This response means that the contract did not call any other contracts, so the list of operations is empty. Then it shows the new value of the storage. - You can test the decrement and reset functions in the same way. + You can test the decrement function in the same way. If you see any errors, make sure that the code of your contract matches the code in the previous section. 1. Test the `Reset` entrypoint in the same way, but pass `unit` as the input parameter and any integer in the storage field. @@ -243,7 +244,10 @@ You can ignore this warning because you can set the initial storage now. When the contract is deployed, the Deploy contract window shows the address at the bottom of the window. 1. Copy the address of the deployed contract, which starts with `KT1`. -It will not be shown again. + +:::warning +Copy the contract address now, because it will not be shown again. +::: Now you can call the contract from any Tezos client, including web applications and command-line applications like [The Octez client](../../developing/octez-client). @@ -260,7 +264,7 @@ It also allows you to call the contract. The block explorer, showing information about the contract -1. Try calling one of the endpoints: +1. Try calling one of the entrypoints: 1. Go to the **Storage** tab and check the current state of the storage, which should be the integer that you put in the Deploy window. @@ -289,4 +293,4 @@ Now the contract is running on the Tezos blockchain. You or any other user can call it from any source that can send transactions to Tezos, including Octez, dApps, and other contracts. If you want to continue working with this contract, try creating a dApp to call it from a web application, similar to the dApp that you create in the tutorial [Build a simple web application](../build-your-first-app/). -You can also try adding your own endpoints and originating a new contract, but you cannot update the existing contract after it is deployed. +You can also try adding your own entrypoints and originating a new contract, but you cannot update the existing contract after it is deployed. diff --git a/docs/tutorials/smart-contract/jsligo.mdx b/docs/tutorials/smart-contract/jsligo.mdx index 2d98625d1..c1a80e50a 100644 --- a/docs/tutorials/smart-contract/jsligo.mdx +++ b/docs/tutorials/smart-contract/jsligo.mdx @@ -41,15 +41,16 @@ A smart contract has these parts: The contract that you deploy in this tutorial stores a single integer. It provides entrypoints that clients can call to change the value of that integer: -- The `increment` endpoint accepts an integer as a parameter and adds that integer to the value in storage -- The `decrement` endpoint accepts an integer as a parameter and subtracts that integer to the value in storage -- The `reset` endpoint takes no parameters and resets the value in storage to 0 +- The `increment` entrypoint accepts an integer as a parameter and adds that integer to the value in storage +- The `decrement` entrypoint accepts an integer as a parameter and subtracts that integer from the value in storage +- The `reset` entrypoint takes no parameters and resets the value in storage to 0 After you deploy the contract, you or any other user can call it from a variety of Tezos clients and decentralized applications (dApps). ## Creating and funding a wallet To deploy and work with the contract, you need a wallet and some tez tokens. +You can get test tokens for free on the Ghostnet test network: 1. Install a Tezos-compatible wallet. Which wallet you install is up to you and whether you want to install a wallet on your computer, in a browser extension, or as a mobile app. @@ -136,7 +137,7 @@ You can work with LIGO code in any IDE, but this online IDE keeps you from havin type storage = int; ``` -1. Add this code to define the return type for the endpoints. +1. Add this code to define the return type for the entrypoints. Tezos entrypoints return two values: a list of other operations to call and the new value of the contract's storage. ```ts @@ -217,7 +218,7 @@ Before you can deploy the contract to Tezos, you must compile it to Michelson, t At the bottom of the window, the Result field shows the response `(LIST_EMPTY(), 42)`. This response means that the contract did not call any other contracts, so the list of operations is empty. Then it shows the new value of the storage. - You can test the decrement and reset functions in the same way. + You can test the decrement function in the same way. If you see any errors, make sure that the code of your contract matches the code in the previous section. 1. Test the `Reset` entrypoint in the same way, but pass `unit` as the input parameter and any integer in the storage field. @@ -258,7 +259,10 @@ You can ignore this warning because you can set the initial storage now. When the contract is deployed, the Deploy contract window shows the address at the bottom of the window. 1. Copy the address of the deployed contract, which starts with `KT1`. -It will not be shown again. + +:::warning +Copy the contract address now, because it will not be shown again. +::: Now you can call the contract from any Tezos client, including web applications and command-line applications like [The Octez client](../../developing/octez-client). @@ -275,7 +279,7 @@ It also allows you to call the contract. The block explorer, showing information about the contract -1. Try calling one of the endpoints: +1. Try calling one of the entrypoints: 1. Go to the **Storage** tab and check the current state of the storage, which should be the integer that you put in the Deploy window. @@ -304,4 +308,4 @@ Now the contract is running on the Tezos blockchain. You or any other user can call it from any source that can send transactions to Tezos, including Octez, dApps, and other contracts. If you want to continue working with this contract, try creating a dApp to call it from a web application, similar to the dApp that you create in the tutorial [Build a simple web application](../build-your-first-app/). -You can also try adding your own endpoints and originating a new contract, but you cannot update the existing contract after it is deployed. +You can also try adding your own entrypoints and originating a new contract, but you cannot update the existing contract after it is deployed. diff --git a/docs/tutorials/smart-contract/smartpy.mdx b/docs/tutorials/smart-contract/smartpy.mdx index a51717c5e..d3b3a8320 100644 --- a/docs/tutorials/smart-contract/smartpy.mdx +++ b/docs/tutorials/smart-contract/smartpy.mdx @@ -46,8 +46,8 @@ A smart contract has these parts: The contract that you deploy in this tutorial stores a string value. It provides entrypoints that clients can call to change the value of that string: -- The `replace` endpoint accepts a new string as a parameter and stores that string, replacing the existing string. -- The `append` endpoint accepts a new string as a parameter and appends it to the existing string. +- The `replace` entrypoint accepts a new string as a parameter and stores that string, replacing the existing string. +- The `append` entrypoint accepts a new string as a parameter and appends it to the existing string. After you deploy the contract, you or any other user can call it from various sources, including web applications, other contracts, and the Octez command-line client. @@ -154,7 +154,7 @@ You can work with SmartPy code in any IDE, but this online IDE keeps you from ha scenario.verify(contract.data.greeting == "Hi, there!") ``` - These tests run automatically on compilation to verify that the replace and append endpoints work. + These tests run automatically on compilation to verify that the replace and append entrypoints work. For more information about SmartPy and tests, see the [SmartPy documentation](https://smartpy.io/). The SmartPy online IDE looks like this: @@ -261,7 +261,7 @@ It will not be shown again. The block explorer, showing information about the contract -1. Try calling one of the endpoints: +1. Try calling one of the entrypoints: 1. Go to the **Storage** tab and check the current state of the storage. If you just originated the contract, the storage is "Hello" because that's the value set in the smart contract code. @@ -291,4 +291,4 @@ Now the contract is running on the Tezos blockchain. You or any other user can call it from any source that can send transactions to Tezos, including Octez, dApps, and other contracts. If you want to continue working with this contract, try creating a dApp to call it from a web application, similar to the dApp that you create in the tutorial [Build a simple web application](../build-your-first-app/). -You can also try adding your own endpoints and originating a new contract, but you cannot update the existing contract after it is deployed. +You can also try adding your own entrypoints and originating a new contract, but you cannot update the existing contract after it is deployed.