Перейти к содержанию

Blockchain Connector XLM Service API

Review

For each supported blockchain, a set of endpoints is available, allowing you to create a transaction, sign it, send it to the network, and retrieve an address from a public key.

Request parameters embedded in the URL, such as the blockchain identifier, are mandatory. Parameters in the query string or JSON body of the request can be optional and are described in detail in the corresponding sections.

Server address: https://cloud.spatium.net/blockchain-connector-xlm/v1 Swagger

For this server address, interaction with the Stellar blockchain(xlm) is available.

The structure of requests and the information in responses are the same.

Data Types

Network

Network - network type. As a rule, blockchains support at least two options: a test network for development (testnet) with fictitious assets and a stable production network (livenet) with real assets. Data structure:

type Network = 'livenet' | 'testnet';

API

Generate Address from a Public Key

Swagger Get API address

Request Structure

POST /api/get-address/xlm

{
   publicKey: string;
   network?: Network;
   prefix?: boolean;
}
{
  requestId: string;
  data: {
    address: string;
  };
}

Parameters

  • publicKey - public key, required parameter, string;

  • network - network type, optional parameter, default value 'livenet' (Network);

  • prefix - true if address contains a prefix, optional parameter, default value false (boolean).

Getting Data to Form a Transaction

Swagger Prepare transaction API

To form a Stellar transaction, it is required to provide a maximum fee size. It means that a maximum amount a user can pay is indicated, but actually the minimum required amount for transaction to be processed is going to be charged. When there is no network load, the minimum amount will be charged (100 stroops[^1] per operation now), so the provided fee can't be less than that.

Network fee

Swagger Prepare transaction FeeStat

To provide the correct fee size, it is useful to address current fee statistics. This endpoint provides data about minimum and maximum fees in the 5 past network ledgers.

Note

There are different maximum fee forming strategies. But one shound take into account, that a transaction with a low maximum fee won't be processed with a high network load, so we recommend using the statistically highest fee with the addition of a small backup - current minimal fee per operation (feeCharged.max + lastLedgerBaseFee), at the same time leaving the option to enter any fee value manually.

Request Structure

GET api/prepare-transaction/fee-stat/xlm/?network={network}

{
   network: Network;
}
{
 requestId: string;
 data: {
   lastLedgerBaseFee: string;
   feeCharged: { 
    min: string;
    max: string;
   };
 };
}
Parameters
  • network - network type, optional parameter, default value 'livenet' (Network).

Get Transaction Hash

Get Send Transaction Hash

This endpoint supports transfers of the native blockchain currency as well as any Stellar asset. When sending native currency, the existence of the account with the address is checked. If it does not exist, the account is automatically created with a start balance of the provided amount, otherwise it is a normal transfer.

Important

According to Stellar logic, one can't transfer XLM to a non-existent account (it is necessary to create one first). This endpoint will automatically create the account if it's necessary, but there will be no notice about account absence! If you want to notify users about account absence, you can use the utility endpoint to check if the account exists (checkXLMAccount method).

Request Structure

POST api/transaction/get-hash/xlm/transfer

{
  publicKey: string;
  network?: Network;
  to: string;
  amount: string;
  asset?: StellarAsset;
  fee: string;
  memo?: string;
}
{
requestId: string;
 data: {
   unsignedMessage: string;
   hash: string;
 };
}

Parameters

  • publicKey - public key, required parameter, string;

  • network - network type, optional parameter, default value 'livenet' (Network);

  • to - recipient's address (string);

  • amount - integer value (or 0 for trustline deleting), storing the limit amount for this asset on the current address, required parameter, (string), default value is the blockchain determined maximum value for the asset;

  • asset - cryptocurrency based on the Stellar blockchain, determined by the asset issuer's address and asset's code, for which a trustline is added. Required parameter (StellarAsset);

  • fee - transaction fee (string);

  • memo - additional transaction data (string).

Get Add Trustline Transaction Hash

Request Structure

POST api/transaction/get-hash/xlm/add-trustline

{
  publicKey: string;
  network?: Network;
  amount: string;
  asset?: StellarAsset;
  fee: string;
  memo?: string;
}
{
requestId: string;
 data: {
   unsignedMessage: string;
   hash: string;
 };
}

Parameters

  • publicKey - public key, required parameter, string;

  • network - network type, optional parameter, default value 'livenet' (Network);

  • amount - integer value (or 0 for trustline deleting), storing the limit amount for this asset on the current address, optional parameter, (string), default value is blockchain determined maximum value for the asset;

  • asset - cryptocurrency based on the Stellar blockchain, determined by the asset issuer's address and asset's code, for which a trustline is added. Required parameter (StellarAsset);

  • fee - transaction fee (string);

  • memo - additional transaction data (string).

Get Create claimableBalance Transaction Hash

Request Structure

POST api/transaction/get-hash/xlm/add-trustline

{
  publicKey: string;
  network?: Network;
  claimableBalanceId: string;
  fee: string;
  memo?: string;
}
{
requestId: string;
 data: {
   unsignedMessage: string;
   hash: string;
 };
}

Parameters

  • publicKey - public key, required parameter, string;

  • network - network type, optional parameter, default value 'livenet' (Network);

  • claimableBalanceId - claimableBalance identifier, required parameter, string;

  • fee - transaction fee (string);

  • memo - additional transaction data (string).

Transaction Signing

Request Structure

POST api/transaction/attach-signature/xlm

{
  publicKey: string;
  network: Network;
  unsignedMessage: string;
  signature: {
    s: string;
    R: string;
  };
}
{
 requestId: string;
 data: {
   txdata: string;
 };
}
Parameters
  • publicKey - public key, required parameter, string.

  • network - network type, optional parameter, default value 'livenet' (Network);

  • unsignedMessage - transaction data gained at the previous stage (string);

  • signature - signature data object.

Sending Transaction to Network

Request Structure

POST api/transaction/send/xlm

{
  txdata: string;
}
{
 requestId: string;
 data: {
   txid: string;
 };
}
Parameters
  • txdata - signed transaction data, required parameter, string.

Stellar Utility Endpoints

Get Information About XLM Reserved Balance (getXLMAccountReserve method)

Request Structure

POST /api/utility/account-reserve

{
  address: string;
}
{
  requestId: string;
  reserved: {
    baseReserve: string,
    xlm: string,
    assets: {
    value: string,
    count: number,
    },
  total: string,
  }
}
Parameters
  • address - a unique string used for wallet identification on the Stellar chain. Starts with 'G' and contains 56 numeric and alphabetic characters.
Response Parameters
  • requestId - request identifier (string - uuid);

  • baseReserve - reserve that the network uses while estimating accounts minimum balance. This balance can't be sent or spent;

  • xlm - XLM amount, reserved on the account;

  • assets - reserved assets data object;

  • value - amount of the XLM, reserved on the account;

  • count - trustline amount, set on the account;

  • total - total for reserves on the account, including their mininmum balance and their assets.

Get XLM Base Reserve (baseReserve)(getXLMBaseReserve method)

Request Structure

GET /api/utility/base-reserve

{
  requestId: string,
  baseReserve: string,
}
Response Parameters
  • requestId - request identifier (string - uuid);

  • baseReserve - reserve that the network uses while estimating accounts minimum balance. This balance can't be sent or spent;

Check Existence of an Account (checkXLMAccount method)

Request Structure

POST /api/utility/check-account

{
  address: string;
}
{
  requestId: string,
  accountExists: boolean,
}
Parameters
  • address - a unique string used for wallet identification on the Stellar chain. Starts with 'G' and contains 56 numeric and alphabetic characters;
Response Parameters
  • requestId - request identifier (string - uuid);

  • accountExists - boolean, shows if the account exists

Check Trustline Existance (checkXLMAccountHasTrustline mehtod)

Request Structure

POST /api/utility/check-account-trustline

{
  address: string;
  issuer: string;
  code: string
}
{
  requestId: string
  hasTrustline: boolean,
}
Parameters
  • address - a unique string used for wallet identification on the Stellar chain. Starts with 'G' and contains 56 numeric and alphabetic characters;

  • issuer - an account on the Stellar blockchain, that creates, releases and deletes new assets (tokens) on the blockchain;

  • code - an asset’s identifying code. Contains several symbols and helps to distinguish the asset from the others released by the same issuer;

Response Parameters
  • requestId - request identifier (string - uuid);

  • hasTrustline - boolean, shows if trustline exists.