-
Notifications
You must be signed in to change notification settings - Fork 2
Reddio Unity SDK
Reddio Unity SDK provides unity CSharp scripts for using Reddio API, in async/await pattern or Unity Coroutine pattern.
- Reddio Unity SDK requires UniTask for providing APIs in Unity Coroutine style, you can download UniTask from here
- Download the latest version of Reddio Unity SDK here.
- Optional: If you want to interact with the wallet application (eg. MetaMask), you should install WalletConnect by following these instructions
After setup these packages for your Unity project, you can write scripts for your application with Reddio API.
With async/await:
public async void GetBalance()
{
var reddioRestClient = ReddioRestClient.Testnet();
var balance = await reddioRestClient.GetBalance(
new GetBalanceMessage("0x1c2847406b96310a32c379536374ec034b732633e8675860f20f4141e701ff4", ""));
Debug.Log("balance: " + balance);
}
Or with Unity Coroutine:
public void OnClick()
{
StartCoroutine(GetBalance());
}
public IEnumerator GetBalance()
{
var reddioRestClient = ReddioRestClient.Testnet();
var unityClient = new ReddioUnityRestClient(reddioRestClient);
yield return unityClient.GetBalance(
new GetBalanceMessage("0x1c2847406b96310a32c379536374ec034b732633e8675860f20f4141e701ff4", ""),
(balance) =>
{
Debug.Log("balance: " + balance);
// your codes here
},
(error) => { // resolve the exception });
}
IReddioRestClient
is the interface of Low-Level API for using Reddio API, you could find the corresponding methods for each rest API.
ReddioRestClient
is the implementation of Low-Level Rest API, and there are two factory methods for instantiating: ReddioRestClient.mainnet()
and ReddioRestClient.testnet()
.
IReddioClient
is the interface for High-Level API. It encapsulates the complex and boring codes for signing the request with StarEx Cryptographic Library for easy-to-use purposes.
The default implementation is ReddioClient
.
We recommend using High-Level API for a better experience.
CryptoService
provides interaction with StarEx Cryptographic, like Signing and Public-key cryptography related methods.
- StarEx Cryptographic Library
- Low-Level and High-Level Reddio API client.