Skip to content

An Algorand SDK for Unity. Use the Algorand blockchain in your video game.

License

Notifications You must be signed in to change notification settings

deltav-deltaverse/unity-algorand-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Unity Algorand SDK

Caution

This package has not been audited and isn't suitable for production use.

Integrate your game with Algorand, a Pure Proof-of-Stake blockchain overseen by the Algorand Foundation. Create and sign Algorand transactions, use Algorand's REST APIs, and connect to any Algorand wallet supporting WalletConnect.

Requirements

This package supports the following build targets and Unity versions:

Unity Version Windows Mac OS Linux Android iOS WebGL
2020.3
2021.2

Common Usages

Make a payment transaction:

using AlgoSdk;

var sender = "<your sender address>";
var receiver = "<your receiver address>";
var algod = new AlgodClient("https://node.testnet.algoexplorerapi.io");
var suggestedTxnParams = await algod.GetSuggestedParams();
var microAlgosToSend = 1_000_000L;
var paymentTxn = Transaction.Payment(sender, suggestedTxnParams, receiver, microAlgosToSend);

Sign the transaction with an account:

var account = Account.GenerateAccount();
var signedTxn = account.SignTxn(paymentTxn);

Sign the transaction with kmd:

var kmd = new KmdClient("<host of kmd>");
var walletToken = await kmd.InitWalletHandleToken("<your wallet id>", "<your wallet password>");
var signedTxn = await kmd.SignTransaction(paymentTxn.Sender, paymentTxn.ToSignatureMessage(), walletToken, "<your kmd wallet password>");

Sign the transaction with WalletConnect:

using AlgoSdk.WalletConnect;

SavedSession savedSession = [...];
var session = new AlgorandWalletConnectSession(savedSession);
var walletTransaction = WalletTransaction.New(paymentTxn);
var signedTxns = await session.SignTransactions(new[] { walletTransaction });
var signedTxn = signedTxns[0];

Send the signed transaction:

await algod.SendTransaction(signedTxn);

Initiate a WalletConnect session and generate a QR Code:

using AlgoSdk;
using AlgoSdk.WalletConnect;
using UnityEngine;

var dappMeta = new ClientMeta
{
    Name = "<name of your dapp>",
    Description = "<description of your dapp>",
    Url = "<url of your dapp>",
    IconUrls = new[]
    {
        "<icon1 of your dapp>", "<icon2 of your dapp>"
    }
};
var session = new AlgorandWalletConnectSession(dappMeta);
var handshake = await session.StartConnection();
Texture2D qrCode = handshake.ToQrCodeTexture();

Installation

Open UPM

The easiest way to install is to use Open UPM as it manages your scopes automatically. You can install Open UPM here. Then use the Open UPM CLI at the root of your Unity project to install.

> cd <your unity project>
> openupm add com.careboo.unity-algorand-sdk

Manually Adding UPM Scopes

If you don't want to use Open UPM, it's straightforward to manually add the UPM registry scopes required for this package. See Unity's official documentation on Scoped Registries.

Unity Asset Store

The SDK is also available in the Unity Asset Store.

Getting Started

Documentation

The documentation built for a specific version is hosted at:

https://careboo.github.io/unity-algorand-sdk/{version}/

Read Your First Transaction to learn the basics on creating, signing, and sending transactions. The WalletConnect guide teaches about how to implement WalletConnect in your application.

About

An Algorand SDK for Unity. Use the Algorand blockchain in your video game.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%