1.0.3 • Published 8 months ago

@stardust-gg/legacy-imx-custodial-ethers-sdk v1.0.3

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
8 months ago

Legacy IMX Custodial Ethers SDK

License standard-readme compliant

Table of Contents

Currently only supports Ethers.js v5

Install

npm i @stardust-gg/legacy-imx-custodial-ethers-sdk

Usage

The StardustCustodialSDK object is designed to be used with only 1 app. If your use case requires to have multiple apps, multiple StardustCustodialSDK's will need to be used.

Creating your first app

import { StardustCustodialSDK, StardustApp } from '@stardust-gg/legacy-imx-custodial-ethers-sdk';

// create your app object locally
const app: StardustApp = new StardustApp('app_name', 'email@address.xyz', 'optional_description');

// create a StardustApp instance in the Stardust API
await StardustCustodialSDK.CreateApp(app);

// save the api key so you can access this app later
const apiKey = app.apiKey;

For now, API Keys will need to be activated by the Stardust team. You must activate your key before being able to follow along with the sections below

Getting your app and creating wallet

import {
  StardustCustodialSDK,
  StardustApp,
  StardustWallet,
} from '@stardust-gg/legacy-imx-custodial-ethers-sdk';

const STARDUST_API_KEY = 'your-api-key';
const sdk = new StardustCustodialSDK(STARDUST_API_KEY);
const wallet: StardustWallet = await sdk.createWallet();

// Make sure to save this walletId for later steps!
const walletId = wallet.id;
await clientWalletDB.save(walletId);

To get your Stardust Linked Ethers wallet for use with IMX:

const ethersWallet = await wallet.getEthersWallet();

This wallet can now be used with IMX:

import { imx } from '@imtbl/imx-sdk';

const signer = (await stardustWallet.getEthersWallet()).connect(provider);
console.log('signer', signer);

const params = {
  starkContractAddress: config.starkContractAddress,
  registrationContractAddress: config.registrationContractAddress,
  signer: signer,
  publicApiUrl: config.apiAddress,
  gasLimit: config.gasLimit,
  gasPrice: config.gasPrice,
};

const client = await imx.ImmutableXClient.build(params);

Contributing

PRs accepted.

License

Apache-2.0