private void FetchDeveloperWalletAddress() { /* * Get the details of the app the SDK is authenticated for. */ App app = Enjin.GetApp(); // Check if the GetApp query found a result. if (Enjin.ServerResponse != ResponseCodes.SUCCESS) { return; } /* * Check to see if the app has been linked to a wallet. If so, * set the developer wallet address to the address of the first * wallet result. */ if (app.wallets.Count > 0) { _developerWalletAddress = app.wallets[0].ethAddress; } Debug.Log($"Developer Wallet Address: {_developerWalletAddress}"); }
IEnumerator MintItem(string itemName, int quantity) { string itemId = itemName; SetAccessToken(); Enjin.MintFungibleItem(_developerWalletAddress, new string[] { _playerWalletAddress }, itemId, quantity, (requestData) => { print("Item Minted::" + itemName); }, true); yield return(null); }
IEnumerator MeltItem(string itemName, int quantity) { string itemId = itemName; Enjin.MeltTokens(PLAYER_IDENTITY_ID, itemId, quantity, (requestData) => { print("Item Melted::" + itemName); }, true); yield return(null); }
IEnumerator MeltItem(string itemName, int quantity) { string itemId = itemName; SetAccessToken(true); Enjin.MeltTokens(_playerWalletAddress, itemId, quantity, (requestData) => { print("Item Melted::" + itemName); }, true); SetAccessToken(); yield return(null); }
IEnumerator SendItem(string itemName, int quantiy) { string itemId = itemName; SetAccessToken(true); Enjin.SendCryptoItemRequest(_playerWalletAddress, itemName, _developerWalletAddress, quantiy, (requestData) => { print("Item Sended::" + itemName); }, true); SetAccessToken(); yield return(null); }
private void AuthenticateSdkAsAdmin() { /* * Authenticate the SDK as an admin. * * Note: You should not do this in an actual game. Developers need to have a manged server responsible * for player authentication and any other operations requiring admin authentication. Exposing the app * secret to player clients is a security risk. */ Enjin.StartPlatform(platformUrl, projectId, projectSecret); _adminAccessToken = Enjin.AccessToken; }
IEnumerator SendItem(string itemName, int quantiy) { string itemId = itemName; Enjin.SendCryptoItemRequest(PLAYER_IDENTITY_ID, itemName, DEVELOPER_IDENTITY_ID, quantiy, (requestData) => { print("Item Sended::" + itemName); }, true); yield return(null); }
IEnumerator MintItem(string itemName, int quantity) { string itemId = itemName; print(Enjin.GetCryptoItemURI(itemId)); Enjin.MintFungibleItem(DEVELOPER_IDENTITY_ID, new string[] { PLAYER_ADDRESS }, itemId, quantity, (requestData) => { print("Item Minted::" + itemName); }, true); yield return(null); }
/* * Authenticates the player. * * Note: This is intended to be handled on a managed authentication server due to the fact that * sensitive credentials are involved. Player clients should never handle this themselves. */ public IEnumerator AuthenticatePlayer(string playerName) { Enjin.IsDebugLogActive = true; // Attempt to fetch player from Enjin platform. User player = Enjin.GetUser(playerName); if (Enjin.ServerResponse == ResponseCodes.NOTFOUND) { // Create new player if no result found. player = Enjin.CreatePlayer(playerName); } for (int i = 0; i < player.identities.Length; i++) { Identity identity = player.identities[i]; if (identity.app.id != projectId) { continue; } _playerIdentityId = identity.id; _playerWalletAddress = identity.wallet.ethAddress; _playerLinkingCode = identity.linkingCode; break; } Debug.Log($"Player Identity Id: {_playerIdentityId}"); Debug.Log($"Player Wallet Address: {_playerWalletAddress}"); Debug.Log($"Player Linking Code: {_playerLinkingCode}"); /* * Authenticate the player and cache the access token. * * Note: Normally you will have your own protocol for clients to communicate with your * authentication server using credentials you save in your own database. It is recommended * that you generate a unique ID for your users and associate that with their login * credentials to avoid exposing their private details to a third party (Enjin). */ _playerAccessToken = Enjin.AuthPlayer(playerName); yield return(null); }
public IEnumerator LoginEnjin(string player_email) { PLAYER_EMAIL = player_email; //Enjin.StartPlatformWithToken(PLATFORM_URL, APP_ID, ACCESS_TOKEN); Enjin.IsDebugLogActive = false; User admin = Enjin.GetUser(DEVELOPER_USERNAME); DEVELOPER_ACCESS_TOKEN = Enjin.AccessToken; print(Enjin.CreatePlayer(PLAYER_EMAIL)); User player = Enjin.GetUser(PLAYER_EMAIL); for (int i = 0; i < player.identities.Length; i++) { Identity identity = player.identities[i]; Enjin.CreateIdentity(identity); if (identity.app.id == APP_ID) { PLAYER_IDENTITY_ID = identity.id; PLAYER_ADDRESS = identity.wallet.ethAddress; APP_LINK_CODE = identity.linkingCode; print("_IDENTITY_ID:: " + PLAYER_IDENTITY_ID); print("_ADDRESS::" + PLAYER_ADDRESS); print("_ADDRESS_LENGTH::" + PLAYER_ADDRESS.Length); print("_LINKING_CODE::" + APP_LINK_CODE); } } // Enjin.CreatePlayer(PLAYER_EMAIL); print(Enjin.AuthPlayer(PLAYER_EMAIL)); yield return(null); }
private void Awake() { Enjin.StartPlatform(PLATFORM_URL, APP_ID, APP_SECRET); StartCoroutine(LoginEnjin(PLAYER_EMAIL)); }