Unity Plugin
Introduction
The TRIKON Plugin facilitates seamless integration of TRIKON functionalities into Unity projects. By leveraging this plugin, developers can effortlessly incorporate TRIKON's features such as user authentication, token management, and NFT transactions into their Unity games or applications.
Prerequisites
Before integrating the TRIKON Plugin into your Unity project, ensure that you have the following prerequisites:
TRIKON Developer Account: Sign up for a TRIKON Developer Account to gain access to the necessary credentials and tools required for integrating TRIKON functionalities.
Optional: Token Contract Address: If your project involves token transactions, you may need the contract address of the token you're using.
Optional: ERC1155 Contract Address: In case your project involves ERC1155 NFT transactions, you may require the contract address of the ERC1155 token.
Optional: NFT Contract Address: For projects dealing with NFTs, you may need the contract address of the specific NFT token.
Integration Guide
Follow these steps to seamlessly integrate the TRIKON Plugin into your Unity project:
Create a Game: Log in to your TRIKON Developer Account and create a new game project.
Project Setup: Set up a project within the created game on the TRIKON platform.
APIKey Configuration: Retrieve the APIKey from the Game Console of the Developer Dashboard and configure it in the TRIKON Settings Scriptable Object provided by the plugin.
Note: A demonstration of the plugin's usage can be found in the “TRIKON/Demo” folder for quick reference.
API Documentation
public static void AnonymousSignIn(string username, string password, Action<SignInResult> onCompleted = null, Action<long, string> onError = null)
public static void AnonymousSignIn(string username, string password, Action<SignInResult> onCompleted = null, Action<long, string> onError = null)
Description: Initiates an anonymous sign-in process for users on the TRIKON Server.
Parameters:
username
: The username assigned to the anonymous user.password
: The password associated with the anonymous user.onCompleted
: Callback invoked upon successful sign-in.onError
: Callback invoked in case of errors during the sign-in process.
public static void AnonymousSignUp(string username, string password, Action<SignInResult> onCompleted = null, Action<long, string> onError = null)
public static void AnonymousSignUp(string username, string password, Action<SignInResult> onCompleted = null, Action<long, string> onError = null)
Description: Registers a new anonymous user on the TRIKON Server.
Parameters:
username
: The username to be assigned to the new anonymous user.password
: The password to be set for the new anonymous user.onCompleted
: Callback invoked upon successful registration.onError
: Callback invoked in case of errors during the registration process.
public static void CheckUserName(string username, Action<string> onComplete = null, Action<long, string> onError = null)
public static void CheckUserName(string username, Action<string> onComplete = null, Action<long, string> onError = null)
Description: Verifies the availability of a username on the TRIKON Server, ensuring uniqueness.
Parameters:
username
: The username to be checked for availability.onComplete
: Callback invoked upon successful completion of the username availability check.onError
: Callback invoked in case of errors during the username availability check.
public static void GetGasPrice(Action<string> onComplete = null, Action<long, string> onError = null)
public static void GetGasPrice(Action<string> onComplete = null, Action<long, string> onError = null)
Description: Retrieves the current gas price from the TRIKON Server.
Parameters:
onComplete
: Callback invoked upon successful retrieval of the gas price.onError
: Callback invoked in case of errors during the gas price retrieval process.
public static void SigninSocial(Action<SocialLoginSuccess> onComplete = null, Action<long, string> onError = null)
public static void SigninSocial(Action<SocialLoginSuccess> onComplete = null, Action<long, string> onError = null)
Description: Allows users to log in using their social media accounts.
Parameters:
onComplete
: Callback invoked upon successful social login, returning the signed-in user's details.onError
: Callback invoked in case of errors during the social login process.
public static void MintToken(double amount, bool isSponsored, Action onComplete = null, Action<long, string> onError = null)
public static void MintToken(double amount, bool isSponsored, Action onComplete = null, Action<long, string> onError = null)
Description: Mints the earned ERC-20 Tokens in the game.
Parameters:
amount
: The amount of tokens to be minted.isSponsored
: Determines if the transaction is Game Developer Sponsored or self-Sponsored.onComplete
: Callback invoked upon successful token minting.onError
: Callback invoked in case of errors during the token minting process.
public static void SendNativeToken(string sendToAddress, string valueToSend, bool isSponsored = true, Action onComplete = null, Action<long, string> onError = null)
public static void SendNativeToken(string sendToAddress, string valueToSend, bool isSponsored = true, Action onComplete = null, Action<long, string> onError = null)
Description: Sends the Native Token to the corresponding address.
Parameters:
sendToAddress
: The recipient's address to which the Native Token will be sent.valueToSend
: The amount of Native Token to be sent.isSponsored
: Determines if the transaction is Game Developer Sponsored or self-Sponsored.onComplete
: Callback invoked upon successful completion of the token transfer.onError
: Callback invoked in case of errors during the token transfer process.
public static void SendERC20Token(string sendToAddress, string valueToSend, bool isSponsored = true, Action onComplete = null, Action<long, string> onError = null)
public static void SendERC20Token(string sendToAddress, string valueToSend, bool isSponsored = true, Action onComplete = null, Action<long, string> onError = null)
Description: Sends the ERC-20 Token to the corresponding address.
Parameters:
sendToAddress
: The recipient's address to which the ERC-20 Token will be sent.valueToSend
: The amount of ERC-20 Token to be sent.isSponsored
: Determines if the transaction is Game Developer Sponsored or self-Sponsored.onComplete
: Callback invoked upon successful completion of the token transfer.onError
: Callback invoked in case of errors during the token transfer process.
public static void GetERC20Balance(Action<string> onComplete = null, Action<long, string> onError = null)
public static void GetERC20Balance(Action<string> onComplete = null, Action<long, string> onError = null)
Description: Retrieves the ERC-20 Token balance for the Token Contract Address.
Parameters:
onComplete
: Callback invoked upon successful retrieval of the ERC-20 Token balance.onError
: Callback invoked in case of errors during the ERC-20 Token balance retrieval process.
public static void GetNativeBalance(Action<string> onComplete = null, Action<long, string> onError = null)
public static void GetNativeBalance(Action<string> onComplete = null, Action<long, string> onError = null)
Description: Retrieves the Native Token balance in the selected chain network.
Parameters:
onComplete
: Callback invoked upon successful retrieval of the Native Token balance.onError
: Callback invoked in case of errors during the Native Token balance retrieval process.
public static void ConvertToUSD(Action<double> onComplete = null, Action<long, string> onError = null)
public static void ConvertToUSD(Action<double> onComplete = null, Action<long, string> onError = null)
Description: Converts the Native Token balance to USD.
Parameters:
onComplete
: Callback invoked upon successful conversion of the Native Token balance to USD, returning the conversion rate.onError
: Callback invoked in case of errors during the conversion process.
public static void EstimateGasCost(TokenType tokenType, string valueToSend, Action<string> onComplete = null, Action<long, string> onError = null)
public static void EstimateGasCost(TokenType tokenType, string valueToSend, Action<string> onComplete = null, Action<long, string> onError = null)
Description: Estimates the gas cost for performing a transaction.
Parameters:
tokenType
: An enum representing the type of token (native or ERC-20) for which the gas cost is estimated.valueToSend
: The amount for which the gas cost is to be estimated.onComplete
: Callback invoked upon successful estimation of the gas cost.onError
: Callback invoked in case of errors during the gas cost estimation process.
public static void GetAllGameWalletTransactions(int pageNumber, int limit, Action<GameWalletTransactions> onComplete = null, Action<long, string> onError = null)
public static void GetAllGameWalletTransactions(int pageNumber, int limit, Action<GameWalletTransactions> onComplete = null, Action<long, string> onError = null)
Description: Retrieves the list of all transactions performed by the user’s wallet.
Parameters:
pageNumber
: The current page number.limit
: The limit of the number of transactions to be displayed on each page.onComplete
: Callback invoked upon successful retrieval of wallet transactions, returning the transaction details.onError
: Callback invoked in case of errors during the retrieval process.
public static void UpdateTheGamerAccount(GamerProfileDataToSend gamerProfile, Action<GamerWalletObject> onComplete = null, Action<long, string> onError = null)
public static void UpdateTheGamerAccount(GamerProfileDataToSend gamerProfile, Action<GamerWalletObject> onComplete = null, Action<long, string> onError = null)
Description: Updates the Gamer Account with the provided profile data.
Parameters:
gamerProfile
: A custom structure containing the details to be updated.onComplete
: Callback invoked upon successful update of the Gamer Account, returning the updated results.onError
: Callback invoked in case of errors during the update process.
public static void PurchaseAssetERC1155(string valueInToken, string tokenId, bool isSponsored = true, Action onComplete = null, Action<long, string> onError = null)
public static void PurchaseAssetERC1155(string valueInToken, string tokenId, bool isSponsored = true, Action onComplete = null, Action<long, string> onError = null)
Description: Allows the user to purchase an ERC-1155 NFT.
Parameters:
valueInToken
: The value in Token for purchasing the NFT.tokenId
: The ID of the NFT that the user wants to purchase.isSponsored
: Determines if the transaction is Game Developer Sponsored or self-Sponsored.onComplete
: Callback invoked upon successful purchase of the NFT.onError
: Callback invoked in case of errors during the purchase process.
public static void GetNFTBalance(Action<NFTBalance> onComplete = null, Action<long, string> onError = null)
public static void GetNFTBalance(Action<NFTBalance> onComplete = null, Action<long, string> onError = null)
Description: Retrieves the NFT balance in the user’s wallet.
Parameters:
onComplete
: Callback invoked upon successful retrieval of the NFT balance, returning the list of owned NFTs.onError
: Callback invoked in case of errors during the retrieval process.
This comprehensive list provides detailed documentation for each API function, facilitating easier integration and usage of the TRIKON Plugin within Unity projects.
Last updated