Enable user wallet interactions
Passport currently offers wallet support for Immutable's StarkEx rollup. Please see here for more information on Immutable's layer 2 solutions.
When a user signs up for a Passport account for the first time, a wallet is created and associated with their Passport identity.
Depending on the application type you are building, you may need to perform operations
that require a wallet signature (with user approval) or get data from API using the IMXClient
.
The following sections below outline how to use each SDK module. You can use both the IMXProvider
and the Immutable X
API to achieve things like listing a Passport wallet's assets or balance.
IMX Provider
A wallet in Immutable X is represented by the IMX Provider interface. You can create an instance of the object by invoking the following method when the user clicks on Sign in with Passport as explained in the setup guide.
const provider: IMXProvider = await passport.connectImx();
Supported Functions
Passport supports the following IMX Provider functions:
- batchNftTransfer
- cancelOrder
- createOrder
- createTrade
- exchangeTransfer
- getAddress
- isRegisteredOffchain
- registerOffchain
- transfer - Example Transfer Guide
Please refer to the IMX Provider documentation to get detailed usage instructions.
Note that the above workflow methods may throw the following errors:
Error Code | Cause | Resolution |
---|---|---|
USER_REGISTRATION_ERROR | Passport failed to register the user with the IMX protocol | Check your network connection |
USER_NOT_REGISTERED_ERROR | The user has not been registered with the IMX protocol | Ensure that the registerOffchain function has been called for this user |
WALLET_CONNECTION_ERROR | Passport failed to initialise the Passport wallet | Check your network connection and call the connectImx function again |
Passport users must explicitly approve a transaction in order to be processed by the Immutable X API. You can learn more about this feature in Transaction Confirmations.
Unsupported Functions
The following IMX Provider functions are not supported by Passport:
- isRegisteredOnchain: Coming soon.
- deposit: Coming soon.
- prepareWithdrawal: Coming soon.
- completeWithdrawal: Coming soon.
Learn more about how to choose the right way to integrate with Passport's provider based on your application type.
Immutable X API
The IMXClient
allows you to create an Immutable X API client instance to interact with the API.
For example, you can list the balances for a user as follows:
import { config as imtblConfig, x } from "@imtbl/sdk";
const config = {
baseConfig: { environment: imtblConfig.Environment.PRODUCTION },
};
const client = new x.IMXClient(config);
const listBalances = async () => {
const response = await client.listBalances({
owner: "0x0000000000000000000000000000000000000000",
});
return response;
};