The TRIKON Plugin facilitates seamless integration of TRIKON functionalities into Flutter projects. With this plugin, developers can effortlessly incorporate features such as user authentication, token management, and NFT transactions into their Flutter applications. The plugin is available for download from the TRIKON website as well as on pub.dev.
Prerequisites
Before integrating the TRIKON Plugin into your Flutter project, make sure you have the following prerequisites:
TRIKON Developer Account: Sign up for a TRIKON Developer Account to access the required credentials and tools 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: If your project involves ERC1155 NFT transactions, you may need 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 integrate the TRIKON Plugin into your Flutter 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.
API Key Configuration: Retrieve the API Key from the Game Console of the Developer Dashboard and configure it in the TRIKON Settings provided by the plugin.
Note: Refer to the provided documentation for a quick demonstration of the plugin's usage.
API Documentation
// Anonymous sign-invoid anonymousSignIn(String username, String password, {Function(SignInResult)? onCompleted, Function(int, String)? onError}) {
// Initiates an anonymous sign-in process for users on the TRIKON Server.// Parameters:// - username: The username for anonymous sign-in.// - password: The password for anonymous sign-in.// - onCompleted: Callback invoked upon successful sign-in.// - onError: Callback invoked in case of errors during sign-in.}// Anonymous sign-upvoid anonymousSignUp(String username, String password, {Function(SignInResult)? onCompleted, Function(int, String)? onError}) {
// Registers a new anonymous user on the TRIKON Server.// Parameters:// - username: The username for the new anonymous user.// - password: The password for the new anonymous user.// - onCompleted: Callback invoked upon successful registration.// - onError: Callback invoked in case of errors during registration.}// Check username availabilityvoidcheckUserName(String username, {Function(String)? onComplete, Function(int, String)? onError}) {// 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 availability check.// - onError: Callback invoked in case of errors during the availability check.}// Get gas pricevoidgetGasPrice({Function(String)? onComplete, Function(int, String)? onError}) {// Retrieves the current gas price from the TRIKON Server.// Parameters:// - onComplete: Callback invoked upon successful retrieval of gas price.// - onError: Callback invoked in case of errors during retrieval.}// Social loginvoidsigninSocial({Function(SocialLoginSuccess)? onComplete, Function(int, String)? onError}) {// Allows users to log in using their social media accounts.// Parameters:// - onComplete: Callback invoked upon successful social login.// - onError: Callback invoked in case of errors during social login.}// Mint tokenvoidmintToken(double amount, bool isSponsored, {Function()? onComplete, Function(int, String)? onError}) {// 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 token minting.}// Send native tokenvoid sendNativeToken(String sendToAddress, String valueToSend, {bool isSponsored = true, Function()? onComplete, Function(int, String)? onError}) {
// 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 token transfer.// - onError: Callback invoked in case of errors during token transfer.}// Send ERC-20 tokenvoid sendERC20Token(String sendToAddress, String valueToSend, {bool isSponsored = true, Function()? onComplete, Function(int, String)? onError}) {
// 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 token transfer.// - onError: Callback invoked in case of errors during token transfer.}// Get ERC-20 balancevoidgetERC20Balance({Function(String)? onComplete, Function(int, String)? onError}) {// Retrieves the ERC-20 Token balance for the Token Contract Address.// Parameters:// - onComplete: Callback invoked upon successful retrieval of ERC-20 Token balance.// - onError: Callback invoked in case of errors during retrieval.}// Get native balancevoidgetNativeBalance({Function(String)? onComplete, Function(int, String)? onError}) {// Retrieves the Native Token balance in the selected chain network.// Parameters:// - onComplete: Callback invoked upon successful retrieval of Native Token balance.// - onError: Callback invoked in case of errors during retrieval.}// Convert to USDvoidconvertToUSD({Function(double)? onComplete, Function(int, String)? onError}) {// Converts the Native Token balance to USD.// Parameters:// - onComplete: Callback invoked upon successful conversion to USD.// - onError: Callback invoked in case of errors during conversion.}// Estimate gas costvoid estimateGasCost(TokenType tokenType, String valueToSend, {Function(String)? onComplete, Function(int, String)? onError}) {
// Estimates the gas cost for performing a transaction.// Parameters:// - tokenType: Represents the type of token (native or ERC-20) for which gas cost is estimated.// - valueToSend: The amount for which gas cost is to be estimated.// - onComplete: Callback invoked upon successful estimation of gas cost.// - onError: Callback invoked in case of errors during estimation.}// Get all game wallet transactionsvoid getAllGameWalletTransactions(int pageNumber, int limit, {Function(GameWalletTransactions)? onComplete, Function(int, String)? onError}) {
// 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.// - onError: Callback invoked in case of errors during retrieval.}// Update the gamer accountvoid updateTheGamerAccount(GamerProfileDataToSend gamerProfile, {Function(GamerWalletObject)? onComplete, Function(int, String)? onError}) {
// 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.// - onError: Callback invoked in case of errors during update.}// Purchase asset ERC1155void purchaseAssetERC1155(String valueInToken, String tokenId, {bool isSponsored = true, Function()? onComplete, Function(int, String)? onError}) {
// 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 purchase.}// Get NFT balancevoidgetNFTBalance({Function(NFTBalance)? onComplete, Function(int, String)? onError}) {// Retrieves the NFT balance in the user’s wallet.// Parameters:// - onComplete: Callback invoked upon successful retrieval of NFT balance.// - onError: Callback invoked in case of errors during retrieval.}
This documentation provides detailed information on integrating and utilising the TRIKON Plugin within Flutter applications, including descriptions of function parameters.