-
Notifications
You must be signed in to change notification settings - Fork 1
Call creation
VladyslavLapin edited this page May 7, 2024
·
1 revision
Creating a transaction call in Unity using the Vara SDK involves handling asynchronous transactions and monitoring their state. Unlike immediate results, calls return a subscription to track transaction status and results.
The process in Unity, with Substrate.Vara.NET.NetApiExt, involves setting up the call parameters and initiating the transfer. The response is managed through a subscription, allowing for real-time tracking of the transaction within the blockchain.
/// <summary>
/// Transfer keep alive.
/// </summary>
/// <returns></returns>
public async Task<string> TransferKeepAliveAsync()
{
var client = (VaraExt.SubstrateClientExt)_client;
var accountAlice = new AccountId32();
accountAlice.Create(Utils.GetPublicKeyFrom(Alice.Value));
var account32 = new AccountId32();
account32.Create(Utils.GetPublicKeyFrom("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"));
var multiAddress = new EnumMultiAddress();
multiAddress.Create(MultiAddress.Id, account32);
var amount = new BaseCom<U128>();
amount.Create(10000000);
var transferKeepAlive = BalancesCalls.TransferKeepAlive(multiAddress, amount);
var subscription = await GenericExtrinsicAsync(client, Alice, transferKeepAlive, CancellationToken.None);
return subscription;
}