unityUnity SDK

The OpenDive Sui Unity SDK is the first fully-featured Unity SDK with offline transaction building.

This means that games built with our SDK can directly craft custom Move calls without relying Sui's "unsafe" RPC calls under the Transaction Builder APIarrow-up-right -- which in turn reduces the number of RPC / Network requests.

Our SDK fully supports mobile, desktop and WebGL application built with the Unity game engine.

About the Project

Sui-Unity-SDK is a C# Unity SDK designed to provide Unity developers with a seamless and efficient way to interact with the Sui Blockchain. Our aim is to lower the barrier for Unity developers, enabling them to leverage and integrate Sui's vast and versatile ecosystem into their games without having to delve deep into the complexities of the ecosystem.

Features

Make Account Transfer Quickly and Easily!

With how easy the library is to use, Sui-Unity-SDK gives you the power to quickly setup a Sui account and be able to transfer coins in only a few lines of code:

Requirements

Platforms
Unity Version
Installation
Status

Windows / Mac / iOS / Android / WebGL

2021.3.x

Unity Package Importer

Fully Tested

Windows / Mac / iOS / Android / WebGL

2022.2.x

Unity Package Importer

Fully Tested

Dependencies

Installation

Unity Package Importer

  • Download the latest sui-unity-sdk-xx.unitypackage file from Releasearrow-up-right

  • Inside Unity, Click on AssetsImport PackagesCustom Package. and select the downloaded file.

NOTE: As of Unity 2021.x.x, Newtonsoft Json is a common dependency. Prior versions of Unity require installing Newtonsoft.

Test Suite

The SDK's test suite can be found in the following directory: Assets/Sui-Unity-SDK/Tests.

The test suite covers:

  • Account - private / public keys, signatures and verification

  • Transactions - creation, signing, serialization, and deserialization

    • Coin Querying

    • Extended API

    • Governance API

    • Move Utilities

    • Read API

    • Write API

  • BCS serialization and deserialization

Using Sui-Unity-SDK

Sui-Unity-SDK is designed to be very easy to integrate into your own Unity projects. The main functionality comes from several key classes: SuiClient, FacetClient, TransactionBlock, and Account.

There are four core classes:

  • SuiClient - used to query the Sui blockchain

  • FaucetClient - used to request for airdrops

  • TransactionBlock - used to represent a transaction block object

  • Account - used for representing sui accounts

SuiClient

The RPC Client provides you with the fundamental transaction endpoints needed for interacting with the Sui Blockchain. The following showcases how to initialize the SuiClient.

As shown before, it only take a few lines of code to initialize a transfer for Sui coins. This is the main class developers will be leveraging to interact directly with the Sui Blockchain via RPC Client calls. Here's another example showing how to publish a package:

Here's also how to do various other calls:

FaucetClient

The Faucet Client allows the developer to leverage the ability to fund wallets on any of the non-main networks within the Sui Blockchain. This can easily speed up development times through automating the process of funding accounts. Here's an example on how to use the Faucet Client:

TransactionBlock

The Transaction Block is a local object that helps developers build out the serialized representation of transaction data. This is the core of utilizing offline transaction building, along with building out interactions with on-chain objects. Here is an example to build out a simple Move call:

As well, developers can utilize any arbitrary move calls published to the network. Here is an example using a serializer to set a value:

Account

Accounts within the SDK represent a Sui user's account, that give ease of access to the needed information you'd need for communicating with the Sui Blockchain. Here are some example initializations of accounts:

From there, you're able to retrieve the byte array of the private and public keys, along with signing and verifying messages and transactions, as the core function of an Account object, as shown here:

The developer can now use the Account to sign various messages and transactions for interacting with the Sui Blockchain, as shown here:

Developers can also verify the integrity of the message using the public key, as shown here:

License

Sui-Unity-SDK is released under the MIT license. See LICENSEarrow-up-right for details.

Last updated