LYNC
DashboardSupport
  • 👋Introducing LYNC
  • Products
    • LYNC Account Abstraction SDK
    • LYNC Account Abstraction WebGL SDK
    • Metamask Wallet
    • LYNC Metamask PC SDK
    • OKX Wallet
    • LYNC In-Game Marketplace SDK
    • NFT Fetcher
    • No-Code Smart Contract Deployer
    • EVM Lootbox SDK
      • Getting Started
      • Using the SDK
        • Creating a new lootbox
        • Opening a lootbox
        • Claiming rewards
        • Whitelisting users using lootbox
        • Lootbox admin functions
        • Useful information functions from LyncLootBox class
        • Multicall : opening and claiming multiple lootboxes in a single transaction
      • Example Codes in React & TypeScript
        • Example code for creating a new lootbox
        • Example code for opening a lootbox
        • Example code for claiming a lootbox
    • Launch your products on Telegram
      • Configure Your Telegram Bot
      • Deploying Your Product on TG
  • APTOS
    • LYNC Paymaster - Supporting Aptos
      • How to Register on LYNC Dashboard
      • How to Create Paymaster
      • How to Fund the Paymaster
      • Module & Function Whitelist
      • How to Integrate Paymaster
        • Unity
        • API
        • JavaScript/ TypeScript
    • LYNC Unity Aptos SDK
    • Keyless Accounts
      • Configure Your OIDC Provider
      • Integrate Keyless in Unity
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
        • Send generic transactions on Aptos
    • LYNC Social Login SDK on Aptos
      • Getting Started
      • Using the SDK
      • Example Codes in React & TypeScript
      • Types Used in the Methods Provided by the SDK
      • Other Specification
    • LYNC Aptos Lootbox
      • Getting Started
      • Creating a Lootbox
      • Opening a Lootbox
      • Claiming the Rewards
      • Conclusion
  • Movement Labs
    • 📇Indexer
      • How to run index custom data?
      • Example Queries
        • Get Token Info
        • Get Token Balances
        • Get NFTs Owned by an Account
    • NFT Deployer
    • LYNC Social Login SDK on Movement
      • Getting Started
      • Using the SDK
      • Example Codes in React & TypeScript
      • Types and Enums Used in the Methods Provided by the SDK
      • Other Specification
    • LYNC Unity Movement SDK
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
    • LYNC Paymaster - Supporting Movement
      • How to Register on LYNC Dashboard
      • How to Create Paymaster
      • How to Fund the Paymaster
      • Module & Function Whitelist
      • How to Integrate Paymaster
        • JavaScript/ TypeScript
  • Supra
    • LYNC Paymaster - Supporting Supra L1
      • How to Register on LYNC Dashboard
      • How to Create Paymaster
      • How to Fund the Paymaster
      • Module & Function Whitelist
      • How to Integrate Paymaster
        • JavaScript/ TypeScript
    • LYNC Unity SUPRA SDK
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
  • Fuel
    • LYNC Unity Fuel SDK
    • LYNC NFT Deployer
      • Introduction
      • Getting Started
      • Deploying Your NFTs
        • Launch Your Entire Collection
      • Troubleshooting and FAQs
    • LYNC Fuel Lootbox
      • Getting Started
      • Creating a Lootbox
      • Opening a Lootbox
      • Claiming the Rewards
      • Conclusion
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
    • Fuel Marketplace NPM SDK
      • Getting Started
      • Using the SDK
        • Using hooks to get the marketplace data
        • Using services provided by the SDK to list, buy, and manage tokens
        • Some useful functions provided by the SDK
        • Error codes for the SDK
        • Interfaces and Enums provided by the SDK
      • Support
  • Metis
    • Wallet Creation and Transaction APIs
      • Pre-requisites
      • Integration
        • API Overview
        • Create a new wallet
        • Get already created wallet
        • Mint NFT transactions
  • NPM Packages
    • Marketplace
      • Hook: useAllCollectionNFT
      • Hook: useAllBuyNFT
      • Hook: useAllOwnerNFT
      • Hook: useNFTDetails
      • Hook: useAllNFTForRent
Powered by GitBook
On this page
  • Get your API Key
  • Installation
  • Integrating AA SDK in Unity
  • Setup the Project
  • Integrating Login or Transaction Layer via Account Abstraction in Unity
  • Login Flow
  • No-Code Login Flow:
  • Login Flow with Code:
  • Transaction Flow
  • Gasless Transaction
  • Setup Gasless Transactions with Biconomy
  • User Paid Transaction
  • Some common bugs and their resolutions
  1. Products

LYNC Account Abstraction SDK

PreviousIntroducing LYNCNextLYNC Account Abstraction WebGL SDK

Last updated 11 months ago

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 ​

Installation

Download the LYNC Account Abstraction SDK from

Example Project:

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 3 Example Projects present in the SDK:

Assets -> LYNC-AA-SDK -> Example / Example-2 / Example-3

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 Account Abstraction. Attach LYNC Manager Prefab(Assets/LYNC-AA-SDK/LYNC Manager. prefab), on the starting 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. Choose Network (Testnet/ Mainnet)

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

Integrating Login or Transaction Layer via Account Abstraction in Unity

Login Flow

No-Code Login Flow:

You can attach the Login Example Script in any scene where you want users to login, by dragging and dropping a Button as a Game Object.

Login Flow with Code:

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

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

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();
            string smartAccountAddress = walletData.SmartAccount;
        });
        
        //To Logout:
        Lync.WalletAuth.Logout();
    }

To Check if the user is logged in or not:

WalletData walletData = WalletData.TryLoadSavedWallet();
if (walletData.WalletConnected){
    // User is already logged in
}
else{
    // Ask user to login
}

To get the User's wallet address, if the user is logged in

string EOAWalletAddress = walletData.PublicAddress
string SmartAccountAddress = walletData.SmartAccount
string EmailAddress=  walletData.Email;
string UserName = walletData.UserName;
string IdToken = walletData.IdToken;

To Fetch from PlayerPrefs:

string publicAddress = PlayerPrefs.GetString("_publicAddress");
string smartAccount = PlayerPrefs.GetString("_smartAccount");
string email = PlayerPrefs.GetString("_email");
string userName = PlayerPrefs.GetString("_userName");
string idToken = PlayerPrefs.GetString("_idToken");

To Login directly:

LyncManager.Instance.WalletAuth.ConnectWallet(loginUrl, (walletData) =>
{
    // Get all the user's wallet data from "walletData"
});

To Logout directly:

LyncManager.Instance.WalletAuth.Logout();

Transaction Flow

There are two methods for proceeding with a transaction:

  1. Gasless Transaction - Game Developer/ Game Studio will be sponsoring the transaction fee (Function Name: SendTransaction).

  2. User Paid Transaction- The Gamer/ User will be responsible for paying the gas fee and cost if any, required to do the transaction (Function Name: SendUserPaidTransaction).

Gasless Transaction

The limitation with gasless transaction is that, you can't have a cost required in the smart contract.

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

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.

User Paid Transaction

This will require gamers/ users to have some funds in their wallet on the chain you are using. There are two ways, You can ask users to send some tokens to this smart account or use LYNC on-ramp/ off-ramp for gamers allowing them to add funds via credit/ debit card, Apple Pay, Google Pay etc.

User Paid Transactions are similar to Gasless transactions to use, there is only one more parameter required to send is cost in ethers (ex. 0.1).

LYNC.LyncManager.Instance.blockchainMiddleware.SendUserPaidTransaction(contractAddress, functionName, arguments,cost, On721TrxCompleted, onError);

You can see the Assets/LYNC-AA-SDK/Example-2/TransactionExample.cs example script as a reference.

Some common bugs and their resolutions

Problem: Newtonsoft JSON is missing.

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

com.unity.nuget.newtonsoft-json
Example Projects
Pass LYNC API Key​

LYNC API Key ()

Pass in the Dapp API Key ( )

Web3 Auth Client ID ()

To enable gasless transactions via Biconomy, Register a new paymaster on the . Make sure you select the version: 1.0.1

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

The API Key can be generated from here
The API key can be generated from the Biconomy Dashboard
The API key can be generated from the Web3 Auth Dashboard
Biconomy Dashboard
LYNC Manager
here
Here​
https://github.com/LYNC-WORLD/LYNC-Unity-AA/tree/main/Assets/LYNC-AA-SDK
Assets -> Import Package -> Custom Package
SDK Folder Structure
Attach loginExample Script
Assets -> LYNC-AA-SDK -> Example-2 -> loginExample.cs
Token Transactions
Biconomy API Key
Contract Address setup