LYNC Account Abstraction SDK
Last updated
Last updated
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.
Please get your API key before downloading the SDK from here
Download the LYNC Account Abstraction SDK from Here
Example Project: https://github.com/LYNC-WORLD/LYNC-Unity-AA/tree/main/Assets/LYNC-AA-SDK
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
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).
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:
LYNC API Key (The API Key can be generated from here)
Choose chain
Choose Network (Testnet/ Mainnet)
Pass in the Dapp API Key (The API key can be generated from the Biconomy Dashboard )
Web3 Auth Client ID (The API key can be generated from the Web3 Auth Dashboard)
Pass a deep link name (example: lync/gameName etc.)
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 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.
Example (Event Trigger):
LYNC ready Should be a function which has an argument of type "LyncManager"
To Check if the user is logged in or not:
To get the User's wallet address, if the user is logged in
To Fetch from PlayerPrefs:
To Login directly:
To Logout directly:
There are two methods for proceeding with a transaction:
Gasless Transaction - Game Developer/ Game Studio will be sponsoring the transaction fee (Function Name: SendTransaction).
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).
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:
onSuccess: Once the transactions are completed, this handles what to do.
onError: If the transactions failed, this handles what to do.
To enable gasless transactions via Biconomy, Register a new paymaster on the Biconomy Dashboard. Make sure you select the version: 1.0.1
Once done, Get the API Key and Pass it 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.
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).
You can see the Assets/LYNC-AA-SDK/Example-2/TransactionExample.cs example script as a reference.
Problem: Newtonsoft JSON is missing.
Solution: Please, Add this as a git URL in adding package