forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit Rust SDK README (MystenLabs#3487)
* Edit Rust SDK README * Add reciprocal link
- Loading branch information
1 parent
73c4142
commit 207a8c7
Showing
1 changed file
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
# Rust SDK examples | ||
|
||
Examples of interacting with the move contract using the Sui Rust SDK. | ||
This directory contains examples of interacting with a Move language smart contract using the Sui Rust SDK. See the [introduction to the Rust SDK](https://github.com/MystenLabs/sui/blob/main/doc/src/build/rust-sdk.md) for additional details. | ||
|
||
## Tic Tac Toe | ||
|
||
### Demo quick start | ||
|
||
#### 1. Prepare the environment | ||
* Install `sui` and `rpc-server` binaries following the [installation doc](https://github.com/MystenLabs/sui/blob/main/doc/src/build/install.md#binaries). | ||
* [Connect to devnet](https://github.com/MystenLabs/sui/blob/main/doc/src/build/cli-client.md#connect-to-devnet). | ||
* Make sure you have two addresses with gas, you can use the new-address command to create new addresses `sui client new-address`, | ||
you can skip this step if you are going to play with a friend :) | ||
* [Request gas tokens](https://github.com/MystenLabs/sui/blob/main/doc/src/explore/devnet.md#request-gas-tokens) for all addresses that will be used to join the game. | ||
1. Install `sui` and `rpc-server` binaries following the [Sui installation](https://github.com/MystenLabs/sui/blob/main/doc/src/build/install.md#binaries) docs. | ||
1. [Connect to Sui Devnet](https://github.com/MystenLabs/sui/blob/main/doc/src/build/cli-client.md#connect-to-devnet). | ||
1. [Make sure you have two addresses with gas](https://github.com/MystenLabs/sui/blob/main/doc/src/build/cli-client.md#adding-accounts-to-the-client) by using the `new-address` command to create new addresses: | ||
```shell | ||
sui client new-address | ||
``` | ||
You can skip this step if you are going to play with a friend. :) | ||
1. [Request Sui tokens](https://github.com/MystenLabs/sui/blob/main/doc/src/build/install.md#sui-tokens) for all addresses that will be used to join the game. | ||
|
||
#### 2. Publish the move contract | ||
* [Download the Sui source code](https://github.com/MystenLabs/sui/blob/main/doc/src/build/install.md#source-code) | ||
* Publish the [`games` package](https://github.com/MystenLabs/sui/tree/main/sui_programmability/examples/games) | ||
using the Sui client and copy down the package object ID. | ||
1. [Download the Sui source code](https://github.com/MystenLabs/sui/blob/main/doc/src/build/install.md#source-code). | ||
1. Publish the [`games` package](https://github.com/MystenLabs/sui/tree/main/sui_programmability/examples/games) | ||
using the Sui client: | ||
```shell | ||
sui client publish --path /path-to-sui-source-code/sui_programmability/examples/games --gas-budget 10000 | ||
``` | ||
1. Record the package object ID. | ||
#### 3. Create a new tic-tac-toe game | ||
* run the following command in the sui source code folder to start a new game. | ||
1. Run the following command in the Sui source code directory to start a new game, replacing the game package objects ID with the one you recorded: | ||
```shell | ||
cargo run --example tic-tac-toe -- --game-package-id <<games package object ID>> new-game | ||
``` | ||
this will create a game for the first two addresses in your keystore by default. If you want to specify the identity of each player, | ||
you can use the following command | ||
This will create a game for the first two addresses in your keystore by default. If you want to specify the identity of each player, | ||
use the following command and replace the variables with the actual player's addresses: | ||
```shell | ||
cargo run --example tic-tac-toe -- --game-package-id <<games package object ID>> new-game --player-x <<player X address>> --player-o <<player O address>> | ||
``` | ||
* Copy the game id and pass it to your friend to join the game. | ||
1. Copy the game ID and pass it to your friend to join the game. | ||
#### 4. Joining the game | ||
* run the following command in the sui source code folder to join the game. | ||
```shell | ||
cargo run --example tic-tac-toe -- --game-package-id <<games package object ID>> join-game --my-identity <<address>> --game-id <<game ID>> | ||
``` | ||
Run the following command in the Sui source code directory to join the game, replacing the game ID and address accordingly: | ||
```shell | ||
cargo run --example tic-tac-toe -- --game-package-id <<games package object ID>> join-game --my-identity <<address>> --game-id <<game ID>> | ||
``` |