Skip to content

Commit

Permalink
update readme, version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamas Szucs committed May 25, 2023
1 parent 8beb8e0 commit 331b3ff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Assets/SuiUnitySDK/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.originbyte.suiunitysdk",
"displayName": "SuiUnitySDK",
"author": { "name": "Origin Byte", "url": "https://github.com/Origin-Byte" },
"version": "0.2.7",
"version": "1.2.0",
"unity": "2021.3",
"description": "Connecting Unity game developers to Sui and Origin Byte's NFT ecosystem.",
"keywords": [ "web3", "blockchain", "gaming", "SuiUnitySDK" ],
Expand Down
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Connecting Unity game developers to Sui and Origin Byte's NFT ecosystem.
# Features
- For Rpc clients’ direct interaction with the Sui JSON-RPC https://docs.sui.io/sui-jsonrpc
- Read API
- Write API
- Event Read API
- Transaction Builder Api
- Event streaming support
Expand All @@ -15,11 +16,12 @@ Connecting Unity game developers to Sui and Origin Byte's NFT ecosystem.
- [SLIP-0010](https://github.com/satoshilabs/slips/blob/master/slip-0010.md) : Universal private key derivation from master private key also supported
- Sign transactions
- Store key pair in PlayerPrefs
- Interact with Origin Byte Nft Protocol (0.22) https://github.com/Origin-Byte/nft-protocol
- Interact with Origin Byte Nft Protocol (1.1.0) https://github.com/Origin-Byte/nft-protocol
- Helper Scripts and prefabs to load NFTs (even Capys!)
- Windows desktop and WebGL platforms tested
- Unity 2021.3.10f1 LTS or later supported
- Samples are using Sui 0.27.0 devnet
- Samples are using Sui 1.2.0 testnet
- Please note, some of the samples are being updated!

![Capy Image Nft loader](/imgs/capy_loader_1.webp "Capy Image Nft loader")

Expand Down Expand Up @@ -92,8 +94,10 @@ Now you are ready to execute transactions that require signature.
Enter any address and see the results as formatted JSON.

```csharp
var ownedObjectsResult = await SuiApi.Client.GetObjectsOwnedByAddressAsync(address);
Ouput.text = JsonConvert.SerializeObject(ownedObjectsResult.Result, Formatting.Indented);
var address = Input.text;
var filter = ObjectDataFilterFactory.CreateMatchAllFilter(ObjectDataFilterFactory.CreateAddressOwnerFilter(address));
var ownedObjectsResult = await SuiApi.Client.GetOwnedObjectsAsync(address, new ObjectResponseQuery() { Filter = filter }, null, null);
Ouput.text = JsonConvert.SerializeObject(ownedObjectsResult.Result, Formatting.Indented);
```

## RPC Move call and execute transaction samples
Expand All @@ -106,20 +110,26 @@ See move logic here: https://github.com/MystenLabs/sui/blob/main/sui_programmabi

```csharp
var signer = SuiWallet.GetActiveAddress();
var moveCallTx = new MoveCallTransaction()
{
Signer = signer,
PackageObjectId = "0x2554106d7db01830b6ecb0571c489de4a3999163",
Module = "counter",
Function = "increment",
TypeArguments = ArgumentBuilder.BuildTypeArguments(),
Arguments = ArgumentBuilder.BuildArguments( SharedCounterObjectId ),
Gas = (await SuiHelper.GetCoinObjectIdsAboveBalancesOwnedByAddressAsync(SuiApi.Client, signer, 1, 10000))[0],
GasBudget = 5000,
RequestType = SuiExecuteTransactionRequestType.WaitForEffectsCert
};

await SuiApi.Signer.SignAndExecuteMoveCallAsync(moveCallTx);
var moveCallTx = new MoveCallTransaction()
{
Signer = signer,
PackageObjectId = PackageObjectId,
Module = "counter",
Function = "increment",
TypeArguments = ArgumentBuilder.BuildTypeArguments(),
Arguments = ArgumentBuilder.BuildArguments( SharedCounterObjectId ),
Gas =null,
GasBudget = 10000000,
RequestType = ExecuteTransactionRequestType.WaitForLocalExecution
};

var moveCallResult = await SuiApi.Client.MoveCallAsync(moveCallTx);

var txBytes = moveCallResult.Result.TxBytes;
var rawSigner = new RawSigner(SuiWallet.GetActiveKeyPair());
var signature = rawSigner.SignData(Intent.GetMessageWithIntent(txBytes));

var txResponse = await SuiApi.Client.ExecuteTrans
```

## Mint Nft using Origin Byte Nft Protocol
Expand All @@ -134,30 +144,27 @@ This sample uses a pre-minted collection of [DEADBYTES](https://github.com/tomfu

### Setup your collection
1. Publish https://github.com/tomfurrier/nft-protocol/blob/dead-bytes/sources/collection/deadbytes.move or a similar, std_collection. More information about the [nft protocol](https://github.com/Origin-Byte/nft-protocol) .
2. update the MintCapId and signer if needed
1. Publish https://github.com/tomfurrier/nft-protocol/blob/main/example_collections/examples/sources/suitraders.move or a similar. More information about the [nft protocol](https://github.com/Origin-Byte/nft-protocol) .
3. Mint Nfts by calling NftProtocolClient.MintNftAsync

```csharp
// we can sign the mint transaction with the wallet that deployed the contract
var signerKeyPair = Mnemonics.GetKeypairFromMnemonic(SAMPLE_SIGNER_MNEMONIC);
var signer = new Signer(SuiApi.Client, signerKeyPair);
var nftProtocolClient = new NftProtocolClient(SuiApi.Client, signer);
var keypair = SuiWallet.GetActiveKeyPair();
var nftProtocolClient = new NftProtocolClient(SuiApi.Client, SuiWallet.GetActiveKeyPair());

var randomFaceIndex = Random.Range(1, 9);
var txParams = new MintNft()
var txParams = new MintSuitradersNft()
{
Attributes = new Dictionary<string, object>()
{
{ "nft_type", "face" },
},
Description = "You can use this as a face of your character in the game!",
MintCap = NFTMintCapIdField.text,
Recipient = TargetWalletAddressInputField.text,
ModuleName = deadBytesType.Module,
ModuleName = "suitraders",
Function = "airdrop_nft",
Name = $"Face {randomFaceIndex}",
PackageObjectId = mintCapType.PackageId,
Signer = signerKeyPair.PublicKeyAsSuiAddress,
PackageObjectId = NFTPackageObjectIdField.text,
Signer = keypair.PublicKeyAsSuiAddress,
Url = $"https://suiunitysdksample.blob.core.windows.net/nfts/face{randomFaceIndex}.png"
};

Expand Down Expand Up @@ -216,7 +223,6 @@ Dependencies used by the Samples can be found in ./Assets/SuiUnitySDK/Samples/Pl
- Mobile platform support (iOS, Android)
- WalletConnect
- Streaming RPC client, Event subscription
- Secp256k1 keypair support
- More samples
- Origin-Byte NFT ecosystem access from Unity
- Higher level APIs, easy-to-use Prefabs
Expand Down

0 comments on commit 331b3ff

Please sign in to comment.