LogoLogo
  • Getting Started
  • How to Connect
  • REST API
    • PublicMarketData
    • Order
    • Wallet
    • Trade
    • Models
  • Smart Contract ABI
    • OrderBook
    • Order Data (explanation)
  • Websocket API
    • Orderbook
    • Ticker
  • SDK Documentation
    • Getting Started
    • REST API Interaction
    • Smart Contract Interaction
      • Order Placement
      • Order Cancelation
Powered by GitBook

Privacy

  • Privacy Policy

All rights reserved. 21X AG

On this page
  • Key Features
  • 1. Smart Contract Interaction
  • 2. REST API Integration
  • Prerequisites
  • Installation
  • Quick Start Example
Export as PDF

SDK Documentation

This SDK is designed to simplify integration with 21X, the future of trading and settlement for security tokens and crypto assets. As a regulated platform under the EU DLT Regime, 21X ensures compliance, security, and transparency, providing a seamless gateway to the fast-growing market of digital assets.


Key Features

The 21X SDK is designed to streamline interactions with the platform, particularly for managing trades and interacting with the smart contract. Below is an overview of its core capabilities:

1. Smart Contract Interaction

The OrderBook class serves as the gateway for interacting with the platform's EVM-based smart contract. It abstracts the complexities of contract operations, enabling seamless integration. Its key features include:

  • Trading Pair Configuration: Query trading pair configurations, including checking if your wallet is whitelisted to trade on a specific pair and retrieving other important contract-level details.

  • Balance Insights: Access real-time balance information for trading pairs, including the base token (tokenized asset) and the quote token (e-money token).

  • Token Allowances: Easily set allowances for base and quote tokens, ensuring the smart contract is authorized to interact with your tokens for trading.

  • Order Placement: Place buy and sell limit orders directly through the smart contract with support for automatic scaling of price and quantity values.

  • Order Cancellation: Cancel active orders efficiently using a straightforward method.

This class simplifies complex on-chain operations, allowing developers to focus on building functionality rather than managing low-level blockchain interactions.

2. REST API Integration

The built-in REST API client supports a range of essential operations to monitor and manage trading activities:

  • Market Data:

    • List all available trading pairs and their associated contracts.

    • Retrieve real-time price information for trading pairs.

  • Order Tracking:

    • Fetch all open orders on the platform.

    • View active orders and trades associated with your wallet.

These features enable users to fully leverage the platform's capabilities, whether by interacting with the smart contract for direct transactions or querying the REST API for trading insights and order management.

Prerequisites

To use this SDK effectively, you’ll need:

  • Python 3.9 or higher installed on your system.

  • Access credentials for the 21X platform.

  • Basic familiarity with REST API and Ethereum smart contract interactions.

Installation

Get started by installing the SDK via pip:

pip install 21x-sdk

Quick Start Example

Here’s a quick example of how to initialize the SDK and interact with the platform:

from x21_sdk import Client, OrderBook

# Initialize REST API client
client = Client(base_url="http://localhost:8080/api/v1")

# Interact with the smart contract
order_book = OrderBook(
  private_key="your_private_key",
  orderbook_addr="0xOrderBookAddress",
  rpc_url="https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY",
)

# Example: Submit a buy order
order_book.create_buy_order(quantity=Decimal(100), price=Decimal(50.5))
PreviousTickerNextGetting Started

Last updated 2 months ago