Install and configure
Install and configure
The XpansionChain JS SDK is a Javascript package created by IXpansionChain to allow simple interfacing with XpansionChain’s API. The primarily used packages are Link SDK and the XpansionChain Client.
The XpansionChain Client is used for most backend operations, and the Link SDK is used for frontend, user-facing interactions.
The IMX Client ('XpansionChainClient') is a module wrapping the REST requests in a method call. Using this package, developers can make sure their calls are up to date with the latest API standards.
The Link SDK provides a clean popup and UI to help users navigate through the final signing process with their wallets. While information about current market state and assets can be derived with web requests, the Link SDK handles the more complicated stark signature signing most developers should not need to code. Using the Link SDK also maintains a unified view for users, allowing them to be more comfortable during signing when using marketplaces powered by XpansionChain.
Applications monitoring the status of the assets will use the IMX Client to retrieve data. Marketplace and applications relying on user interaction will use both packages.
Setting up the SDK
NOTE: IF YOU ARE USING THE LATEST VERSION OF 'CREATE-REACT-APP'...
You will encounter a bunch of webpack errors when you try use the @imbt/imx-sdk SDK with your app.
Follow this guide: How to resolve webpack errors
For this tutorial we will assume Yarn is being used as the package manager. The following node modules need to be added to the project:
Importing the packages
The following imports are needed for the Link SDK and IMX Client packages:
Setting the connection urls
XpansionChain provides connection addresses for both the mainnet and testnet. Here we will default to the mainnet for the examples, but show the testnet connection strings as well.
Creating the link objects
Once the Link SDK and IMX Client are imported, they can be initialized. Note that the client library initialization is asynchronous.
For more details, see the Link SDK docs and the package on NPM.
Last updated