User onboarding and authorization

All games that are opened in the metapro wallet app have access to the injected web3 provider. It means that the user's web3 account is already connected to the site.

How to get info about the injected user?

Account Acquisition

For most actions, the user's wallet address is required. Therefore, the first step is to acquire it by calling the Request Account action. This function requests access to the user's Ethereum accounts using the eth_requestAccounts method. Once the user grants permission, it retrieves the connected accounts via eth_accounts. If an account is available, it sets the account to a local variable and triggers the On Account Received condition, signaling the successful acquisition of the user's wallet address. To retrieve the user account from the plugin, use the Get Account expression.

User Registration Status

The Check If Registered action is designed to verify whether a user is registered within the project. It sends a request to the authentication service using the user's Ethereum wallet address and the project ID. The response checks if the user has an account and has accepted the required rules. If both conditions are true, the On Is Registered condition is triggered, indicating the user is fully registered. If not, the On Is Not Registered condition is triggered. This check helps identify the user's registration status, which is essential for managing user flow in the game, such as enabling certain actions or features only for registered users.

How to log in as a registered user?

How to log in on an unregistered account

Retrieve the referral code from a deep-linked invitation

The Check Referral Code from Deeplink action extracts the referral code from a provided deep-link by interacting with the DOM. If a referral code exists, it triggers the On Referral Code from Deeplink Exists condition. The referral code can then be accessed using the Get Referral Code from Deeplink expression => string

Authorization

The Login action is used to log in or register a user within a project. It starts by generating a unique hash for the user's account and prompts the user to sign this hash with their wallet. After verifying the user's registration status, if they are not yet registered, it includes optional referral settings and code for registration. The login process retrieves an access token, and user information like username and avatar, and completes the session initialization. Once the user is successfully logged in, the On User Logged In condition is triggered.

Getting user data from expressions

Additionally, the following user data can be retrieved from the plugin using various expressions:

  • Get Account: Retrieve the currently logged-in Ethereum account => string

  • Get Avatar: Retrieve the user's avatar image URL => string

  • Get User ID: Retrieve the user's unique ID => string

  • Get Username: Retrieve the user's username => string

  • Get Access Token: Retrieve the user's authentication token => string

Last updated