Creating a call - ajuna-network/Polkadot.Unity.SDK GitHub Wiki

Creating a transaction call in Unity using the Polkadot SDK involves handling asynchronous transactions and monitoring their state. Unlike immediate results, calls return a subscription to track transaction status and results.

For instance, executing a balance.transferKeepAlive call with a MultiAddress destination and a Compact<U128> value is similar to using Polkadot.JS developer UI.

image

The process in Unity, with Substrate.Polkadot.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 = (PolkadotExt.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;
        }
⚠️ **GitHub.com Fallback** ⚠️