How to Deploy a Game to the Blockchain - Encode Club Sui Series #6

In this final video of our six part educational series, Shayan explains how to test and deploy a game to the Sui network.

In the sixth and final video of Encode Club’s Sui series, we show how to test and deploy the role playing game (RPG) objects we created in the previous session to the Sui network.

The Sui Foundation partnered with Encode Club to offer a series of six developer-focused videos. This series will range from the basics of Sui to tutorials about building smart contracts and working with objects in Sui Move.

Learning Highlights

In the fifth installment of this series, we showed how to write objects and functions for an RPG, including character, item, and non-player character creation. Now we’ll explain how to make sure our code works, and how to deploy it to the Sui network so people can begin playing the game.

Testing Sui Move Packages

Once we’ve written our code, we want to test its functionality. Two types of testing frameworks exist for Move, a general Move testing framework and a Sui-specific testing framework. As Sui Move includes several features that are not present in core Move, we’ll focus on the latter.

Sui-specific testing can be found in the sui::test_scenario module. The test_scenario module provides an environment where builders can test their code via a series of transactions. All updates to the Sui ledger occur via transactions, and Move calls in Sui are encapsulated in transactions. Builders can create mock transactions to see the interactions between several different transactions (i.e. one transaction creating an object, another transaction transferring that object, and another transaction mutating that object).

Publishing Sui Move Packages

Now that we’ve tested our code, we can actually publish it! Sui Move functions can only be called once the corresponding package is published to the Sui network, where it is represented as an immutable object on the Sui ledger. To publish the package, navigate to the package directory and, from the command line interface (CLI), call sui client publish --gas-budget <gas_budget> (i.e. <gas_budget> of 2000). If successful, you will have published your package to the Sui network!

Refer to the Sui documentation on debugging and publishing packages for more detailed information.

Calling Sui Move Code

Making calls to our code on the Sui network lets modules interact with each other, creating the action in the game. In our example in the video, we used Sui Explorer to call the code, which made it easier to visualize the lesson. We could call the same functions using the Sui CLI. When creating your own dApps, you will probably want to give users a nice frontend rather than having them use the Sui Explorer or CLI. The Sui JSON-RPC API lets you connect your smart contracts to a frontend.

Thank you!

Thank you everyone for making it to the final installment of the Sui Foundation x Encode Club Sui Educate series! We hope that by now you’ll have what it takes to create your own dapps on the Sui network. Happy hacking!
source - Deploy a Game to the Blockchain - Encode Club Sui Series #6