Skip to content

Latest commit

 

History

History
 
 

sui-sdk

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Rust SDK examples

This directory contains examples of interacting with a Move language smart contract using the Sui Rust SDK. See the introduction to the Rust SDK for additional details.

Tic Tac Toe

Demo quick start

1. Prepare the environment

  1. Install sui and rpc-server binaries following the Sui installation docs.
  2. Connect to Sui Devnet.
  3. Make sure you have two addresses with gas by using the new-address command to create new addresses:
    sui client new-address ed25519
    New address can be created with key scheme flag {secp256k1 | ed25519}. You can skip this step if you are going to play with a friend. :)
  4. Request Sui tokens for all addresses that will be used to join the game.

2. Publish the move contract

  1. Download the Sui source code.
  2. Publish the games package using the Sui client:
    sui client publish --path /path-to-sui-source-code/sui_programmability/examples/games --gas-budget 10000
  3. Record the package object ID.

3. Create a new tic-tac-toe 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:
    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, use the following command and replace the variables with the actual player's addresses:
    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>>
  2. 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 directory to join the game, replacing the game ID and address accordingly:

cargo run --example tic-tac-toe -- --game-package-id <<games package object ID>> join-game --my-identity <<address>> --game-id <<game ID>>