Creating a New Transaction
To create a new transaction, use the POST /transaction/add API method. POST data must be in JSON format and describes the transaction data in a JSON object. There must always exist a type string property that describes the transaction type which determines the other required parameters.
Transaction Types
Common Parameters
The following parameters are common to all transaction types:
Either feeE8 or feeStr must be specified. The fee must be exactly representable in a 16-bit encoding (see
Transaction Types
Transfer WART tokens to another address.
Parameters:
Either wartE8 or wartStr must be specified.
Example Request:
{
"type": "wartTransfer",
"toAddr": "848b08b803e95640f8cb30af1b3166701b152b98c2cd70ee",
"wartStr": "1.5",
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Transfer a specific asset or its pool's liquidity token.
Parameters:
The amountU64 specifies the smallest units. The conversion to token units depends on the asset's precision p (one token unit = 10^p smallest units). Assets have their own precision, while liquidity tokens always have precision 8 (like WART).
Example Request:
{
"type": "tokenTransfer",
"assetHash": "0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c",
"isLiquidity": false,
"toAddr": "848b08b803e95640f8cb30af1b3166701b152b98c2cd70ee",
"amountU64": 1000000,
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Create a new buy or sell limit order for a specific asset.
Parameters:
For buy orders, amountU64 is in WART (precision 8). For sell orders, it's in the asset's smallest units (precision varies by asset).
Example Request:
{
"type": "limitSwap",
"assetHash": "0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c",
"isBuy": true,
"amountU64": 100000000,
"limit": "c0e74d",
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Deposit liquidity into an asset's WART pool.
Parameters:
Either wartE8 or wartStr must be specified.
Example Request:
{
"type": "liquidityDeposit",
"assetHash": "0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c",
"amountU64": 1000000,
"wartStr": "10.0",
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Withdraw liquidity from an asset's WART pool by redeeming liquidity tokens.
Parameters:
Example Request:
{
"type": "liquidityWithdrawal",
"assetHash": "0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c",
"amountE8": 1000000000,
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Cancel a pending transaction or an existing order.
Parameters:
Example Request:
{
"type": "cancelation",
"cancelHeight": 1198900,
"cancelNonceId": 5,
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Create a new asset.
Parameters:
Example Request:
{
"type": "assetCreation",
"name": "TOK1",
"precision": 8,
"supplyU64": 1000000000000,
"feeStr": "0.0001",
"nonceId": 1,
"pinHeight": 1198931,
"signature65": "..."
}
Signature Hash Bytes:
Fee Encoding
Transaction fees are not subtracted from the transfer amount. The sender spends both the transfer amount and the fee, while toAddr receives only the transferred amount.
For efficiency, fees are encoded as 2-byte floating-point numbers (16 bits):
- First 6 bits: exponent
- Remaining 10 bits: 11-bit mantissa (with implicit leading 1)
Only 64-bit values exactly representable in 16 bits are accepted. Use these endpoints to round arbitrary values:
GET /tools/encode16bit/from_e8/:feeE8- Round from numeric valueGET /tools/encode16bit/from_string/:string- Round from string
Signature Generation
The sender's address is recovered from the ECDSA signature signature65. The signature is created with the private key corresponding to the sender's address.
Steps
Get pinHash: Call
GET /chain/headand extractpinHashandpinHeight.Create transaction hash: Compute SHA256 of the transaction-specific byte sequence (see each transaction type above).
Generate signature: Create a secp256k1-ECDSA recoverable signature with:
r: 32-byte coordinate parameters: 32-byte coordinate parameter (normalized to lower value)recid: 1-byte recovery ID (0, 1, 2, or 3)
Encode signature: Concatenate to form the 65-byte signature:
Warthog uses a custom signature format where the recovery ID is the last byte without the standard offset of 27.
Response
On success, returns the transaction hash:
{
"code": 0,
"data": {
"txHash": "f364da997bf7a3c3bc8ead22041509228d6bdea39fcbcdc6be56030433d54219"
}
}
Integration Guides
Working code examples for generating and sending transactions in Python3, NodeJS, and Elixir.
Libraries