Account Management

Create and connect to Immutable X using your wallet

Your web3 wallet (e.g. Metamask) is used to create, connect, and sign transactions on Immutable X. Using Link SDK calls, we can handle account management activities.

Set up wallet for user

Setting up a user’s account is a single call with the Link SDK. The function returns the user’s account information if setup / signed in was completed correctly.

async function setupAccount(){
    const {address, starkPublicKey } = await link.setup({});
    … save user session data

When called, the Link SDK popup will appear, guiding the user to setup/connect the currently active wallet address.

Saving user session

Keeping track of the currently logged in user can be done in a variety of ways. One simple approach is to store the information in local storage.

async function setupAccount(){
    const {address, starkPublicKey } = await link.setup({});
    localStorage.setItem('WALLET_ADDRESS', address);
    localStorage.setItem('STARK_PUBLIC_KEY', starkPublicKey);

Once stored, your application can access the user’s information to make other requests such as getting the user’s assets or viewing orders they purchased. Local storage is a good option if looking to persist the users data between web sessions. Retrieving the already setup user’s address on future requests is as simple as the following:

const address = localStorage.getItem('WALLET_ADDRESS');

Disconnect Wallet

Tracking the user’s connection to Immutable X should be performed by checking the user’s session. If the user’s session no longer contains the connection data, the setup function should be called again. With this pattern, disconnecting the wallet is done by removing the user’s address from the session. If using the local storage technique, use the following:


Did this page help you?