#
POST /transaction/add
Send transactions as JSON object. This endpoint is for all transaction types.
#
Supported Transactions
The structure depends on the type parameter.
Transfer WART.
NOTE:
- The
WARTamount must be specified either viawartor viawartE8. - The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
Transfer a specific asset or its pool's liquidity token.
Warning
The amountU64 parameter specifies the number of smallest units of the specified token type. The actual conversion to token units depends on the token type's precision p (one token unit corresponds to 10^p smallest representable units). Note that every asset has its own precision fixed during asset creation whereas any asset pool's liquidity always has precision 8 (like the WART token type).
NOTE:
- The transaction fee must be specified either via
feeor viafeeE8. - The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
Create a new buy or sell limit swap order for a specific asset.
Warning
The amountU64 parameter specifies the number of smallest units of the token that is converted. Depending on the isBuy parameter, this is either WART or the specified asset. The actual conversion to token units depends on the token type's precision p (one token unit corresponds to 10^p smallest representable units). Note that WART has precision 8 whereas the asset has its own precision fixed during asset creation.
NOTE:
- The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
Deposit liquidity into an asset's WART pool.
Warning
The amountU64 parameter specifies the number of smallest units of the specified token type. The actual conversion to token units depends on the assets precision p (one token unit corresponds to 10^p smallest representable units). Note that every asset has its own precision fixed during asset creation.
NOTE:
- The
WARTamount must be specified either viawartor viawartE8. - The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
Withdraw liquidity from an asset's WART pool by redeeming liquidity tokens.
Warning
The amountU64 parameter specifies the number of smallest units of the specified token type. The actual conversion to token units depends on the assets precision p (one token unit corresponds to 10^p smallest representable units). Note that every asset has its own precision fixed during asset creation.
NOTE:
- The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
Cancel a pending transaction or an existing order.
NOTE:
- The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
Create a new asset.
NOTE:
- The transaction fee must be specified either via
feeor viafeeE8. - Miner fee must be exactly representable in a 16 bit encoding.
The transaction hash needed for signature generation is the SHA256 hash of the following bytes:
#
Details on fees
Fees are not subtracted from the amount sent in the transaction. The sender spends both, transfer amount and transaction fee, toAddr receives the transferred amount and the miner of the block including this transaction gets the transaction fee.
For efficiency and compactness transaction fees are internally encoded as 2-byte floating-point numbers (16 bits), where the first 6 bits encode the exponent and the remaining 10 bits encode a 11 bit mantissa starting with an implicit 1. Of course not every 64 bit value can be encoded in 16 bits and only fee 64 bit values which are representable exactly in the 16 bits encoding are accepted. You can use the /tools/encode16bit/from_e8/:feeE8 or /tools/encode16bit/from_string/:feestring endpoints to round an arbitrary 64-bit fee value to an accepted 64 bit value.
#
How to specify the sender?
The sender's address is recovered from the recoverable ECDSA signature signature65. It is implicitly specified by creating a signature with the corresponding private key.
#
Signature generation
The following steps are required:
Call the
/chain/headendpoint and extract thepinHashandpinHeightfields.Generate the secp256k1-ECDSA recoverable signature of the 32-byte transaction hash using the private key corresponding to the sender's address. The signature will have three properties:
r: 32 byte coordinate parameters: 32 byte coordinate parameterrecid: 1 byte recovery id, it should automatically have one of the four values 0,1,2,3.
- Concatenate the parameters to form the 65-byte compact normalized (lower
s) recoverable signature with the following byte structure:
Note that this is not the standard compact recoverable signature representation because in Warthog, the recoverable id is the last byte of the 65 byte signature and has no offset of 27.
#
Integration guides
We provide working code snippets on how to generate and send transactions in Python3, Elixir and NodeJS.