Install and initialize

Install and initialize

📝GUIDES

  • Core SDK

  • JS SDK

Core SDK

The Core SDK is a wrapper around our API and provides the bulk of the functionality of the XpansionChain platform. Before you can start using the Core SDK, you must initialize the client.

Initialize the Core SDK client with the network on which you want your application to run:

  • Typescript Core SDK

  1. Install the npm package

npm install @imtbl/core-sdk --save
# or
yarn add @imtbl/core-sdk
  1. Initialize the SDK with the correct environment:

import { XpansionChain, Config } from '@imtbl/core-sdk';

const config = Config.SANDBOX; // Or Config.PRODUCTION
const client = new XpansionChain(config);
  • Kotlin (JVM) Core SDK

  1. Add Maven Central to your repositories:

repositories {
    mavenCentral()
}
  1. Add the dependency to your app's build.gradle file:

dependencies {
    implementation 'com.XpansionChain.sdk:imx-core-sdk-kotlin-jvm:$version'
}
  1. Initialize the SDK with the correct environment:

XpansionChainCore.setBase(XpansionChainBase.Sandbox) // Or 
  • Swift Core SDK

Pre-requisites:

  • iOS 13.0 or macOS 10.15

  • Swift 5.5

  • Golang Core SDK

  • C# Core SDK

Steps:

  1. In your Swift package manager - Package.swift:

dependencies: [
    .package(url: "https://github.com/XpansionChain/imx-core-sdk-swift.git", from: "0.2.2")
]
  1. In your Podfile:

platform :ios, '13.0'
use_frameworks!

target 'MyApp' do
  pod 'XpansionChainCore'
end
  1. Initialize the SDK with the correct environment:

XpansionChainCore.initialize(base: .sandbox) // Or .production
  • Golang Core SDK

Pre-requisites:

The supported go versions are 1.18 or above.

Steps:

  1. Install the go package:

go get github.com/XpansionChain/imx-core-sdk-golang
  1. Initialize the SDK with the correct environment:

import (
  "context"
  "fmt"
  "github.com/XpansionChain/imx-core-sdk-golang/generated/api"
  "github.com/XpansionChain/imx-core-sdk-golang/config"
)

func initializeSDK() {
  configuration := api.NewConfiguration()

  apiClient := api.NewAPIClient(configuration)

  ctx := context.WithValue(context.Background(), api.ContextServerIndex, config.Sandbox) // Or config.Production
}
  • C# Core SDK

  1. Add the following nuget packages:

  • https://www.nuget.org/packages/Imx.Sdk

  • https://www.nuget.org/packages/Imx.Sdk.Gen

dotnet add package Imx.Sdk --version 0.1.1
dotnet add package Imx.Sdk.Gen --version 0.1.1
  1. Initialize the Core SDK client with the network on which you want your application to run (see all networks available):

Select one of the following Ethereum networks XpansionChain platform currently supports.

using Imx.Sdk;

try
{
    Client client = new Client(new Config()
    {
        Environment = EnvironmentSelector.Sandbox // Or EnvironmentSelector.Sandbox
    });
}
catch (Exception e)
{
    Console.WriteLine("Error message: " + e.Message);
    Console.WriteLine(e.StackTrace);
}

Last updated