Giter Site home page Giter Site logo

moosesnwoop / unity-algorand-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from careboo/unity-algorand-sdk

1.0 0.0 0.0 85.03 MB

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

License: MIT License

Shell 0.05% JavaScript 1.31% C# 96.84% CSS 0.16% HLSL 0.24% ShaderLab 1.40%

unity-algorand-sdk's Introduction

The Algorand Logo
Algorand SDK for Unity

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.

Table of Contents

Requirements

This package supports the following build targets and Unity versions:

Unity Version Windows Mac OS Linux Android iOS WebGL
2020.3
2021.3 ✴️
2022.2 ✴️
  • ✅ All APIs are supported.
  • ✴️ Algorand.Unity.Net is not supported. This assembly is used to enable cross-compatibility between the .NET SDK and the Unity SDK.
  • ❌ Not supported. Use at your own risk.

Common Usages

Make a payment transaction:

using Algorand.Unity;

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 Algorand.Unity.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 Algorand.Unity;
using Algorand.Unity.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

Algorand SDK for Unity is now available!

Getting Started

Read Getting Started to learn the basic workflows for developing on Algorand.

Documentation Site

Docs for this version were generated at https://careboo.github.io/unity-algorand-sdk/4.1.

Samples

Some of the samples are built on WebGL and hosted on GitHub Pages.

unity-algorand-sdk's People

Contributors

jasonboukheir avatar semantic-release-bot avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.