Blockchain Connector BTC-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-btc-like/v1
For this server address, interaction with the following blockchains is available:
- btc;
- ltc;
- bch;
- doge.
The structure of requests and 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:
AddressType
AddressType - Legacy (p2pkh) or SegWit (p2wpkh) address format, applicable only for Bitcoin and Litecoin blockchains. Data structure:
UTXO
UTXO - unspent transaction output. Data structure:
txid
- transaction identifier;vout
- output identifier in this transaction;value
- amount.
API
Generate Address from Public Key
Swagger Get address
Request Structure
POST /api/get-address/{chain}
Parameters
-
publicKey
- public key, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network), -
type
- address format, optional parameter, default value'p2wpkh'
, forbch
this parameter is ignored (AddressType), -
prefix
- true if address contains prefix, optional parameter, default valuefalse
(boolean).
Getting Data to Form a Transaction
To form and estimate transaction fee it is required to get the following set of data:
- UTXO list,
- transaction size,
- price per byte.
Swagger Prepare transaction API
Estimate endpoint allows you to get all data required for transaction formation and estimation with one request. Also there is a possibility to get this data in three separate requests: (utxo-list, size, price-per-byte).
Estimate
This endpoint provides all the data required for transaction formation and estimation
Swagger Prepare transaction Estimate
Request Structure
POST api/prepare-transaction/estimate/{chain}
Parameters
-
address
- sender address, required parameter, string, -
publicKey
- public key, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network), -
type
- address format, optional parameter, default value'p2wpkh'
, forbch
this parameter is ignored (AddressType), -
to
- recepient address, required parameter, string, -
amount
- amount in internal integer format, required parameter, string,
UTXO list
UTXO list is required to form a correct transaction and estimate its size
Swagger Prepare transaction UTXO
Request Structure
GET /api/prepare-transaction/utxo-list/{chain}?address={address}&network=livenet
Parameters
-
address
- sender address, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network),
Response structure
Transaction size
Transaction size is required to accurately estimate transaction fee size.
Swagger Prepare transaction Size
Request Structure
POST /api/prepare-transaction/size/{chain}
Parameters
-
publicKey
- public key, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network), -
type
- address format, optional parameter, default value'p2wpkh'
, forbch
this parameter is ignored (AddressType), -
utxo
- a list of unspent transaction outputs, required parameter (UTXO), -
to
- recepient address, required parameter, string, -
amount
- amount in internal integer format, required parameter, string,
Price per Byte
Satosha price for one byte of transaction size. It's necessary to estimate the transaction fee correctly. The amount depends on the sending mode (slow, normal, fast). The final transaction fee is calculated as a product of a transaction size and a satosha sum per byte for the chosen sending mode.
Swagger Prepare transaction Price per byte
Request Structure
GET /api/prepare-transaction/price-per-byte/{chain}?network=livenet
Parameters
network
- network type, optional parameter, default value'livenet'
(Network),
Response structure
Transactions
Swagger Transaction API
Getting a Transaction Hash
Swagger Transaction Get hash
Request Structure
POST /api/transaction/get-hash/{chain}
Parameters
-
publicKey
- public key, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network), -
type
- address format, optional parameter, default value'p2wpkh'
, forbch
this parameter is ignored (AddressType), -
utxo
- a list of unspent transaction outputs, required parameter (UTXO), -
to
- recepient address, required parameter, string, -
amount
- amount in internal integer format, required parameter, string, -
fee
- transaction commission, required parameter, string,
Transaction Signing
Swagger Transaction Attach signature
Request Structure
POST /api/transaction/attach-signature/{chain}
Parameters
-
publicKey
- public key, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network), -
type
- address format, optional parameter, default value'p2wpkh'
, forbch
this parameter is ignored (AddressType), -
utxo
- a list of unspent transaction outputs, required parameter (UTXO), -
to
- recepient address, required parameter, string, -
amount
- amount in internal integer format, required parameter, string, -
fee
- transaction commission, required parameter, string, -
signatures
- array of objects with signing data, required parameter.
Sending Transaction to Network
Swagger Transaction Send
Request Structure
POST /api/transaction/send/{chain}
Parameters
-
txdata
- signed transaction data, required parameter, string, -
network
- network type, optional parameter, default value'livenet'
(Network),