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

Blockchain Connector ETH-like 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-eth-like/v1 Swagger

For this server address, interaction with the following blockchains is available:

  • eth;
  • ftm;
  • avax;
  • matic;
  • bsc;
  • arb.

The structure of requests and the information in responses is the same for them.

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 sctructure POST /api/get-address/{chain}

{
   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 and estimate the transaction fee it is required to get the following set of data:

  • transfer data,
  • nonce (a one-time transaction number),
  • gasLimit (maximum amount of work performed by the validator to process a transaction),
  • gasPrice (price for a unit of validator work).

In case of sending blockchains' native currency transfer data is not required, it can be determined as an empty string. When sending ERC-20 tokens, transfer data is required and can be obtained by the corresponding erc20 transfer data getting method.

After transfer data is determined, the estimate endpoint allows you to get all of the other data required to form and estimate transaction with one request. Also, there is a possibility to get this data in three separate requests: (nonce, gas-limit, gas-price).

ERC-20 Transfer Data

Getting transfer data is necessary to to form a correct transaction and calculate gasLimit in case of ERC-20 tokens sending.

Important! This method works only to send ERC-20 tokens. In case of sending blockchains' native currency transfer data is not required, it can be determined as an empty string.

Swagger Prepare transaction API

Request Structure

GET /api/prepare-transaction/erc20-transfer-data?to={addressTo}&amount={amount}

Parameters

  • to - recepient address, required parameter, string,

  • amount - amount in internal integer format, required parameter, string,

Response structure

{
 requestId: string;
 data: { erc20TransferData: string; };
}

Estimate

This endpoint provides all data, required for transaction formation and estimation

Swagger Prepare transaction Estimate

Request Structure

POST /api/prepare-transaction/estimate/{chain}

{
   address: string;
   network?: Network;
   to: string | null;
   amount: string;
   data: string;
}
{
  requestId: string;
  data: {
    nonce: number;
    gasLimit: string;
    gasPrices: { normal: string; fast: string; slow: string };
  };
}

Parameters

  • address - sender address, required parameter, string,

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

  • type - address format, optional parameter, default value 'p2wpkh', for bch this parameter is ignored (AddressType),

  • to - recepient address, required parameter, string,

  • amount - amount in internal integer format, required parameter, string,

Nonce

A one-time transaction number (nonce) is necessary to form a specific transaction and follow-on gasLimit estimation.

Swagger Prepare transaction Nonce

Request Structure

GET /api/prepare-transaction/nonce/{chain}?address={address}&network=livenet

Parameters

  • address - sender address, required parameter, string,

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

Response structure

{
 requestId: string;
 data: { nonce: number };
}

gasLimit

The maximum amount of work performed by the validator to process a transaction (gasLimit) is necessary to form a correct transaction and estimate its fee.

Swagger Prepare transaction GasLimit

Request Structure

POST /api/prepare-transaction/gas-limit/{chain}

{  
   to: string | null;
   amount: string;
   data: string;
   nonce: number;
   network?: Network;
}
{
  requestId: string;
  data: {
    gasLimit: string;
  };
}

Parameters

  • to - recepient address, required parameter, string or null,

  • amount - amount in internal integer format, required parameter, string,

  • data - transfer data, required parameter (gathered through the corresponding method or an empty string),

  • nonce - a one-time transaction number, required parameter, number,

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

gasPrice

A price for a unit of validator work (gasPrice) is necessary to correctly estimate fee. The amount depends on sending mode (slow, normal, fast). The final fee is calculated as a product of the transaction gasLimit and gasPrice for the chosen sending mode.

Swagger Prepare transaction GasPrice

Request Structure

GET /api/prepare-transaction/gas-price/{chain}?network=livenet

Parameters

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

Response structure

{
 requestId: string;
 data: { gasPrices: { normal: string; fast: string; slow: string } };
}
GET /api/prepare-transaction/gas-price/{chain}

Transactions

Transaction Get hash]

Swagger Transaction Get hash

Request Structure

POST /api/transaction/get-hash/{chain}

{
   network?: Network;
   publicKey: string;
   to: string | null;
   amount: string;
   gasLimit: string;
   gasPrice: string;
   nonce: number;
   data: string;
}
{
  requestId: string;
  data: { hash: string };
}

Parameters

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

  • publicKey - public key, required parameter, string,

  • to - recepient address, required parameter, string,

  • amount - amount in internal integer format, required parameter, string,

  • fee - transaction commission, required parameter, string,

  • gasLimit - maximum amount of work performed by the validator to process a transaction, required parameter, string,

  • gasPrice - price for unit of validator work, required parameter, string,

  • nonce - a one-time transaction number, required parameter, number,

  • data - transfer data, required parameter (gathered through the corresponding method or an empty string),

Transaction Signing

Swagger Transaction Attach signature

Request Structure

POST /api/transaction/attach-signature/{chain}

{
   publicKey: string;
   network?: Network;
   to: string | null;
   amount: string;
   gasLimit: string;
   gasPrice: string;
   nonce: number;
   data: string;
   signature: {
      s: string;
      r: string;
      recovery: number;
   };
}
{
  requestId: string;
  data: { txdata: string };
}

Parameters

  • publicKey - public key, required parameter, string,

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

  • to - recepient address, required parameter, string,

  • amount - amount in internal integer format, required parameter, string,

  • fee - transaction commission, required parameter, string,

  • gasLimit - maximum amount of work performed by the validator to process a transaction, required parameter, string,

  • gasPrice - price for unit of validator work, required parameter, string,

  • nonce - a one-time transaction number, required parameter, number,

  • data - transfer data, required parameter (gathered through the corresponding method or an empty string),

  • signature - signing data object, required parameter.

Sending Transaction to Network

Swagger Transaction Send

Request Structure

POST /api/transaction/send/{chain}

{
   txdata: string;
   network?: Network;
}
{
  requestId: string;
  data: { txid: string };
}

Parameters

  • txdata - signed transaction data, required parameter, string,

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