Skip to main content

CurrencyBuy

Buys currency units using Shamwari coin (FXT). The transaction attempts to match existing sell offers at the best available price.

Request

POST /nxt?requestType=currencyBuy

Parameters

NameTypeDescriptionRequired
secretPhrasestringBuyer's secret passphraseYes
currencylongCurrency ID to buyYes
baseCurrencylongBase currency ID (coin) used for paymentYes
rateQNTPerUnitlongExchange rate (QNT per unit)Yes
unitsQNTlongNumber of units to buyYes
feeRateQNTPerFXTlongTransaction fee rateOptional
deadlineintTransaction deadline in minutesOptional

How Currency Buy Works

  1. The transaction attempts to match existing sell offers on the exchange
  2. When a match is found, the minimum units between the sell offer and the buy order are exchanged at the rate matching the lowest sell offer
  3. A single transaction can match multiple sell offers or none
  4. Currency buy orders are NOT saved — they execute immediately (fully or partially) or not at all
  5. For each match, an exchange record is created (retrievable via GetExchanges)

Response

{
"transaction": "1234567890123456789",
"fullHash": "abc123...",
"errorCode": 0,
"errorDescription": ""
}

Error Handling

ErrorCondition
NO_COST_ORDERCalculated cost is zero
NOT_ENOUGH_FUNDSInsufficient coin balance
UNKNOWN_CURRENCYCurrency does not exist

Example

curl -X POST http://localhost:22024/nxt \
-d "requestType=currencyBuy" \
-d "secretPhrase=your_phrase" \
-d "currency=987654321" \
-d "baseCurrency=1" \
-d "rateQNTPerUnit=500" \
-d "unitsQNT=1000000000"