If you're building apps with Immutable, please use Immutable's Unified SDK
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
See the Developer homepage for general information on building on ImmutableX.
- Get started building on ImmutableX with the Developer docs
- Check out the API reference documentation
- For the C# Core SDK reference documentation, please see here
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).
- Sample code - see the examples folder for sample code for key SDK functionality.
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
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);
}
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
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);
}
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
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.
...
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:
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.
You can also join the conversation, connect with other projects, and ask questions in our ImmutableX Discourse forum.
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.