Skip to content

Transaction API

Transaction API sends transactions and gets their information.

Create transaction

Create a transaction to be sent to the blockchain network. You can create transactions for sending native tokens or executing smart contracts.

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/tx
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/tx
HTTP Method POST
Content-Type application/json

Header parameters

Field Name Description Type Required
x-network Blockchain network string Y
Authorization Authentication token for calling the API string Y

Request body

Field Name Description Type Required
from The account address that will send the transaction to the blockchain. string Y
to * For smart contract transactions, such as a transaction calling a contract function: the smart contract address
* For transactions sending native tokens: the account address that will receive tokens
string Y
amount * For smart contract transactions, such as a transaction calling a contract function: enter 0
* For transactions sending native tokens: enter the amount of tokens to send
string Y
data For smart contract transactions, this is the contract function name and the contract function parameter information.
* Polygon: Web3js encodeABI can be used to generate data value
* XPLA: XPLAjs message creation can be used to generate data value
json * For smart contract transactions: Y
* For transactions sending native tokens: N
encoded Whether the transaction returned should be encoded (true: Encoded Raw Transaction String, false: Decoded JSON result) boolean N

Responses

Field Name Description Type
code API call result code, 0: Success number
message Result message string
data API response data json
data.rawTx Transaction data string or json
data.hashedTx The hashed data.rawTx. You receive this value only if the API header x-network is polygon and the Request Body from is a multi-signature wallet address. string
data.requestId A unique identifier for the API request string

Request sample

curl -X 'POST' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/tx' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Content-Type: application/json' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNvbS5jb20yd...' 
  -d '{
  "from": "0x9428e6eF51FEb2201676deEc11B7E36F7c1F0765",
  "to": "0xFBd488D1b00604d3b05124d80E35FeA9A39C3296",
  "amount": "0.001",
  "data": "",
  "encoded": true
}'

Response sample

{
  "code": 0,
  "message": "success",
  "data": {
    "rawTx": "02f68301388182013484618b021e84618b0235827b0c94fbd488d1b00604d3b05124d80e35fea9a39c329687038d7ea4c6800080c0808080",
    "requestId": "93ff43f7-3e19-42e1-a7d0-bbff40be1361"
  }
}

Get transaction information

Gets the transaction information using a transaction hash (txhash). Only the information of the transactions recorded on a blockchain can be returned.

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/tx/{txhash}
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/tx/{txhash}
HTTP Method GET
Content-Type application/json

Path parameters

Field Name Description Type Required
txhash the transaction hash string Y

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.txhash the transaction hash string
data.blockNumber the block number of the block that contains the transaction number
data.contractAddress The contract address if the transaction involves deploying a contract string
data.status the transaction status (success after the transaction was successfully recorded on a block of a blockchain) string
data.fee the applied fee json
data.data the transaction data
* Polygon
* XPLA
json
data.logs the transaction log json

Request sample

curl -X 'GET' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/tx/0x5a0ca3a7eebbafa946da6ed0160930fc4f334887dbf11a9b38937ab8831fd125' 
  -H 'accept: application/json' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNvbS5jb20yd...' 
  -H 'x-network: polygon'

Response sample

// Polygon Transaction
{
  "code": 0,
  "message": "success",
  "data": {
    "txhash": "0x5a0ca3a7eebbafa946da6ed0160930fc4f334887dbf11a9b38937ab8831fd125",
    "blockNumber": 33457511,
    "contractAddress": "0x4377C1bE43Db73561f1179e2637CFf0bbD617eFC",
    "status": "success",
    "fee": {
      "gas": 151232,
      ...
    },
    "data": {
      "from": "0x9428e6eF51FEb2201676deEc11B7E36F7c1F0765",
      ..
     },
    "logs": [
      {
        "transactionHash": "0x5a0ca3a7eebbafa946da6ed0160930fc4f334887dbf11a9b38937ab8831fd125",
        ....
      }
    ]
  }
}
// Xpla Transaction
{
  "code": 0,
  "message": "success",
  "data": {
    "txhash": "E21E0CC37CD1BCACADFDEBD4C7AF2F68257EA4591D670F4AA0A725B21422C29F",
    "blockNumber": 4818400,
    "contractAddress": "0x4377C1bE43Db73561f1179e2637CFf0bbD617eFC",
    "status": "success",
    "fee": {
      "gasUsed": 21000,
      ...
    },
    "data": {
      "memo": "",
      ...
    },
    "logs": [
      {
        "msg_index": 0,
        ...
      }
    ]
  }}

Send transaction

Sends the signed transaction to a blockchain.

Note

The signing on a transaction must be done by the gamer in his/her private wallet or must be served by the game studio.

Note

The transferral might fail though the transaction hash (txhash) was returned in response. Please check the data.status from Get Transaction Information API to verify the transferral result of the transaction.

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/send
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/send
HTTP Method POST
Content-Type application/json

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Request body

Note

The notifier of the transaction transferral result (callbackUrl) is only provided from the Hive Blockchain API.

Field Name Description Type Required
signedTx the signed transaction string Y
sync the synchronous/asynchronous process of the transaction
* true: The transaction will be processed in a sychronous way, meaning that the API will wait until the transaction is finished being recorded on a blockchain. After sending the API request, the API waits until it gets the response value (txHash).
* false: The transaction will be processed in an asychronous way, meaning that you may not get the result of transaction transferral at the moment. You need to use Get Transaction Information API to verify the transferral result of the transaction.
boolean Y

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.txhash the transaction hash string
data.status the transaction status string
Note

If it is asynchronous, you may not be able to get the response or data.status can be pending. The status will be changed after the transaction is loaded on a blockchain.

Request sample

curl -X 'POST' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/send' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Content-Type: application/json' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNvbS5jb20yd...' 
  -d '{
  "signedTx": "0x02f8b58301388181b985016d14154585016d1415578289219494853bdc9c...",
  "sync": false
}'

Response sample

// Polygon
{
  "code": 0,
  "message": "success",
  "data": {
    "txhash": "0x53e8783e4da707daf58c96a8cea278e7b2a8a5f185af0913b518974556c79076",
    "status": "pending"
  }
}
// Xpla
{
  "code": 0,
  "message": "success",
  "data": {
    "txhash": "84655BB965D709A4AAD4104C7FFBD8E42F52F0BB313493FFDCA02B01FE983A8F",
    "status": "pending"
  }
}