Sui-Godot-SDK is a package to help developers integrate Sui blockchain technology into their godot projects.
project_demo/
: This directory contains the example use.resources/
: A place for various resources needed for the project, like images, data files, or other assets.modules/
: This directory contains the project's source code.
- Compatibility with main, dev, and test networks.
- Integration with Sui blockchain using native libraries.
- Cross-platform support (macOS, Windows, Linux).
- Mint new NFTs.
- Transfer NFTs to other addresses.
- Retrieve wallet objects related to NFTs.
- Conversion between raw and managed data structures for NFT objects.
- Create and manage multisig wallets.
- Create transactions from multisig wallets.
- Sign and execute transactions using multisig wallets.
- Handling of multisig data structures and transaction results.
- Basic serialization and deserialization of Sui types.
- Support for various Sui types including integers, floats, booleans, strings, and addresses.
- Conversion of Sui types to BCS (Binary Canonical Serialization) format.
- Create and manage transaction builders.
- Add various types of commands to transactions (e.g., move call, transfer object, split coins, merge coins).
- Execute transactions with or without a sponsor.
- Singleton pattern for easy access to wallet functionalities.
- Generate new wallets with specified key schemes and word lengths.
- Import wallets from private keys.
- Import wallets from mnemonics.
- List all wallets.
- Display wallet details.
- Generate and add new keys to the wallet.
Platforms | Godot Version | Status |
---|---|---|
Mac / Linux / Windows | Godot 4.3 | Fully Tested |
This guide provides step-by-step instructions for installing and setting up on macOS / Linus / Windows platforms. Ensure you have the following prerequisites installed to build the project:
- Visual Studio Code with C++ development environment
- Install Sui Follow this guide to install Sui https://docs.sui.io/guides/developer/getting-started/sui-install
Run follow command to setting Environment before testing:
-
Check Sui Client Environment:
sui client envs
NOTE:If you don't have DevNet, please run CMD :
sui client new-env --alias devnet --rpc https://fullnode.devnet.sui.io:443
-
Switch to devnet network:
sui client switch --env devnet
-
Check current network:
sui client active-env
NOTE: The return should be devnet
-
Get the active address:
sui client active-address
-
Request token:
sui client faucet
NOTE: Wait for 60s to get the tokens
-
Check the gas coin objects for the active address:
sui client gas
-
Build Project:
- In Sui-Godot-SDK directory run CMD:
git clone -b 4.3 https://github.com/godotengine/godot
- Change working directory to godot:
cd godot
- Build project cmd:
scons custom_modules=../modules
-
Get godot engine: In Sui-Godot-SDK directory run CMD:
git clone -b 4.3 https://github.com/godotengine/godot
-
Compile the engine:
cd godot scons custom_modules=../modules
Sui-Godot-SDK can integrate into your own godot projects.
You can custom your project_demo
and run below built file in directory to check your source code.
./godot/bin/<godot_binary>
NOTE:
-
If you are running on Windows environment, please copy file
sui_rust_sdk.dll
atmodules/sui_sdk/libs
directory intogodot/bin
directory -
If you are running on Linux environment, please run cmd below to set environment variable:
source ./.bashrc
The SDK comes with several examples that show how to leverage the Rust2C-Sui-SDK to its full potential. The examples include Wallet Creation and Management, Token Transfers, NFT Minting, Account Funding, and Multi-signature.
var suiSDK = SuiSDK.new()
The SuiWallet
class provides various functionalities to manage wallets in your Unity project. Below are some examples of how touse the SuiWallet
class.
To generate a new wallet with a specified key scheme and word length:
var newWallet = suiSDK.generateWallet("ED25519", "12")
print(wallet.get_address())
print(wallet.get_mnemonic())
print(wallet.get_public_base64_key())
print(wallet.get_private_key())
print(wallet.get_key_scheme())
To import a wallet using a private key:
var importResult = suiSDK.importFromPrivateKey("your_private_key_here")
if importResult.get_status() == 0:
print("Import wallet " + importResult.get_address() + " successfully")
else:
print(importResult.get_error())
To import a wallet using a mnemonic phrase:
var importResult = suiSDK.importFromMnemonic("your_mnemonic_phrase_here")
if importResult.get_status() == 0:
print("Import wallet " + importResult.get_address() + " successfully")
else:
print(importResult.get_error())
To list all wallets:
var wallets = suiSDK.getWallets()
for wallet in wallets:
print(wallet.get_address())
print(wallet.get_mnemonic())
print(wallet.get_public_base64_key())
print(wallet.get_private_key())
print(wallet.get_key_scheme())
To generate and add a new key to the wallet:
var wallet = sdk.generateAndAddKey()
The SuiTransactionBuilder
class allows you to create and manage transactions. Below are some examples of how to use the SuiTransactionBuilder
class.
To create a new transaction:
var builder = SuiProgrammableTransactionBuilder.new()
To add a move call command to the transaction:
var arguments = SuiArguments.new()
var typeTag = SuiTypeTags.new()
suiSDK.addMoveCallCommand(builder, "package_id", "module_name", "function_name", typeTag, arguments)
To add a transfer object command to the transaction:
var agreements = SuiArguments.new()
suiSDK.addArgumentResult(agreements, 0)
var recipient = SuiArguments.new()
var recipientBscBasic = SuiBSCBasic.new()
recipientBscBasic.BSCBasic("address", "recipient_address")
suiSDK.addTransferObjectCommand(builder, agreements, recipient)
To execute the transaction:
var gas = 0.005 * 10**9
var result = suiSDK.executeTransaction(builder, "sender_address", gas)
print(result)
The sui_builder
provides methods for basic serialization and deserialization of Sui types. Below are some examples of how to use the sui_builder
.
To serialize data of a specific Sui type:
var amount = 1;
var amountBscBasic = SuiBSCBasic.new()
amountBscBasic.BSCBasic("u64", str(int(amount)*10**9))
The sui_multisig
provides functionalities to create and manage multisig wallets. Below are some examples of how to use the sui_multisig
.
To create a new multisig wallet:
var address1 = "wallet_address_1"
var address2 = "wallet_address_2"
var address3 = "wallet_address_3"
var addresses = [address1, address2, address3]
var weights = [1, 1, 2]
var multiSig = suiSDK.getOrCreateMultisig(addresses, weights, 3)
To create a transaction from a multisig wallet:
var amount = 1 *10**9
var txBytes = suiSDK.createTransaction("wallet_address", "wallet_address", amount)
To sign and execute a transaction using a multisig wallet:
var address1 = "wallet_address_1"
var address2 = "wallet_address_2"
var address3 = "wallet_address_3"
var signer_addresses = [address2, address3]
var message = suiSDK.signAndExecuteTransaction(multiSig, txBytes, signer_addresses)
print(message)
The sui_nfts
provides functionalities to mint, transfer, and retrieve NFT-related wallet objects. Below are some examples of how to use the sui_nfts
.
To mint a new NFT:
var message = suiSDK.mintNft("package_id", "sender_address", "NFT Name", "NFT Description", "NFT URI")
print(message)
To transfer an NFT to another address:
var message = suiSDK.transferNft("package_id", "sender_address", "nft_id", "recipient_address")
print(message)
To retrieve wallet objects related to NFTs:
var nfts = suiSDK.getWalletObjects("wallet_address", "object_type")
This project is licensed under the Apache-2.0 License. Refer to the LICENSE file for details.