/imx-core-sdk-csharp

The Immutable Core SDK C# provides convenient access to the Immutable APIs and Ethereum contract methods for applications integrating with Immutable

Primary LanguageC#Apache License 2.0Apache-2.0

🚨 This library is no longer maintained 🚨

If you're building apps with Immutable, please use Immutable's Unified SDK

Immutable Core SDK in C#

The Immutable Core SDK in C# provides convenient access to the ImmutableX API and Ethereum smart contracts for applications written on the ImmutableX platform.

Currently, this SDK supports interactions with our application-specific rollup based on StarkWare's StarkEx. In the future, when we start supporting other rollups, this SDK will also provide access to those.

Note Currently, the C# Core SDK provides read-only functionality. The endpoints supported are (from this Changelog entry):

  • Assets: Get & List
  • Balances: Get & List
  • Collections: Get & List & List with filters
  • Exchanges: Get & List
  • Metadata: Get
  • Mints: Get & List
  • NFT Checkout Primary: Get & List transactions, Get currencies
  • Deposits: Get & List
  • Withdrawals: Get & List
  • Transfers: Get & List
  • Trades: Get & List
  • Orders: Get & List
  • Users: Get
  • Tokens: Get & List

Implementation roadmap: image

Documentation

See the Developer homepage for general information on building on ImmutableX.

The following sections provide information on how to set up and use the most common functions of the C# SDK. For any other questions, please reach out to the team (see Getting Help).

Examples

  • Sample code - see the examples folder for sample code for key SDK functionality.

Installation

Add 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

Initialization

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 ImmutableX platform currently supports.

Environment Description
Sandbox The default test network (currently, it is Goërli)
Mainnet Ethereum network
using Imx.Sdk;

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

Get data

These methods allow you to read data about events, transactions or current state on ImmutableX (layer 2). They do not require any user authentication because no state is being changed.

Examples of the types of data that are typically retrieved include:

  • Assets or details of a particular asset
  • Token balances for a particular user
  • Orders or details about a particular order
  • Historical trades and transfers

Examples

Get all collections and get assets from a particular collection:

using Imx.Sdk.Gen.Client;
using Imx.Sdk.Gen.Model;
using Imx.Sdk;

try
{
    Client client = new Client(new Config() {
        Environment = EnvironmentSelector.Sandbox
    });

    // List collections
    ListCollectionsResponse resultListCollections = client.ListCollections(pageSize: 2);
    
    if (resultListCollections.Result.Count > 0)
    {
        Console.WriteLine("List Collections Response: " + resultListCollections.ToJson());
        
        // Get the first item in collection
        var collection = resultListCollections.Result[0];
        // Get a list of assets
        ListAssetsResponse resultListAssets = client.ListAssets(collection: collection.Address, pageSize: 10);
        Console.WriteLine("List Assets Response: " + resultListAssets.ToJson());
    }
    else
    {
        Console.WriteLine("No Collections found!");
    }
}
catch (ApiException  e)
{
    Console.WriteLine("Exception when calling Api: " + e.Message);
    Console.WriteLine("Status Code: " + e.ErrorCode);
    Console.WriteLine(e.StackTrace);
}
catch (Exception e)
{
    Console.WriteLine("Error message: " + e.Message);
    Console.WriteLine(e.StackTrace);
}

API autogenerated code

We use OpenAPI (formally known as Swagger) to auto-generate the API clients that connect to the public APIs. The OpenAPI spec is retrieved from https://api.x.immutable.com/openapi and also saved in the repo.

To re-generate the API client, run:

make generate-openapi-prod

Changelog management

This repository is using release-it to manage the CHANGELOG.md.

The following headings should be used as appropriate

  • Added
  • Changed
  • Deprecated
  • Removed
  • Fixed

This is an example with all the change headings. For actual usage, use only the one heading that is relevant. This goes at the top of the CHANGELOG.md above the most recent release.

...

## [Unreleased]

### Added

For new features.

### Changed

For changes in existing functionality.

### Deprecated

For soon-to-be removed features.

### Removed

For now removed features.

### Fixed

For any bug fixes.

...

Getting help

ImmutableX is open to all to build on, with no approvals required. If you want to talk to us to learn more, or apply for developer grants, click below:

Contact us

Project support

To get help from other developers, discuss ideas, and stay up-to-date on what's happening, become a part of our community on Discord.

Join us on Discord

You can also join the conversation, connect with other projects, and ask questions in our ImmutableX Discourse forum.

Visit the forum

Still need help?

You can also apply for marketing support for your project. Or, if you need help with an issue related to what you're building with ImmutableX, click below to submit an issue. Select I have a question or issue related to building on Immutable X as your issue type.

Contact support