From 6a781781ab31ecd3e9fa1c28b3179d3cb8eb62cb Mon Sep 17 00:00:00 2001 From: Randall-Mysten <109545725+randall-Mysten@users.noreply.github.com> Date: Tue, 14 Mar 2023 14:31:55 -0700 Subject: [PATCH] Misc updates for style, code changes, etc (#9299) ## Description Describe the changes or additions included in this PR. ## Test Plan How did you test the new or updated feature? --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes --- doc/src/build/comms.md | 16 ++-- doc/src/build/event_api.md | 86 ++++++++--------- doc/src/build/fullnode.md | 8 +- doc/src/build/index.md | 4 +- doc/src/build/install.md | 30 +++--- doc/src/build/json-rpc.md | 4 +- doc/src/build/rust-sdk.md | 51 +++++----- doc/src/explore/tutorials.md | 180 ++++++++++++++++++----------------- 8 files changed, 192 insertions(+), 187 deletions(-) diff --git a/doc/src/build/comms.md b/doc/src/build/comms.md index d049c1f20bf2f..90e3c3ace4835 100644 --- a/doc/src/build/comms.md +++ b/doc/src/build/comms.md @@ -1,15 +1,15 @@ --- -title: Connect to the Sui Network +title: Connect to a Sui Network --- The pages in this section provide various options for communicating with Sui: -* Use the [Sui JSON-RPC API](json-rpc.md) to interact with a Sui network. -* Use the [Sui CLI client](cli-client.md). -* Interact with the Sui network via the [Sui Rust SDK](rust-sdk.md), a collection of Rust language JSON-RPC wrapper and crypto utilities. -* Sign transactions and interact with the Sui network using the [Sui TypeScript SDK](https://github.com/MystenLabs/sui/tree/main/sdk/typescript) built on the Sui JSON RPC API. -* Run a [Sui Full node](fullnode.md) yourself to store the full Sui blockchain state and history. -* Filter and subscribe to a [real-time event stream](event_api.md#subscribe-to-sui-events) on your Sui Full node using the WebSocket API. -* Find SDKs for other languages provided by the community in the [awesome-move](https://github.com/MystenLabs/awesome-move#sdks) overview. + * Use the [Sui JSON-RPC API](json-rpc.md) to interact with a Sui network. + * Use the [Sui CLI client](cli-client.md). + * Interact with the Sui network via the [Sui Rust SDK](rust-sdk.md), a collection of Rust language JSON-RPC wrapper and crypto utilities. + * Sign transactions and interact with the Sui network using the [Sui TypeScript SDK](https://github.com/MystenLabs/sui/tree/main/sdk/typescript) built on the Sui JSON RPC API. + * Run a [Sui Full node](fullnode.md) yourself to store the full Sui blockchain state and history. + * Filter and subscribe to a [real-time event stream](event_api.md#subscribe-to-sui-events) on your Sui Full node using the WebSocket API. + * Find SDKs for other languages provided by the community in the [awesome-move](https://github.com/MystenLabs/awesome-move#sdks) overview. See the [Sui Reference Documentation](../reference/index.md) for information on the Sui API and SuiJSON format. diff --git a/doc/src/build/event_api.md b/doc/src/build/event_api.md index fbd8037aa826e..3001f7f97432d 100644 --- a/doc/src/build/event_api.md +++ b/doc/src/build/event_api.md @@ -37,12 +37,12 @@ Move event attributes: "moveEvent": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "type": "0x2::devnet_nft::MintNFTEvent", "fields": { - "creator": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1", + "creator": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "name": "Example NFT", - "object_id": "0x497913a47dc0028a85f24c70d825991b71c60001" + "object_id": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" }, "bcs": "SXkTpH3AAoqF8kxw2CWZG3HGAAFwYT9PF64TY/en5yUdqrXFsG9owQtFeGFtcGxlIE5GVA==" } @@ -64,8 +64,8 @@ Publish event attributes: ```json { "publish": { - "sender": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1", - "packageId": "0x2d052c9de3dd02f28ec0f8e4dfdee175a5c597c3" + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", + "packageId": "0x5f01a29887a1d95e5b548b616da63b0ce07d816e89ef7b9a382177b4422bbaa2" } } ``` @@ -92,11 +92,11 @@ Transfer event attributes: "transferObject": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "native", - "sender": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "recipient": { - "AddressOwner": "0x741a9a7ea380aed286341fcf16176c8653feb667" + "AddressOwner": "0xa3c00467938b392a12355397bdd3d319cea5c9b8f4fc9c51b46b8e15a807f030" }, - "objectId": "0x591fbb00a6c9676186cb44402040a8350520cbe9", + "objectId": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5", "version": 1, "type": "Coin" } @@ -119,10 +119,10 @@ Delete object events occur when you delete an object. ```json { "deleteObject": { - "packageId": "0x2d052c9de3dd02f28ec0f8e4dfdee175a5c597c3", + "packageId": "0x5f01a29887a1d95e5b548b616da63b0ce07d816e89ef7b9a382177b4422bbaa2", "transactionModule": "discount_coupon", - "sender": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1", - "objectId": "0xe3a6bc7bf1dba4d17a91724009c461bd69870719" + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", + "objectId": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" } } ``` @@ -147,11 +147,11 @@ New object event attributes: "newObject": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "recipient": { - "AddressOwner": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1" + "AddressOwner": "0xa3c00467938b392a12355397bdd3d319cea5c9b8f4fc9c51b46b8e15a807f030" }, - "objectId": "0x497913a47dc0028a85f24c70d825991b71c60001" + "objectId": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" } } ``` @@ -199,9 +199,9 @@ You can use the `EventQuery` criteria object to query a Sui node and retrieve ev | MoveModule | Events emitted from the specified Move module | {"MoveModule":{"package":"0x2", "module":"devnet_nft"}} | | MoveEvent | Move struct name of the event | {"MoveEvent":"0x2::event_nft::MintNFTEvent"} | | EventType | Type of event described in [Events](#event-types) section | {"EventType": "NewObject"} | -| Sender | Query by sender address | {"Sender":"0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1"} | -| Recipient | Query by recipient | {"Recipient":{"AddressOwner":"0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1"}} | -| Object | Return events associated with the given object | {"Object":"0xe3a6bc7bf1dba4d17a91724009c461bd69870719"} | +| Sender | Query by sender address | {"Sender":"0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106"} | +| Recipient | Query by recipient | {"Recipient":{"AddressOwner":"0xa3c00467938b392a12355397bdd3d319cea5c9b8f4fc9c51b46b8e15a807f030"}} | +| Object | Return events associated with the given object | {"Object":"0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5"} | | TimeRange | Return events emitted in [start_time, end_time] interval | {"TimeRange":{"startTime":1669039504014, "endTime":1669039604014}} | ## Pagination @@ -246,12 +246,12 @@ curl --location --request POST '127.0.0.1:9000' \ "moveEvent": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "type": "0x2::devnet_nft::MintNFTEvent", "fields": { - "creator": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "creator": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "name": "Example NFT", - "object_id": "0x2ee80b4a2d203365dfbd68a90a8ad9a0dca19155" + "object_id": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" }, "bcs": "LugLSi0gM2XfvWipCorZoNyhkVX+1JBtcbilg//9jpVnYCe2u4HXzwtFeGFtcGxlIE5GVA==" } @@ -268,11 +268,11 @@ curl --location --request POST '127.0.0.1:9000' \ "newObject": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "recipient": { - "AddressOwner": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf" + "AddressOwner": "0xa3c00467938b392a12355397bdd3d319cea5c9b8f4fc9c51b46b8e15a807f030" }, - "objectId": "0x2ee80b4a2d203365dfbd68a90a8ad9a0dca19155" + "objectId": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" } } }, @@ -287,12 +287,12 @@ curl --location --request POST '127.0.0.1:9000' \ "moveEvent": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "type": "0x2::devnet_nft::MintNFTEvent", "fields": { - "creator": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "creator": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "name": "Example NFT", - "object_id": "0xd5657cf6acaba958c5b01ec0516f4f0dac77c7d2" + "object_id": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" }, "bcs": "1WV89qyrqVjFsB7AUW9PDax3x9L+1JBtcbilg//9jpVnYCe2u4HXzwtFeGFtcGxlIE5GVA==" } @@ -309,11 +309,11 @@ curl --location --request POST '127.0.0.1:9000' \ "newObject": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "recipient": { - "AddressOwner": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf" + "AddressOwner": "0xa3c00467938b392a12355397bdd3d319cea5c9b8f4fc9c51b46b8e15a807f030" }, - "objectId": "0xd5657cf6acaba958c5b01ec0516f4f0dac77c7d2" + "objectId": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" } } } @@ -360,12 +360,12 @@ curl --location --request POST '127.0.0.1:9000' \ "moveEvent": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "type": "0x2::devnet_nft::MintNFTEvent", "fields": { - "creator": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "creator": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "name": "Example NFT", - "object_id": "0x2ee80b4a2d203365dfbd68a90a8ad9a0dca19155" + "object_id": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" }, "bcs": "LugLSi0gM2XfvWipCorZoNyhkVX+1JBtcbilg//9jpVnYCe2u4HXzwtFeGFtcGxlIE5GVA==" } @@ -382,12 +382,12 @@ curl --location --request POST '127.0.0.1:9000' \ "moveEvent": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "type": "0x2::devnet_nft::MintNFTEvent", "fields": { - "creator": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "creator": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "name": "Example NFT", - "object_id": "0xd5657cf6acaba958c5b01ec0516f4f0dac77c7d2" + "object_id": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" }, "bcs": "1WV89qyrqVjFsB7AUW9PDax3x9L+1JBtcbilg//9jpVnYCe2u4HXzwtFeGFtcGxlIE5GVA==" } @@ -435,11 +435,11 @@ curl --location --request POST '127.0.0.1:9000' \ "newObject": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "recipient": { - "AddressOwner": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf" + "AddressOwner": "0xa3c00467938b392a12355397bdd3d319cea5c9b8f4fc9c51b46b8e15a807f030" }, - "objectId": "0xd5657cf6acaba958c5b01ec0516f4f0dac77c7d2" + "objectId": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" } } }, @@ -454,12 +454,12 @@ curl --location --request POST '127.0.0.1:9000' \ "moveEvent": { "packageId": "0x0000000000000000000000000000000000000000000000000000000000000002", "transactionModule": "devnet_nft", - "sender": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "sender": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "type": "0x2::devnet_nft::MintNFTEvent", "fields": { - "creator": "0xfed4906d71b8a583fffd8e95676027b6bb81d7cf", + "creator": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106", "name": "Example NFT", - "object_id": "0xd5657cf6acaba958c5b01ec0516f4f0dac77c7d2" + "object_id": "0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5" }, "bcs": "1WV89qyrqVjFsB7AUW9PDax3x9L+1JBtcbilg//9jpVnYCe2u4HXzwtFeGFtcGxlIE5GVA==" } @@ -488,9 +488,9 @@ You can use `EventFilter` to filter the events included in your subscription to | Module | Move module name | MoveEvent
TransferObject
DeleteObject
NewObject | `{"Module":"devnet_nft"}` | | MoveEventType | Move event type defined in the move code | MoveEvent | `{"MoveEventType":"0x2::devnet_nft::MintNFTEvent"}`| | MoveEventField | Filter using the data fields in the move event object | MoveEvent | `{"MoveEventField":{ "path":"/name", "value":"Example NFT"}}` | -| SenderAddress | Address that started the transaction | MoveEvent
Publish
TransferObject
DeleteObject
NewObject | `{"SenderAddress": "0x70613f4f17ae1363f7a7e7251daab5c5b06f68c1"}` | +| SenderAddress | Address that started the transaction | MoveEvent
Publish
TransferObject
DeleteObject
NewObject | `{"SenderAddress": "0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106"}` | | EventType | Type of event described in the [Events](#type-of-events) section | MoveEvent
Publish
TransferObject
DeleteObject
NewObject
EpochChange
Checkpoint | `{"EventType":"Publish"}` | -| ObjectId | Object ID | TransferObject
DeleteObject
NewObject | `{"ObjectId":"0xe3a6bc7bf1dba4d17a91724009c461bd69870719"}` | +| ObjectId | Object ID | TransferObject
DeleteObject
NewObject | `{"ObjectId":"0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5"}` | ### Combining filters diff --git a/doc/src/build/fullnode.md b/doc/src/build/fullnode.md index 318ef61a1e804..5c704766b50ba 100644 --- a/doc/src/build/fullnode.md +++ b/doc/src/build/fullnode.md @@ -48,7 +48,7 @@ Suggested minimum hardware to run a Sui Full node: * CPUs: 10 core * RAM: 32 GB -* Storage (SSD): 1 TB +* Storage (SSD): 2 TB ### Software requirements @@ -113,7 +113,7 @@ Follow the instructions in the [Full node Docker README](https://github.com/Myst ```shell curl -fLJO https://github.com/MystenLabs/sui-genesis/raw/main/devnet/genesis.blob ``` - * [Testnet genesis blob](https://github.com/MystenLabs/sui-genesis/raw/main/testnet/genesis.blob) + * [Testnet genesis blob](https://github.com/MystenLabs/sui-genesis/raw/main/testnet/genesis.blob) - Supported only when there is an active public Testnet network. ```shell curl -fLJO https://github.com/MystenLabs/sui-genesis/raw/main/testnet/genesis.blob ``` @@ -174,7 +174,7 @@ docker-compose down --volumes If you followed the instructions for [Building from Source](#building-from-source), update your Full node as follows: -1. Shut down your currently running Full node. +1. Shut down your running Full node. 1. `cd` into your local Sui repository: ```shell cd sui @@ -196,7 +196,7 @@ Source](#building-from-source), update your Full node as follows: ```shell curl -fLJO https://github.com/MystenLabs/sui-genesis/raw/main/devnet/genesis.blob ``` - * [Testnet genesis blob](https://github.com/MystenLabs/sui-genesis/raw/main/testnet/genesis.blob) + * [Testnet genesis blob](https://github.com/MystenLabs/sui-genesis/raw/main/testnet/genesis.blob) - supported only when there is an active public Testnet network ```shell curl -fLJO https://github.com/MystenLabs/sui-genesis/raw/main/testnet/genesis.blob ``` diff --git a/doc/src/build/index.md b/doc/src/build/index.md index e05a45c7240f3..41ae5d9ddba46 100644 --- a/doc/src/build/index.md +++ b/doc/src/build/index.md @@ -8,11 +8,11 @@ The topics in this section provide information and guidance to help you start bu To get started, see [Install](../build/install.md) to learn about prerequisites and steps to install Sui binaries. -After you install Sui, learn how to use the [Sui Client CLI](cli-client.md). You can use the client to interact with a [Devnet](devnet.md) Full node or your own [local network](../build/cli-client.md#genesis). +After you install Sui, learn how to use the [Sui Client CLI](cli-client.md). You can use the client to interact with a Sui Full node or your own [local network](../build/cli-client.md#genesis). ## Smart contracts -Learn about how to [Write Smart Contracts with Move](../build/move/index.md), including how to write, build, test, and publish Move packages on Sui. +Learn how to [Write Smart Contracts with Move](../build/move/index.md), including how to write, build, test, and publish Sui Move packages. ## Programming with Objects diff --git a/doc/src/build/install.md b/doc/src/build/install.md index 1349d69a73ebb..1afd34346d9c5 100644 --- a/doc/src/build/install.md +++ b/doc/src/build/install.md @@ -8,10 +8,10 @@ Before you install Sui, you need to install some prerequisite tools and configur The steps to install Sui include: -1. Install [prerequisites](#prerequisites) for your operating system. -1. Install [Sui binaries](#install-sui-binaries). -1. Configure an [Integrated Development Environment (IDE)](#integrated-development-environment). -1. Request [SUI test tokens](#sui-tokens) to use on a Sui network. + 1. Install [prerequisites](#prerequisites) for your operating system. + 1. Install [Sui binaries](#install-sui-binaries). + 1. Configure an [Integrated Development Environment (IDE)](#integrated-development-environment). + 1. Request [SUI test tokens](#sui-tokens) to use on a Sui network. You can also download the [source code](#source-code) to have local access to files. @@ -24,16 +24,16 @@ The Sui repository includes two primary branches, `devnet` and `main`. ## Documentation in the Sui repository -The source for the documentation published on this site also resides in the Sui repository. The content differs between the branches of the repository just like the Sui source code. Use the version of the documentation that corresponds to the Sui network you plan to use. For example, to use the Sui Devnet network, use the **Devnet** version of the documentation. To use Sui Testnet, use the **Testnet** version of the documentation. +The source for the documentation published on this site also resides in the Sui repository. The content differs between the branches of the repository just like the Sui source code. Use the version of the documentation that corresponds to the Sui network you plan to use. For example, to use the Sui Devnet network, use the **Devnet** version of the documentation. To use the latest Sui updates, use the **Latest build** version of the documentation. ## Supported operating systems Sui supports the following operating systems: -* Linux - Ubuntu version 20.04 (Bionic Beaver) -* macOS - macOS Monterey -* Microsoft Windows - Windows 11 + * Linux - Ubuntu version 20.04 (Bionic Beaver) + * macOS - macOS Monterey + * Microsoft Windows - Windows 11 ## Prerequisites @@ -300,10 +300,10 @@ git clone https://github.com/MystenLabs/sui.git --branch devnet ``` The following primary directories offer a good starting point for exploring Sui's source code: -* [sui](https://github.com/MystenLabs/sui/tree/main/crates/sui) - Sui, including the Sui CLI Client -* [sui_framework](https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/sources) - Sui Move core smart contracts (e.g., coin.move, object.move, test_scenario.move, ...) -* [sui_programmability](https://github.com/MystenLabs/sui/tree/main/sui_programmability) - Sui Move code examples (games, defi, nfts, ...) -* [sui_core](https://github.com/MystenLabs/sui/tree/main/crates/sui-core) - Core Sui components -* [sui-types](https://github.com/MystenLabs/sui/tree/main/crates/sui-types) - Sui object types, such as coins and gas -* [explorer](https://github.com/MystenLabs/sui/tree/main/apps/explorer) - browser-based object explorer for the Sui network -* [sui-network](https://github.com/MystenLabs/sui/tree/main/crates/sui-network) - networking interfaces + * [sui](https://github.com/MystenLabs/sui/tree/main/crates/sui) - Sui, including the Sui CLI Client + * [sui_framework](https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/sources) - Sui Move core smart contracts (e.g., coin.move, object.move, test_scenario.move, ...) + * [sui_programmability](https://github.com/MystenLabs/sui/tree/main/sui_programmability) - Sui Move code examples (games, defi, nfts, ...) + * [sui_core](https://github.com/MystenLabs/sui/tree/main/crates/sui-core) - Core Sui components + * [sui-types](https://github.com/MystenLabs/sui/tree/main/crates/sui-types) - Sui object types, such as coins and gas + * [explorer](https://github.com/MystenLabs/sui/tree/main/apps/explorer) - browser-based object explorer for the Sui network + * [sui-network](https://github.com/MystenLabs/sui/tree/main/crates/sui-network) - networking interfaces diff --git a/doc/src/build/json-rpc.md b/doc/src/build/json-rpc.md index 90fc032f95dc5..284ddbfdbabe0 100644 --- a/doc/src/build/json-rpc.md +++ b/doc/src/build/json-rpc.md @@ -6,13 +6,13 @@ Welcome to the guide for making remote procedure calls (RPC) to the Sui network. This guide is useful for developers interested in Sui network interactions via API and should be used in conjunction with the [SuiJSON format](sui-json.md) for aligning JSON inputs with Move Call arguments. -For a similar guide on Sui network interactions via CLI, refer to the [Sui CLI client](cli-client.md) documentation. +For a similar guide on Sui network interactions via CLI, refer to the [Sui Client CLI](cli-client.md) documentation. Follow the instructions to [install Sui binaries](install.md#install-sui-binaries). ## Connect to a Sui network -You can connect to a Sui Full node on Devnet. Follow the guidance in the [Connect to Sui Devnet](../build/devnet.md) topic to start making RPC calls to the Sui network. +You can connect to a Sui Full node on a Sui network. Follow the guidance in the [Connect to Sui Devnet](../build/devnet.md) topic to start making RPC calls to the Sui network. To configure your own Sui Full node, see [Configure a Sui Full node](fullnode.md). diff --git a/doc/src/build/rust-sdk.md b/doc/src/build/rust-sdk.md index 803cd78a6b800..8621b087960bb 100644 --- a/doc/src/build/rust-sdk.md +++ b/doc/src/build/rust-sdk.md @@ -1,40 +1,38 @@ --- -title: Interact with Sui over Rust SDK +title: Interact with Sui using the Rust SDK --- ## Overview -The [Sui SDK](https://github.com/MystenLabs/sui/tree/main/crates/sui-sdk) is a collection of Rust language JSON-RPC wrapper and crypto utilities you can use to interact with the [Sui Devnet](../build/devnet.md) and [Sui Full node](fullnode.md). -The [`SuiClient`](cli-client.md) can be used to create an HTTP or a WebSocket client (`SuiClient::new`). -See our [JSON-RPC](json-rpc.md#sui-json-rpc-methods) doc for the list of available methods. +The [Sui SDK](https://github.com/MystenLabs/sui/tree/main/crates/sui-sdk) is a collection of Rust language JSON-RPC wrapper and crypto utilities you can use to interact with Sui. -> Note: As of [Sui version 0.6.0](https://github.com/MystenLabs/sui/releases/tag/devnet-0.6.0), the WebSocket client is for [subscription only](event_api.md#subscribe-to-sui-events); use the HTTP client for other API methods. +Use the [`SuiClient`](cli-client.md) to create an HTTP or a WebSocket client (`SuiClient::new`). See the [JSON-RPC](json-rpc.md#sui-json-rpc-methods) documentation for the list of available methods. -## References +**Note:** The WebSocket client supports only [subscription](event_api.md#subscribe-to-sui-events); use the HTTP client for other API methods. -Find the `rustdoc` output for key Sui projects at: +## References -* Sui blockchain - https://mystenlabs.github.io/sui/ -* Narwhal and Bullshark consensus engine - https://mystenlabs.github.io/narwhal/ -* Mysten Labs infrastructure - https://mystenlabs.github.io/mysten-infra/ +View the documentation for the [crates used in Sui](https://mystenlabs.github.io/sui/). ## Configuration -Add the `sui-sdk` crate in your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) file like so: -```toml + +Add the `sui-sdk` crate in your [`Cargo.toml`](https://doc.rust-lang.org/cargo/reference/manifest.html) file: + +```bash [dependencies] sui-sdk = { git = "https://github.com/MystenLabs/sui" } ``` -If you are connecting to the devnet, use the `devnet` branch instead: -```toml + +Include the `branch` argument to use a specific branch of the Sui repository: + +```bash [dependencies] sui-sdk = { git = "https://github.com/MystenLabs/sui", branch = "devnet" } ``` -## Examples +## Example 1 - Get all objects owned by an address -### Example 1 - Get all objects owned by an address - -This will print a list of object summaries owned by the address `"0xec11cad080d0496a53bafcea629fcbcfff2a9866"`: +This code example prints a list of object summaries owned by the specified address. ```rust use std::str::FromStr; @@ -46,7 +44,7 @@ async fn main() -> Result<(), anyhow::Error> { let sui = SuiClientBuilder::default().build( "https://fullnode.devnet.sui.io:443", ).await.unwrap(); - let address = SuiAddress::from_str("0xec11cad080d0496a53bafcea629fcbcfff2a9866")?; + let address = SuiAddress::from_str("0xbcab7526033aa0e014f634bf51316715dda0907a7fab5a8d7e3bd44e634a4d44")?; let objects = sui.read_api().get_objects_owned_by_address(address).await?; println!("{:?}", objects); Ok(()) @@ -55,7 +53,7 @@ async fn main() -> Result<(), anyhow::Error> { You can verify the result with the [Sui Explorer](https://explorer.sui.io/) if you are using the Sui Devnet Full node. -### Example 2 - Create and execute transaction +## Example 2 - Create and execute transaction Use this example to conduct a transaction in Sui using the Sui Devnet Full node: @@ -83,9 +81,9 @@ async fn main() -> Result<(), anyhow::Error> { None => panic!("Cannot obtain home directory path"), }; - let my_address = SuiAddress::from_str("0x47722589dc23d63e82862f7814070002ffaaa465")?; - let gas_object_id = ObjectID::from_str("0x273b2a83f1af1fda3ddbc02ad31367fcb146a814")?; - let recipient = SuiAddress::from_str("0xbd42a850e81ebb8f80283266951d4f4f5722e301")?; + let my_address = SuiAddress::from_str("0xbcab7526033aa0e014f634bf51316715dda0907a7fab5a8d7e3bd44e634a4d44")?; + let gas_object_id = ObjectID::from_str("0xe638c76768804cebc0ab43e103999886641b0269a46783f2b454e2f8880b5255")?; + let recipient = SuiAddress::from_str("0x727b37454ab13d5c1dbb22e8741bff72b145d1e660f71b275c01f24e7860e5e5")?; // Create a sui transfer transaction let transfer_tx = sui @@ -108,7 +106,7 @@ async fn main() -> Result<(), anyhow::Error> { } ``` -### Example 3 - Event subscription +## Example 3 - Event subscription Use the WebSocket client to [subscribe to events](event_api.md#subscribe-to-sui-events). @@ -128,9 +126,6 @@ async fn main() -> Result<(), anyhow::Error> { } } ``` -> Note: You will need to connect to a fullnode for the Event subscription service, see [Full node setup](fullnode.md#fullnode-setup) if you want to run a Sui Fullnode. - -## Larger examples +**Note:** The Event subscription service requires a running Sui Full node. To learn more, see [Full node setup](fullnode.md#fullnode-setup). -See the Sui Rust SDK README for the [Tic Tac Toe](https://github.com/MystenLabs/sui/tree/main/crates/sui-sdk) example. diff --git a/doc/src/explore/tutorials.md b/doc/src/explore/tutorials.md index ca95bd5c15a3c..fdc7ea4893cc3 100644 --- a/doc/src/explore/tutorials.md +++ b/doc/src/explore/tutorials.md @@ -15,7 +15,7 @@ and playing it to the end. 1. [Start the Sui network](../build/cli-client.md#starting-the-network) by running the `sui start` command. -After completing these steps, you will have a running local Sui instance and +After completing these steps, you have a running local Sui instance and the `sui client` command used in the remainder of this tutorial in your path. Simply leave the terminal with Sui running and start a new terminal for the remainder of this tutorial. @@ -77,75 +77,53 @@ sui client call --package $PACKAGE_ID --module tic_tac_toe --function create_gam ## Gather addresses and gas objects -In the new terminal session you started, use the following command in the Sui CLI client to view the addresses we own: +In the new terminal session you started, use the following command in the Sui CLI client to view the addresses available: + ```shell $ sui client addresses ``` -Which results in output resembling: -```shell -Showing 5 results. -ECF53CE22D1B2FB588573924057E9ADDAD1D8385 -7B61DA6AACED7F28C1187D998955F10464BEAE55 -251CF224B6BA3A019D04B6041357C20490F7A322 -DB4C7667636471AFF396B900EB7B63FACAF629B6 -A6BBB1930E01495EE93CE912EA01C29695E07890 -``` -Note that since these addresses are randomly generated, they are different from the values you see when you run the command. We need three addresses to play TicTacToe. Let's pick the first three addresses. Let's call them ADMIN, PLAYER_X and PLAYER_O. - -Since we will be using these addresses and gas objects repeatedly in the rest of this tutorial, let's make them environment variables so that we don't have to retype them every time: -``` -$ export ADMIN=ECF53CE22D1B2FB588573924057E9ADDAD1D8385 -export PLAYER_X=7B61DA6AACED7F28C1187D998955F10464BEAE55 -export PLAYER_O=251CF224B6BA3A019D04B6041357C20490F7A322 -``` - -For each of these addresses, let's discover the gas objects associated with each address: -``` -$ sui client gas --address $ADMIN - Object ID | Version | Gas Value ----------------------------------------------------------------------- - 38B89FE9F4A4823F1406938E87A8767CBD7F0B93 | 0 | 100000 - 4790500A28AB5B4F9A3988E2A5E201D56996CBB0 | 0 | 100000 - 6AB7D15F41B28FF1EBF6D32499214BBD9035D1EB | 0 | 100000 - 800F2704E22637A036C4325B539D711BB83CA6C2 | 0 | 100000 - D2F52301D5343DD2C1FA076401BC6283C3E4AA34 | 0 | 100000 -$ sui client gas --address $PLAYER_X - Object ID | Version | Gas Value ----------------------------------------------------------------------- - 6F675038CAA48184707DBBE95ACFBA2030E87CD8 | 0 | 100000 - 80C91F0B31EFBC1C7BF639A531301AAF3A1D3AB6 | 0 | 100000 - 9FED1FC3D21F284DC53DE87C0E19718971D96D8C | 0 | 100000 - E293F935F015C23216867442DB4E712518E7CAB7 | 0 | 100000 - F19384C06AE538F9C3C9D9762002B4DAEA49FE3A | 0 | 100000 -$ sui client gas --address $PLAYER_O - Object ID | Version | Gas Value ----------------------------------------------------------------------- - 2110ADFB7BAF889A05EA6F5889AF7724299F9BED | 0 | 100000 - 8C04A5D8D62155B9E90093D6CB300DA304B9E581 | 0 | 100000 - 9602B7C0869E7E5AB314FB3D99395A8C640E0E34 | 0 | 100000 - A0DBF58C3801EC2FEDA1D039E190A6B31A25B199 | 0 | 100000 - D5EBB8A19A35874A18B7A1D883EBFC8D897F5693 | 0 | 100000 -``` -We only need one gas object per address. So let's pick the first gas object of each address. In the above example, it's `38B89FE9F4A4823F1406938E87A8767CBD7F0B93`, `6F675038CAA48184707DBBE95ACFBA2030E87CD8` and `2110ADFB7BAF889A05EA6F5889AF7724299F9BED`, respectively. Again, you will see different IDs. Let's also add them to our environment variables: -``` -$ export ADMIN_GAS=38B89FE9F4A4823F1406938E87A8767CBD7F0B93 -export X_GAS=6F675038CAA48184707DBBE95ACFBA2030E87CD8 -export O_GAS=2110ADFB7BAF889A05EA6F5889AF7724299F9BED +The response lists the addresses available. Choose three to use for the tutorial. Call them ADMIN, PLAYER_X, and PLAYER_O. + +To make it easier to use these address values and gas object, create an environment variable for each address so you don't have to manually add them each time: + +```bash +export ADMIN=0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106 +export PLAYER_X=0x011a285261b9f8d10a0c7ecb4c0dbe6d396825768dba38c3056809472736e521 +export PLAYER_O=0x4ab708d1a4160fa0fdbf359691764e16380444ddb48d2b8856a169594a9baa55 ``` -## Publish the TicTacToe game on Sui -To keep this tutorial simple, use the TicTacToe game we implemented in [tic_tac_toe.move](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/games/sources/tic_tac_toe.move). +Next, determine the gas objects associated with each address: +```bash +sui client gas --address $ADMIN +``` + +```bash +sui client gas --address $PLAYER_X +``` + +```bash +sui client gas --address $PLAYER_0 +``` + +The tutorial uses only one gas object per address. Choose the object to use, and then create variables for them as well. + +```bash +export ADMIN_GAS=0x1aa482ad8c6240cda3097a4aa13ad5bfb27bf6052133c01f79c8b4ea0aaa0601 +export X_GAS=0x3fd0e889ee56152cdbd5fa5b5dab78ddc66d127930f5173ae7b5a9ac3e17dd6d +export O_GAS=0x51ec7820e82035a5de7b4f3ba2a3813ea099dca1867876f4177a1fa1d1efe022 +``` -Find even more [examples](examples.md) in the Sui repository. Of course, you are welcome to -[write your own package](../build/move/write-package.md). +## Publish the TicTacToe game on Sui +To keep this tutorial simple, use the TicTacToe game example from [tic_tac_toe.move](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/games/sources/tic_tac_toe.move). -To publish the game, we run the publish command and specify the path to the source code of the game package: +To publish the game, run the publish command and specify the path to the location of the game package: ```shell $ sui client publish ./sui/sui_programmability/examples/games --gas $ADMIN_GAS --gas-budget 30000 ``` -Which yields results resembling: +The response resembles the following: + ```shell ----- Certificate ---- Signed Authorities : ... @@ -156,34 +134,37 @@ The newly published package object: (A613A7FF8CB03E0DFC0D157E232BBA50C5F19D17, S List of objects created by running module initializers: [] Updated Gas : Coin { id: 38B89FE9F4A4823F1406938E87A8767CBD7F0B93, value: 92939 } ``` -As we can see, the package was successfully published. Some gas was charged: the initial gas value was 100000, now it's 92939 (note: the current gas charging mechanism is rather arbitrary, we will come up with a gas mechanism shortly). -The newly published package has the ID `A613A7FF8CB03E0DFC0D157E232BBA50C5F19D17`. Note that this ID will also be different in your terminal. We add the package to another environment variable: -``` +The package successfully published. Some gas was charged: the initial gas value was 100000, now it's 92939. The newly published package has the ID `A613A7FF8CB03E0DFC0D157E232BBA50C5F19D17`. Note that this ID is different than ID for the package you publish. + +```bash export PACKAGE=A613A7FF8CB03E0DFC0D157E232BBA50C5F19D17 ``` ## Playing TicTacToe -As we mentioned earlier, we need 3 parties to participate in this game: Admin, PlayerX and PlayerO. -At a high level, the game works as following: -1. The admin creates a game, which also specifies the addresses of the two players. This will also create two capability objects and send to each of the addresses to give them permission to participate in the same game. This ensures that an arbitrary person cannot attempt to join this game. -2. Each player takes turns to send a *Mark* object to the admin indicating where they want to place their mark. -3. The admin, upon receiving marks (in practice, this is done through monitoring events), places the mark to the gameboard. -4. (2) and (3) repeats until game ends. -Because the admin owns the gameboard, each individual player cannot place a mark directly on the gameboard (they don't own the object, and hence cannot mutate it, see [Object Model](../learn/objects.md)), each mark placement is split to 2 steps, that each player first sends a mark, and then the admin places the mark. A sample gameplay can also be found in the [tic_tac_toe_tests](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/games/tests/tic_tac_toe_tests.move) file. +As mentioned earlier, the game requires three participants: Admin, PlayerX and PlayerO. At a high level, the game works as follows: + 1. The admin creates a game and specifies the addresses of the two players. This also creates two capability objects and grants each of the addresses permission to participate in the same game. + 1. Each player takes turns to send a *Mark* object to the admin that indicates their move. + 1. The admin receives the marks (in practice, this is done through monitoring events), and positions the mark on the game board. + 1. (2) and (3) repeat until the game ends. + +Because the admin owns the game board, each individual player cannot place a mark directly on it. The players don't own the object so can't mutate it. Each mark placement consists of two steps. Each player first sends a mark, and then the admin places the mark. View an example game play in the [tic_tac_toe_tests](https://github.com/MystenLabs/sui/blob/main/sui_programmability/examples/games/tests/tic_tac_toe_tests.move) file. Now let's begin the game! -First of all, let's create a game with the command: + +First, create a game with the following command: + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function create_game --args $PLAYER_X $PLAYER_O --gas $ADMIN_GAS --gas-budget 1000 ``` -You will see output like: +The response resembles the following: + ```shell ----- Certificate ---- Signed Authorities : ... Transaction Kind : Call Gas Budget : 1000 -Package ID : 0xa613a7ff8cb03e0dfc0d157e232bba50c5f19d17 +Package ID : 0x1aa482ad8c6240cda3097a4aa13ad5bfb27bf6052133c01f79c8b4ea0aaa0601 Module : TicTacToe Function : create_game Object Arguments : [] @@ -198,35 +179,39 @@ F1B8161BD97D3CD6627E739AD675089C5ACFB452 SequenceNumber(1) o#1c92bdf7646cad2a653 Mutated Objects: 38B89FE9F4A4823F1406938E87A8767CBD7F0B93 SequenceNumber(2) o#26dbaf7ec2032a6270a45498ad46ac0b1ddbc361fcff20cadafaf5d39b8181b1 ``` + The preceding call created three objects. For each object, it printed out a tuple of three values (object_id, version, object_digest). Object ID is what we care about here. Since we don't have a real application here to display things for us, we need a bit of object printing magic to figure out which object is which. Let's print out the metadata of each created object (replace the object ID with what you see on your screen): -``` -$ sui client object 5851B7EA07B93E68696BC0CF811D2E266DFB880D -Owner: AddressOwner(k#251cf224b6ba3a019d04b6041357c20490f7a322) + +```bash +sui client object 5851B7EA07B93E68696BC0CF811D2E266DFB880D +Owner: AddressOwner(k#0x4ab708d1a4160fa0fdbf359691764e16380444ddb48d2b8856a169594a9baa55) Version: 1 ID: 5851B7EA07B93E68696BC0CF811D2E266DFB880D Readonly: false Type: 0xa613a7ff8cb03e0dfc0d157e232bba50c5f19d17::TicTacToe::MarkMintCap -$ sui client object A6D3B507D4533822E690291166891D42694A2721 -Owner: AddressOwner(k#7b61da6aaced7f28c1187d998955f10464beae55) +sui client object A6D3B507D4533822E690291166891D42694A2721 +Owner: AddressOwner(k#0x011a285261b9f8d10a0c7ecb4c0dbe6d396825768dba38c3056809472736e521) Version: 1 ID: A6D3B507D4533822E690291166891D42694A2721 Readonly: false Type: 0xa613a7ff8cb03e0dfc0d157e232bba50c5f19d17::TicTacToe::MarkMintCap -$ sui client object F1B8161BD97D3CD6627E739AD675089C5ACFB452 -Owner: AddressOwner(k#ecf53ce22d1b2fb588573924057e9addad1d8385) +sui client object F1B8161BD97D3CD6627E739AD675089C5ACFB452 +Owner: AddressOwner(k#0x008e9c621f4fdb210b873aab59a1e5bf32ddb1d33ee85eb069b348c234465106) Version: 1 ID: F1B8161BD97D3CD6627E739AD675089C5ACFB452 Readonly: false Type: 0xa613a7ff8cb03e0dfc0d157e232bba50c5f19d17::TicTacToe::TicTacToe ``` -There are two MarkMintCap objects (for capability of minting a mark for each player) and a TicTacToe object (the game object). Take a look at each of the `Owner` fields, and you will see that: -1. MarkMintCap Object `5851B7EA07B93E68696BC0CF811D2E266DFB880D` is owned by PLAYER_O. -2. MarkMintCap Object `A6D3B507D4533822E690291166891D42694A2721` is owned by PLAYER_X. -3. TicTacToe Object `F1B8161BD97D3CD6627E739AD675089C5ACFB452` is owned by ADMIN. + +There are two `MarkMintCap` objects (for capability of minting a mark for each player) and a TicTacToe object (the game object). Take a look at each of the `Owner` fields, and you will see that: + 1. `MarkMintCap` Object `5851B7EA07B93E68696BC0CF811D2E266DFB880D` is owned by PLAYER_O. + 1. `MarkMintCap` Object `A6D3B507D4533822E690291166891D42694A2721` is owned by PLAYER_X. + 1. `TicTacToe` Object `F1B8161BD97D3CD6627E739AD675089C5ACFB452` is owned by ADMIN. We add the above three object IDs to these environment variables: + ``` $ export XCAP=A6D3B507D4533822E690291166891D42694A2721 export OCAP=5851B7EA07B93E68696BC0CF811D2E266DFB880D @@ -235,20 +220,25 @@ export GAME=F1B8161BD97D3CD6627E739AD675089C5ACFB452 By convention, PlayerX goes first. PlayerX wants to put a mark at the center of the gameboard ((1, 1)). This needs to take two steps. First PlayerX creates a Mark object with the placement intention and send it to the admin. We will call the `send_mark_to_game` function in `TicTacToe`, whose signature looks like this: + ``` public entry fun send_mark_to_game(cap: &mut MarkMintCap, game_address: address, row: u64, col: u64, ctx: &mut TxContext); ``` + The `cap` argument will be PlayerX's capability object (XCAP), and `game_address` argument will be the admin's address (ADMIN): + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function send_mark_to_game --args $XCAP $ADMIN 1 1 --gas $X_GAS --gas-budget 1000 ``` + And its output: + ```shell ----- Certificate ---- Signed Authorities : ... Transaction Kind : Call Gas Budget : 1000 -Package ID : 0xa613a7ff8cb03e0dfc0d157e232bba50c5f19d17 +Package ID : 0x1aa482ad8c6240cda3097a4aa13ad5bfb27bf6052133c01f79c8b4ea0aaa0601 Module : TicTacToe Function : send_mark_to_game Object Arguments : [(A6D3B507D4533822E690291166891D42694A2721, SequenceNumber(1), o#930533ef8b324909c65d3586c73a6db1b7ee116704d6bc986a2c3a8f51d8bf10)] @@ -261,16 +251,22 @@ AE3CE9176F1A8C1F21D922722486DF667FA00394 SequenceNumber(1) o#d40c0e3c74a2badd60c Mutated Objects: ... ``` + The above call created a Mark object, with ID `AE3CE9176F1A8C1F21D922722486DF667FA00394`, and it was sent to the admin. The admin can now place the mark on the gameboard. The function to place the mark looks like this: -``` + +```rust public entry fun place_mark(game: &mut TicTacToe, mark: Mark, ctx: &mut TxContext); ``` + The first argument is the game board, and the second argument is the mark the admin just received from the player. We will call this function (replace the second argument with the Mark object ID above): + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function place_mark --args $GAME 0xAE3CE9176F1A8C1F21D922722486DF667FA00394 --gas $ADMIN_GAS --gas-budget 1000 ``` + The gameboard now looks like this (this won't be printed out, so keep it in your imagination): + ``` _|_|_ _|X|_ @@ -278,11 +274,13 @@ _|X|_ ``` PlayerO now tries to put a mark at (0, 0): + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function send_mark_to_game --args $OCAP $ADMIN 0 0 --gas $O_GAS --gas-budget 1000 ``` With output like: + ```shell ----- Certificate ---- ... @@ -299,6 +297,7 @@ $ sui client call --package $PACKAGE --module tic_tac_toe --function place_mark ``` With output like: + ```shell ----- Certificate ---- ... @@ -306,7 +305,9 @@ With output like: Status : Success { gas_used: 679 } ... ``` + The gameboard now looks like this: + ``` O|_|_ _|X|_ @@ -314,11 +315,13 @@ _|X|_ ``` PlayerX puts a mark at (0, 2): + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function send_mark_to_game --args $XCAP $ADMIN 0 2 --gas $X_GAS --gas-budget 1000 ``` With output like: + ```shell ----- Certificate ---- ... @@ -330,11 +333,13 @@ Created Objects: ``` Then run: + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function place_mark --args $GAME 0x2875D50BD9021ED2009A1278C7CB6D4C876FFF6A --gas $ADMIN_GAS --gas-budget 1000 ``` The gameboard now looks like this: + ``` O|_|X _|X|_ @@ -342,11 +347,13 @@ _|X|_ ``` PlayerO places a mark at (1, 0): + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function send_mark_to_game --args $OCAP $ADMIN 1 0 --gas $O_GAS --gas-budget 1000 ``` With output like: + ```shell ----- Certificate ---- ... @@ -368,12 +375,15 @@ O|_|X O|X|_ | | ``` + This is a chance for PlayerX to win! X now mints the winning mark at (2, 0): + ```shell $ sui client call --package $PACKAGE --module tic_tac_toe --function send_mark_to_game --args $XCAP $ADMIN 2 0 --gas $X_GAS --gas-budget 1000 ``` And its output: + ```shell ----- Certificate ---- ... @@ -408,7 +418,7 @@ $ sui client object 54B58C0D5B14A269B1CD424B3CCAB1E315C43343 See output resembling: ```shell -Owner: AddressOwner(k#7b61da6aaced7f28c1187d998955f10464beae55) +Owner: AddressOwner(k#0x011a285261b9f8d10a0c7ecb4c0dbe6d396825768dba38c3056809472736e521) Version: 1 ID: 54B58C0D5B14A269B1CD424B3CCAB1E315C43343 Readonly: false