diff --git a/aptos-move/move-examples/move-tutorial/README.md b/aptos-move/move-examples/move-tutorial/README.md index 67f564b4f9453b..8452c34ecc6b32 100644 --- a/aptos-move/move-examples/move-tutorial/README.md +++ b/aptos-move/move-examples/move-tutorial/README.md @@ -7,7 +7,7 @@ slug: "move-tutorial" Welcome to the Aptos Move Tutorial! This is the original Move language and tools tutorial, independent of a particular network, adapted to use Aptos tooling. Here you will learn basic usage of the Move language and tools for compiling, testing, and verifying Move. -This tutorial does not teach you how to use the existing [Aptos Move frameworks](../../../developer-docs-site/docs/guides/move-guides/index.md) or how to run code on the Aptos network. See the [Aptos developer documentation](https://aptos.dev/tutorials/aptos-quickstarts) for those instructions. +This tutorial does not teach you how to use the existing [Aptos Move frameworks](https://aptos.dev/reference/move) or how to run code on the Aptos network. See the [Aptos developer documentation](../../../developer-docs-site/docs/tutorials/index.md) for those instructions. There are nine steps in total: @@ -35,14 +35,14 @@ You should obtain a copy of the content of the directory in which this `README.m step_1 step_2 step_2_sol step_3 ... ``` -You also need a recent version of the [Aptos CLI](../../../developer-docs-site/docs/cli-tools/aptos-cli-tool/index.md). This tutorial is written using the following version: +You also need a recent version of the [Aptos CLI](../../../developer-docs-site/docs/tools/install-cli/index.md). This tutorial is written using the following version: ```shell > aptos --version aptos 1.0.7 ``` -If you want to use an [IDE](../../../developer-docs-site/docs/guides/move-guides/index.md#ides-for-move) for working through the examples, we recommend CLion/IntelliJ, which has good support for Aptos Move. +If you want to use an IDE for working through the examples, we recommend CLion/IntelliJ, which has good support for Aptos Move. ## Step 1: Writing my first Move module @@ -67,13 +67,13 @@ module 0xCAFE::basic_coin { ``` This is defining a Move -[module](../../../developer-docs-site/docs/guides/move-guides/book/modules-and-scripts.md). Modules are the +[module](../../../developer-docs-site/docs/move/book/modules-and-scripts.md). Modules are the building blocks of Move code, and are defined with a specific address -- the address that the module can be published under. In this case, the `basic_coin` module can be published only under `0xCAFE`. Let's now take a look at the next part of this file where we define a -[struct](../../../developer-docs-site/docs/guides/move-guides/book/structs-and-resources.md) +[struct](../../../developer-docs-site/docs/move/book/structs-and-resources.md) to represent a `Coin` with a given `value`: ``` @@ -100,7 +100,7 @@ module 0xCAFE::basic_coin { ``` Let us take a look at this function and what it is saying: -* It takes a [`&signer`](../../../developer-docs-site/docs/guides/move-guides/book/signer.md) reference ('`&`') -- an +* It takes a [`&signer`](../../../developer-docs-site/docs/move/book/signer.md) reference ('`&`') -- an unforgeable token that represents control over a particular address, and a `value` to mint. * It creates a `Coin` with the given value and stores it under the @@ -122,7 +122,7 @@ aptos move compile * Move code can also live in a number of other places. See the [Move book](../../../developer-docs-site/docs/guides/move-guides/book/packages.md) for more information on the Move package system. -* More information on the `Move.toml` file can also be found in the [Package](../../../developer-docs-site/docs/guides/move-guides/book/packages.md#movetoml) section of the Move book. +* More information on the `Move.toml` file can also be found in the [Package](../../../developer-docs-site/docs/move/book/packages.md#movetoml) section of the Move book. * Move also supports the idea of [named addresses](../../../developer-docs-site/docs/guides/move-guides/book/address.md#named-addresses); Named addresses are a way to parameterize Move source code so that you can compile @@ -132,9 +132,9 @@ aptos move compile [addresses] Somenamed_address = "0xC0FFEE" ``` -* [Structures](../../../developer-docs-site/docs/guides/move-guides/book/structs-and-resources.md) in Move +* [Structures](../../../developer-docs-site/docs/move/book/structs-and-resources.md) in Move can be given different - [abilities](../../../developer-docs-site/docs/guides/move-guides/book/abilities.md) that describe what + [abilities](../../../developer-docs-site/docs/move/book/abilities.md) that describe what can be done with that type. There are four different abilities: - `copy`: Allows values of types with this ability to be copied. - `drop`: Allows values of types with this ability to be popped/dropped. @@ -145,9 +145,9 @@ aptos move compile in global storage and, because it has no other abilities, it cannot be copied, dropped, or stored as a non-key value in storage. So you can't copy coins, and you also can't lose coins by accident! -* [Functions](../../../developer-docs-site/docs/guides/move-guides/book/functions.md) are default +* [Functions](../../../developer-docs-site/docs/move/book/functions.md) are default private, and can also be `public`, - [`public(friend)`](../../../developer-docs-site/docs/guides/move-guides/book/friends.md). + [`public(friend)`](../../../developer-docs-site/docs/move/book/friends.md). A function marked as `entry` can be called as a transaction. * `move_to` is one of the [five different global storage operators](../../../developer-docs-site/docs/guides/move-guides/book/global-storage-operators.md). @@ -291,12 +291,12 @@ method directly from a transaction, you'll want to change its signature to: ``` public entry fun transfer(from: signer, to: address, amount: u64) acquires Balance { ... } ``` -Read more on Move function [visibilities](../../../developer-docs-site/docs/guides/move-guides/book/functions.md#visibility). +Read more on Move function [visibilities](../../../developer-docs-site/docs/move/book/functions.md#visibility).
Comparison with Ethereum/Solidity -In most Ethereum [ERC-20]((https://ethereum.org/en/developers/docs/standards/tokens/erc-20/)) contracts, the balance of each address is stored in a _state variable_ of type +In most Ethereum [ERC-20](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) contracts, the balance of each address is stored in a _state variable_ of type mapping(address => uint256). This state variable is stored in the storage of a particular smart contract. The Ethereum blockchain state might look like this: @@ -348,7 +348,7 @@ is false, then abort the transaction with ``. Here `MODULE_OWNER` an defined at the beginning of the module. The standard library's [`error`] module also defines common error categories we can use. It is important to note that Move is transactional in its execution -- so -if an [abort](../../../developer-docs-site/docs/guides/move-guides/book/abort-and-assert.md) is raised no unwinding of state +if an [abort](../../../developer-docs-site/docs/move/book/abort-and-assert.md) is raised no unwinding of state needs to be performed, as no changes from that transaction will be persisted to the blockchain. [`error` module]: https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/move-stdlib/sources/error.move @@ -385,7 +385,7 @@ fun withdraw(addr: address, amount: u64) : Coin acquires Balance { } ``` At the beginning of the method, we assert that the withdrawing account has enough balance. We then use `borrow_global_mut` -to get a mutable reference to the global storage, and `&mut` is used to create a mutable [reference](../../../developer-docs-site/docs/guides/move-guides/book/references.md) to a field of a +to get a mutable reference to the global storage, and `&mut` is used to create a mutable [reference](../../../developer-docs-site/docs/move/book/references.md) to a field of a struct. We then modify the balance through this mutable reference and return a new coin with the withdrawn amount.
@@ -446,7 +446,7 @@ The solution to this exercise can be found in [`step_5_sol`](./step_5_sol). ## Step 6: Making my `basic_coin` module generic In Move, we can use -[generics](../../../developer-docs-site/docs/guides/move-guides/book/generics.md) +[generics](../../../developer-docs-site/docs/move/book/generics.md) to define functions and structs over different input data types. Generics are a great building block for library code. In this section, we are going to make our simple `basic_coin` module generic so that it can serve as a library module to be used by @@ -487,17 +487,17 @@ In definitions of both `Coin` and `Balance`, we declare the type parameter `Coin to be phantom because `CoinType` is not used in the struct definition or is only used as a phantom type parameter. -Read more about [phantom type](../../../developer-docs-site/docs/guides/move-guides/book/generics.md#phantom-type-parameters) parameters in the Aptos Move Book. +Read more about [phantom type](../../../developer-docs-site/docs/move/book/generics.md#phantom-type-parameters) parameters in the Aptos Move Book. ## Step 7: Use the Move Prover -> NOTE: Before running the Move Prover, ensure that the [Move Prover](../../../developer-docs-site/docs/cli-tools/aptos-cli-tool/install-move-prover.md) and associated tools are installed. +> NOTE: Before running the Move Prover, ensure that the [Move Prover](../../../developer-docs-site/docs/tools/install-cli/install-move-prover.md) and associated tools are installed. Smart contracts deployed on the blockchain may manipulate high-value assets. As a technique that uses strict mathematical methods to describe behavior and reason correctness of computer systems, formal verification has been used in blockchains to prevent bugs in smart contracts. The -[Move Prover](../../../developer-docs-site/docs/cli-tools/aptos-cli-tool/install-move-prover.md) +[Move Prover](../../../developer-docs-site/docs/move/prover/index.md) is an evolving formal verification tool for smart contracts written in the Move language. The user can employ the [Move Prover](https://github.com/move-language/move/blob/main/language/move-prover/doc/user/prover-guide.md) to specify functional properties of smart contracts