LYNC Account Abstraction SDK

LYNC AA SDK is a no-code Unity SDK supporting PC (MacOS and Windows) and Mobile (Android and iOS)

LYNC Unity Account Abstraction SDK, your solution to seamless gamer onboarding in Web3 Games! Enable effortless logins via socials, wallets, email, and more. Integrate swiftly into any game on Mac, Windows, Android, iOS, or browser. Simplify the gaming experience with LYNC AA SDK, connecting gamers effortlessly.

Get your API Key

Please get your API key before downloading the SDK from here

Installation

Download the LYNC Account Abstraction SDK from Here

Import the SDK .unitypackage file to your project. or simply drag and drop .unitypackage file to your project.

Once the Account Abstraction SDK package has finished importing into your Unity project, you can begin integrating it into your game.

The Folder structure looks like this

Integrating AA SDK in Unity

There are 2 Example Projects present in the SDK: Assets -> LYNC-AA-SDK -> Example / Example-2

You can find the example scene in the folders. Simply pass the API key in lyncManager GameObject.

To test, Build and Run after adding this scene in (Scene in Build).

Setup the Project

To use LYNC Manager Prefab, it needs to be attached to the first scene. This will serve as the starting point for your project.

In LYNC Manager Prefab, be sure to provide the following details:

  1. Choose chain

  2. Pass a deep link name (example: lync/gameName etc.)

Integrating Login or Transaction Layer via Account Abstraction in Unity

Login and Transactions can be done once the action is triggered.

The Sample Code for Login can be found at LoginTransactionExample.cs and ExampleLogin.cs

Note: Make sure to Import LYNC.

using LYNC;
using LYNC.Wallet;

Example (Event Trigger):

LYNC ready Should be a function which has an argument of type "LyncManager"

LyncManager.onLyncReady += LyncReady;

private void LyncReady(LyncManager Lync)
    {
        // Once LYNC is ready, you can do any steps like Login, Logout, Transactions etc.
    }

To Login:

Lync.WalletAuth.ConnectWallet((wallet) =>
{
    addressTxt.text = "Wallet Address: " + wallet.publicAddress;
    loginDateTxt.text = "Login Date: " + wallet.loginDate.ToString();
});

To Logout:

Lync.WalletAuth.Logout();

To do transactions:

To do transactions, TokenExample.cs and LoginTransactionExample.cs can be taken as a reference.

Pass in the Contract Address and Function Name Example: MintNFT(). MintNFT(unit256 id, unit256 amount)

Args are not compulsory parameters, but if the function accepts any argument, make sure to pass them.

To do it from the script:

LyncManager.Instance.blockchainMiddleware.SendTransaction(contractAddress, functionName, args, onSuccess,onError);

onSuccess: Once the transactions are completed, this handles what to do.

onError: If the transactions failed, this handles what to do.

Setup Gasless Transactions with Biconomy

To enable gasless transactions via biconomy, Register a new paymaster on the Biconomy Dashboard.

Once done, Get the API Key and Pass it in to the LYNC Manager.

Setup the gas tank, in Policies create a new one and pass the contract address

That's it, now you can do the gasless transaction on this contract address passing in the LYNC AA SDK.

Some common bugs and their resolutions

Problem: The type name 'HttpUtility' could not be found in the namespace 'System.Web'.

Assets\LYNC-AA-SDK\Auth\DeepLink\DeepLinkManager.cs(76,35):
error CS1069: The type name 'HttpUtility' could not be found in the namespace 'System.Web'.
This type has been forwarded to assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 
Consider adding a reference to that assembly.

Solution:

Change the API Compatibility Level To change the . NET profile, go to Edit > Project Settings > Player >Other settings.

Please change the .NET to 2.1 or 2

Problem: Newtonsoft JSON is missing.

Solution: Please, Add this as a git URL in adding package

com.unity.nuget.newtonsoft-json

Last updated