Skip to content

Commit d700b88

Browse files
authored
[book] massive rewrite (#223)
1 parent 8ce4dcb commit d700b88

171 files changed

Lines changed: 7893 additions & 2866 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

book/404.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
description: "Page not found."
3+
unlisted: true
4+
---
5+
16
# Page not Found
27

38
You're looking for a page that doesn't exist, or has been moved. Please check the URL and try again.

book/appendix/acknowledgements.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
description: "Acknowledgements for The Move Book: credits to The Rust Book, contributors, and the Move community."
2+
description:
3+
'Acknowledgements for The Move Book: credits to The Rust Book, contributors, and the Move
4+
community.'
35
---
46

57
# Appendix F: Acknowledgements
@@ -8,3 +10,16 @@ description: "Acknowledgements for The Move Book: credits to The Rust Book, cont
810
personally grateful to the authors of the book, Steve Klabnik and Carol Nichols, for their work, as
911
I have learned a lot from it. This book is a small tribute to their work and an attempt to bring a
1012
similar learning experience to the Move community.
13+
14+
## The Move Community
15+
16+
Just as important is the Move community, which has shaped this book from its very first edition -
17+
written back when the language had no official documentation. Readers who asked questions, pointed
18+
out confusing passages, reported mistakes, and opened issues and pull requests made the book what it
19+
is today. The full list of contributors is available on
20+
[GitHub](https://github.com/MystenLabs/move-book/graphs/contributors), and the
21+
[Contributing](./contributing) appendix describes how to join them.
22+
23+
Finally, none of this would exist without the people who created Move and continue to develop it
24+
today - the original Move team and the many contributors advancing the language. The
25+
[Move Reference](/reference) published alongside this book is adapted from their work.

book/appendix/reserved-addresses.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ between environments and are used for specific native operations.
1111
- `0x2` - address of the [Sui Framework](./../programmability/sui-framework.md) (alias `sui`)
1212
- `0x5` - address of the `SuiSystem` object
1313
- `0x6` - address of the system [`Clock` object](./../programmability/epoch-and-time.md)
14-
- `0x8` - address of the system `Random` object
15-
- `0xc` - address of the system `CoinRegistry` object
14+
- `0x8` - address of the system [`Random` object](./../programmability/randomness.md)
15+
- `0xc` - address of the system
16+
[`CoinRegistry` object](./../programmability/balance-and-coin.md#currency-and-the-coin-registry)
17+
- `0xd` - address of the system `DisplayRegistry` object (see
18+
[Object Display](./../programmability/display.md))
1619
- `0x403` - address of the `DenyList` system object
20+
- `0xacc` - address of the system `AccumulatorRoot` object

book/before-we-begin/install-move-registry-cli.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ cargo install --locked --git https://github.com/mystenlabs/mvr --branch release
4444

4545
For troubleshooting the installation process, please refer to the
4646
[Install MVR](https://docs.suins.io/move-registry/tooling/mvr-cli#installation) Guide.
47+
48+
## Using MVR
49+
50+
To learn how to find packages in the registry and use them as dependencies in your projects, see
51+
the [Using Move Registry](./../guides/using-move-registry) guide.

book/concepts/address.md

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,9 @@ description: "Learn about addresses in Sui — 32-byte unique identifiers used t
44

55
# Address
66

7-
<!--
8-
9-
Chapter: Concepts
10-
Goal: explain locations and addresses
11-
Notes:
12-
- don't talk about the type
13-
- packages, accounts and objects are identified by addresses
14-
- addresses are 32 bytes long
15-
- addresses are unique
16-
- represented as hex strings (64 characters) prefixed with 0x
17-
- addresses are case insensitive
18-
19-
Links:
20-
- address type
21-
22-
23-
- mention what an address is, because it identifies a package
24-
- address is used for packages, objects, and accounts
25-
- address is a 32-byte value
26-
- address is written in hexadecimal notation
27-
- don't describe the type yet
28-
- focus on the concept of address on blockchain and on Sui in particular
29-
30-
-->
31-
32-
Address is a unique identifier of a location on the blockchain. It is used to identify
7+
An address is a unique identifier of a location on the blockchain. It is used to identify
338
[packages](./packages), [accounts](./what-is-an-account), and [objects](./../object/object-model).
34-
Address has a fixed size of 32 bytes and is usually represented as a hexadecimal string prefixed
9+
An address has a fixed size of 32 bytes and is usually represented as a hexadecimal string prefixed
3510
with `0x`. Addresses are case insensitive.
3611

3712
```move
@@ -43,7 +18,7 @@ with `0x`.
4318

4419
Sui also has reserved addresses that are used to identify standard packages and objects. Reserved
4520
addresses are typically simple values that are easy to remember and type. For example, the address
46-
of the Standard Library is `0x1`. Addresses, shorter than 32 bytes, are padded with zeros to the
21+
of the Standard Library is `0x1`. Addresses shorter than 32 bytes are padded with zeros to the
4722
left.
4823

4924
```move
@@ -52,11 +27,12 @@ left.
5227

5328
Here are some examples of reserved addresses:
5429

55-
- `0x1` - address of the Sui Standard Library (alias `std`)
30+
- `0x1` - address of the Move Standard Library (alias `std`)
5631
- `0x2` - address of the Sui Framework (alias `sui`)
5732
- `0x6` - address of the system `Clock` object
5833

59-
> You can find all reserved addresses in the [Appendix B](../appendix/reserved-addresses).
34+
> You can find all reserved addresses in
35+
> [Appendix B: Reserved Addresses](../appendix/reserved-addresses).
6036
6137
## Further Reading
6238

book/concepts/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ description: "Core Sui and Move concepts: packages, accounts, transactions, addr
44

55
# Concepts
66

7-
In this chapter you will learn about the basic concepts of Sui and Move. You will learn what is a
8-
package, how to interact with it, what is an account and a transaction, and how data is stored on
9-
Sui. While this chapter is not a complete reference, and you should refer to the
10-
[Sui Documentation](https://docs.sui.io) for that, it will give you a good understanding of the
11-
basic concepts required to write Move programs on Sui.
7+
In this chapter you will learn about the basic concepts of Sui and Move: what a package is and how
8+
to interact with it, what an account and a transaction are, and how data is stored on Sui. While
9+
this chapter is not a complete reference - refer to the [Sui Documentation](https://docs.sui.io)
10+
for that - it will give you a good understanding of the concepts required to write Move programs
11+
on Sui.

book/concepts/manifest.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
description: "The Move.toml package manifest: package metadata, dependencies, named addresses, and dependency overrides explained."
3+
---
4+
15
# Package Manifest
26

37
The `Move.toml` is a manifest file that describes the [package](./packages) and its dependencies. It
@@ -18,13 +22,11 @@ example = { git = "https://github.com/example/example.git", subdir = "path/to/pa
1822
### Package
1923

2024
The `[package]` section is used to describe the package. None of the fields in this section are
21-
published on chain, but they are used in tooling and release management; they also specify the Move
25+
published onchain, but they are used in tooling and release management; they also specify the Move
2226
edition for the compiler.
2327

2428
- `name` - the name of the package when it is imported;
25-
- `edition` - the edition of the Move language; currently, the only valid value is `2024`.
26-
27-
<!-- published-at -->
29+
- `edition` - the edition of the Move language; currently, the only valid value is `2024`;
2830

2931
### Dependencies
3032

@@ -41,9 +43,9 @@ example = { git = "https://github.com/example/example.git", subdir = "path/to/pa
4143
my_package = { local = "../my-package" }
4244
```
4345

44-
Packages also import addresses from other packages. For example, the Sui dependency adds the `std`
45-
and `sui` addresses to the project. These addresses can be used in the code as aliases for the
46-
addresses.
46+
Packages also import named addresses from their dependencies. For example, the Sui dependency adds
47+
the `std` and `sui` addresses to the project, usable in the code in place of the full `0x1` and
48+
`0x2` addresses.
4749

4850
Starting with version 1.45 of the Sui CLI, the Sui system packages (`std`, `sui`, `system`,
4951
`bridge`, and `deepbook`) are automatically added as dependencies if none of them are explicitly
@@ -89,4 +91,5 @@ local = "../my-package"
8991

9092
## Further Reading
9193

94+
- [Move Package Management](https://docs.sui.io/develop/manage-packages/move-package-management) in the Sui Docs.
9295
- [Packages](./../../reference/packages) in the Move Reference.

book/concepts/packages.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,6 @@ description: "Understand Move packages — the unit of code organization contain
44

55
# Package
66

7-
<!--
8-
9-
- packages and how they're stored
10-
- overview of packages and their contents (use a diagram)
11-
- how a package is created, and what it consists of
12-
- what is the package manifest
13-
- describe how "name" field is used
14-
- mention the "edition" field
15-
- what are the folders in a package and what are they for
16-
- how packages are imported (give Sui as an example)
17-
- what are addresses, and how they identify packages
18-
- how packages are published
19-
- leave a note that packages are also *upgradable*
20-
21-
-->
22-
237
Move is a language for writing smart contracts - programs that are stored and run on the blockchain.
248
A single program is organized into a package. A package is published on the blockchain and is
259
identified by an [address](./address). A published package can be interacted with by sending
@@ -29,7 +13,7 @@ other packages.
2913
> To create a new package, use the `sui move new` command. To learn more about the command, run
3014
> `sui move new --help`.
3115
32-
Package consists of modules - separate scopes that contain functions, types, and other items.
16+
A package consists of modules - separate scopes that contain functions, types, and other items.
3317

3418
```
3519
package 0x...
@@ -45,7 +29,7 @@ package 0x...
4529

4630
Locally, a package is a directory with a `Move.toml` file and a `sources` directory. The `Move.toml`
4731
file - called the "package manifest" - contains metadata about the package, and the `sources`
48-
directory contains the source code for the modules. Package usually looks like this:
32+
directory contains the source code for the modules. A package usually looks like this:
4933

5034
```
5135
sources/
@@ -60,14 +44,14 @@ Move.toml
6044
```
6145

6246
The `tests` directory is optional and contains tests for the package. Code placed into the `tests`
63-
directory is not published on-chain and is only available in tests. The `examples` directory can be
64-
used for code examples, and is also not published on-chain.
47+
directory is not published onchain and is only available in tests. The `examples` directory can be
48+
used for code examples, and is also not published onchain.
6549

6650
## Published Package
6751

68-
During development, package doesn't have an address and it needs to be set to `0x0`. Once a package
69-
is published, it gets a single unique [address](./address) on the blockchain containing its modules'
70-
bytecode. A published package becomes _immutable_ and can be interacted with by sending
52+
During development, a package doesn't have an address yet, and `0x0` is used in its place. Once a
53+
package is published, it gets a single unique [address](./address) on the blockchain containing its
54+
modules' bytecode. A published package becomes _immutable_ and can be interacted with by sending
7155
transactions.
7256

7357
```
@@ -76,7 +60,14 @@ transactions.
7660
another_module: <bytecode>
7761
```
7862

79-
## Links
63+
While the published bytecode can never be changed, a package can be _upgraded_: an upgrade
64+
publishes a new version of the package at a new address, leaving the old version intact. We touch
65+
on the implications throughout the book: the
66+
[Package Upgrades](./../programmability/package-upgrades) section explains the mechanics, and the
67+
[Upgradeability Practices](./../guides/upgradeability-practices) guide covers how to design for
68+
upgrades.
69+
70+
## Further Reading
8071

8172
- [Package Manifest](./manifest)
8273
- [Address](./address)

book/concepts/what-is-a-transaction.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,9 @@ description: "Learn how Sui transactions work: structure, commands, gas payments
44

55
# Transaction
66

7-
Transaction is a fundamental concept in the blockchain world. It is a way to interact with a
8-
blockchain. Transactions are used to change the state of the blockchain, and they are the only way
9-
to do so. In Move, transactions are used to call functions in a package, deploy new packages, and
10-
upgrade existing ones.
11-
12-
<!--
13-
14-
- how user interacts with a program
15-
- mention public functions
16-
- give a concept of an entry / public function without getting into details
17-
- mention that functions are called in transactions
18-
- mention that transactions are sent by accounts
19-
- every transaction specifies object it operates on
20-
21-
-->
7+
A transaction is the fundamental way to interact with a blockchain. Transactions are used to
8+
change the state of the blockchain, and they are the only way to do so. On Sui, a transaction can
9+
call functions in published packages, deploy new packages, and upgrade existing ones.
2210

2311
## Transaction Structure
2412

@@ -31,11 +19,11 @@ Transactions consist of:
3119
- command inputs - the arguments for the commands: either `pure` - simple values like numbers or
3220
strings, or `object` - objects that the transaction will access;
3321
- a gas object - the `Coin` object used to pay for the transaction;
34-
- gas price and budget - the cost of the transaction;
22+
- a gas price and budget - the cost of the transaction.
3523

3624
## Inputs
3725

38-
Transaction inputs are the arguments for the transaction and are split between 2 types:
26+
Transaction inputs are the arguments for the transaction, and come in two types:
3927

4028
- Pure arguments: These are mostly [primitive types](../move-basics/primitive-types) with some extra
4129
additions. A pure argument can be:
@@ -47,7 +35,7 @@ Transaction inputs are the arguments for the transaction and are split between 2
4735
- [`std::ascii::String`](../move-basics/string#ascii-strings), ASCII strings.
4836
- [`vector<T>`](../move-basics/vector), where `T` is a pure type.
4937
- [`std::option::Option<T>`](../move-basics/option), where `T` is a pure type.
50-
- [`std::object::ID`](../storage/uid-and-id), typically points to an object. See also
38+
- [`sui::object::ID`](../storage/uid-and-id), typically points to an object. See also
5139
[What is an Object](../object/object-model).
5240
- Object arguments: These are objects or references of objects that the transaction will access. An
5341
object argument needs to be either a shared object, a frozen object, or an object that the
@@ -61,6 +49,13 @@ publishing a package) or a call to a function in an already published package. T
6149
executed in the order they are listed in the transaction, and they can use the results of the
6250
previous commands, forming a chain. Transaction either succeeds or fails as a whole.
6351

52+
Any [`public`](../move-basics/visibility#public-visibility) function can be called as a command:
53+
making a function `public` is all it takes for users to call it in a transaction, and it is the
54+
default way to expose functionality in Move. (There is also the
55+
[`entry`](../move-basics/visibility#entry-modifier) modifier, which creates functions callable
56+
_only_ as transaction commands - a deliberately restricted option, covered in the
57+
[Entry Functions](../move-advanced/entry-functions) section.)
58+
6459
Schematically, a transaction looks like this (in pseudo-code):
6560

6661
```
@@ -81,10 +76,6 @@ In this example, the transaction consists of three commands:
8176
with the given arguments - the `payment` object;
8277
3. `TransferObjects` - a built-in command that transfers the object to the recipient.
8378

84-
<!--
85-
> There are multiple different implementations of transaction building, for example
86-
-->
87-
8879
## Transaction Effects
8980

9081
Transaction effects are the changes that a transaction makes to the blockchain state. More
@@ -104,4 +95,12 @@ The result of the executed transaction consists of different parts:
10495
- Events - the custom [events](./../programmability/events) emitted by the transaction;
10596
- Object Changes - the changes made to the objects, including the _change of ownership_;
10697
- Balance Changes - the changes made to the aggregate balances of the account involved in the
107-
transaction;
98+
transaction.
99+
100+
## Further Reading
101+
102+
- [Transactions](https://docs.sui.io/concepts/transactions) in the Sui Documentation.
103+
- [Programmable Transaction Blocks](https://docs.sui.io/concepts/transactions/prog-txn-blocks) in
104+
the Sui Documentation.
105+
- [Using Address Balances](https://docs.sui.io/onchain-finance/asset-custody/address-balances/using-address-balances)
106+
in the Sui Documentation - paying gas and moving funds without a `Coin` object.

book/concepts/what-is-an-account.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,20 @@ description: "Understand Sui accounts: how they are generated from private keys,
44

55
# Account
66

7-
<!--
8-
9-
- user is an account
10-
- account is identified by an address
11-
- account is generated from a private key
12-
- account can own objects
13-
- account can send transactions
14-
- every transaction has a sender
15-
- sender is identified by an address
16-
- sui cryptographic agility
17-
- sui account types
18-
- supported curves: ed25519, secp256k1, zklogin
19-
20-
-->
21-
227
An account is a way to identify a user. An account is generated from a private key, and is
238
identified by an address. An account can own objects, and can send transactions. Every transaction
249
has a sender, and the sender is identified by an [address](./address).
2510

26-
Sui supports multiple cryptographic algorithms for account generation. The two supported curves are
27-
ed25519, secp256k1, and there is also a special way of generating an account - zklogin. The
28-
cryptographic agility - the unique feature of Sui - allows for flexibility in the account
29-
generation.
11+
An account does not need to be created or registered anywhere: it exists as soon as a keypair is
12+
generated, and any valid address can receive objects without prior setup. There is no onchain
13+
record of "all accounts" - an address with no objects and no transaction history is
14+
indistinguishable from one that was never used.
3015

31-
<!-- The cryptographic agility allows for flexibility in the account generation -->
16+
Sui supports multiple signature schemes for accounts: ed25519, ECDSA (over the secp256k1 and
17+
secp256r1 curves), passkeys (device authenticators such as Face ID, Touch ID, or a hardware
18+
security key, based on the WebAuthn standard), multisig (an account controlled by a combination of
19+
keys), and zkLogin, which derives an account from a Web2 login. This _cryptographic agility_ gives
20+
Sui unusual flexibility in how accounts are created and controlled.
3221

3322
## Further Reading
3423

@@ -38,3 +27,4 @@ generation.
3827
the [Sui Docs](https://docs.sui.io)
3928
- [Signatures](https://docs.sui.io/guides/developer/cryptography/signing) in the
4029
[Sui Docs](https://docs.sui.io)
30+
- [Passkey](https://docs.sui.io/develop/cryptography/passkeys) in the [Sui Docs](https://docs.sui.io)

0 commit comments

Comments
 (0)