Skip to main content

Currency API Documentation

The Shamwari Monetary System (MS) API provides a comprehensive suite of endpoints for creating, managing, and transacting currencies on the Shamwari blockchain. All currency endpoints are served through the API servlet at /nxt and support both HTTP GET and POST request methods.

Base Configuration

ConfigurationValue
Default Port22024
SSL Port22024
API Endpoint/nxt
API TagMS (Monetary System)
Testnet Port23023
ProtocolHTTP/HTTPS

All currency endpoints are accessed via:

http://localhost:22024/nxt?requestType=<endpointName>

API Tags

Currency endpoints span the following API tags defined in APITag.java:

TagDescription
MSMonetary System — Currency creation, exchange, lending, and transfers
ACCOUNTSAccount queries — Account currency holdings and balances
CREATE_TRANSACTIONTransaction creation — Submitting currency operations
PHASINGPhasing — Time-locked and voted currency transactions
PAYMENTSPayments — Currency payment operations
LOANSLending — Currency loan lifecycle management
SUBSCRIPTIONSSubscriptions — Subscription service management

Currency Response Model (JSONData.currency)

All currency endpoints return responses conforming to the JSONData.currency() structure defined in JSONData.java:

{
"currency": "123456789",
"issuer": "1234567890",
"issuerRS": "NXT-abcd-efgh-ijkl",
"name": "Currency Name",
"code": "CNY",
"description": "Currency Description",
"whitelistProperty": "property_name",
"type": 3,
"chain": 1,
"initialSupplyQNT": "100000000000",
"currentSupplyQNT": "95000000000",
"maxSupplyQNT": "100000000000",
"transactionLimitQNT": "5000000000",
"dailyLimitQNT": "1000000000",
"creationHeight": 100,
"issuanceHeight": 150,
"minDifficulty": 1,
"maxDifficulty": 255,
"algorithm": 0,
"decimals": 8,
"types": ["EXCHANGEABLE", "CONTROLLABLE"],
"numberOfTransfers": 1500,
"numberOfPayments": 3200
}

Currency Response Fields

FieldTypeDescription
currencystringUnique currency ID (unsigned)
issuerstringIssuer account ID
issuerRSstringIssuer account in NXT format
namestringCurrency name (3-10 alphabetic characters)
codestringCurrency trading code (3-5 uppercase letters)
descriptionstringFree-text description (max 1000 chars)
whitelistPropertystringProperty name for whitelist control
typeintBitvector of currency capabilities
chainintBeta chain ID
initialSupplyQNTstringInitial supply at issuance
currentSupplyQNTstringCurrent circulating supply
maxSupplyQNTstringMaximum allowable supply
transactionLimitQNTstringPer-transaction transfer limit
dailyLimitQNTstringDaily transfer limit
creationHeightintBlock height of currency creation
issuanceHeightintBlock height at which currency becomes active
minDifficultyintMinimum minting difficulty exponent
maxDifficultyintMaximum minting difficulty exponent
algorithmbyteHashing algorithm for minting
decimalsbyteDivisibility (decimal places)
typesarrayArray of CurrencyType strings
numberOfTransfersintTotal transfer count (when includeCounts=true)
numberOfPaymentsintTotal payment count (when includeCounts=true)

CurrencyType Bitmask Values

TypeCodeDescription
SHARED1Shared currency type
PERSONAL2Personal currency type
EXCHANGEABLE4Can be traded on the exchange
CLAIMABLE8Can be claimed by holders
MINTABLE16Supports minting of new units
CONTROLLABLE32Supports transaction/daily limits
RESERVABLE64Reserved for future use
SOVEREIGN128Sovereign reference currency

Account Currency Response Model (JSONData.accountCurrency)

Used by endpoints returning account-holding relationships:

{
"account": "1234567890",
"accountRS": "NXT-abcd-efgh-ijkl",
"currency": "987654321",
"unitsQNT": "5000000000",
"unconfirmedUnitsQNT": "1000000000"
}

Currency Transfer Response Model (JSONData.currencyTransfer)

Used by transfer-related endpoints:

{
"transferFullHash": "abc123def456...",
"chain": 1,
"currency": "987654321",
"sender": "1234567890",
"senderRS": "NXT-abcd-efgh-ijkl",
"recipient": "0987654321",
"recipientRS": "NXT-zyxw-vuts-rqpo",
"unitsQNT": "1000000000",
"taxUnitsQNT": "5000000",
"height": 250,
"timestamp": 123456789
}

Exchange Response Model (JSONData.exchange)

Used by exchange-related endpoints:

{
"transactionFullHash": "abc123...",
"timestamp": 123456789,
"unitsQNT": "1000000000",
"rateQNTPerUnit": "500",
"currency": "987654321",
"baseCurrency": "555555555",
"offer": "111111111",
"offerFullHash": "def456...",
"seller": "1234567890",
"buyer": "0987654321",
"block": "50000",
"height": 250
}

Error Handling

All currency endpoints return standardized error responses defined in JSONResponses.java:

Error CodeConstantDescription
ERROR_INCORRECT_CURRENCYINCORRECT_CURRENCYInvalid currency parameters
ERROR_INCORRECT_CURRENCY_NAME_LENGTHINCORRECT_CURRENCY_NAME_LENGTHCurrency name outside 3-10 char range
ERROR_INCORRECT_CURRENCY_CODE_LENGTHINCORRECT_CURRENCY_CODE_LENGTHCurrency code outside 3-5 char range
ERROR_INCORRECT_CURRENCY_DESCRIPTION_LENGTHINCORRECT_CURRENCY_DESCRIPTION_LENGTHDescription exceeds 1000 chars
ERROR_UNKNOWN_CURRENCYUNKNOWN_CURRENCYRequested currency not found
ERROR_MISSING_CURRENCYMISSING_CURRENCYCurrency parameter missing
ERROR_MISSING_CURRENCY_ACCOUNTMISSING_CURRENCY_ACCOUNTBoth currency and account parameters missing
ERROR_CANNOT_DELETE_CURRENCYCANNOT_DELETE_CURRENCYCurrency cannot be deleted by this account
ERROR_NOT_CURRENCY_ISSUERNOT_CURRENCY_ISSUERSender is not the currency issuer
ERROR_NOT_ENOUGH_CURRENCYNOT_ENOUGH_CURRENCYInsufficient currency balance
ERROR_CURRENCY_NOT_LIMITEDCURRENCY_NOT_LIMITEDCurrency is not controllable type
ERROR_NO_COST_ORDERNO_COST_ORDERZero-value exchange order
ERROR_INCORRECT_LOANINCORRECT_LOANInvalid loan parameters

Complete Endpoint Index

Currency Creation & Administration

EndpointRequest TypeMethodTag
IssueCurrencyissueCurrencyPOSTMS, CREATE_TRANSACTION
DeleteCurrencydeleteCurrencyPOSTMS, CREATE_TRANSACTION
CanDeleteCurrencycanDeleteCurrencyGETMS
AdjustCurrencyLimitsadjustCurrencyLimitsPOSTMS, CREATE_TRANSACTION
GetCurrencygetCurrencyGETMS
GetCurrenciesgetCurrenciesGETMS
GetCurrencyIdsgetCurrencyIdsGETMS
GetCurrenciesByIssuergetCurrenciesByIssuerGETMS, ACCOUNTS

Currency Transfers & Payments

EndpointRequest TypeMethodTag
TransferCurrencytransferCurrencyPOSTMS, CREATE_TRANSACTION
GetCurrencyTransfersgetCurrencyTransfersGETMS
GetExpectedCurrencyTransfersgetExpectedCurrencyTransfersGETMS
CurrencyPaymentcurrencyPaymentPOSTMS, CREATE_TRANSACTION
GetCurrencyPaymentsgetCurrencyPaymentsGETMS
GetExpectedCurrencyPaymentsgetExpectedCurrencyPaymentsGETMS
CurrencyBulkPaymentcurrencyBulkPaymentPOSTMS, CREATE_TRANSACTION
GetCurrencyBulkPaymentsgetCurrencyBulkPaymentsGETMS

Currency Trading & Exchange

EndpointRequest TypeMethodTag
CurrencyBuycurrencyBuyPOSTMS, CREATE_TRANSACTION
CurrencySellcurrencySellPOSTMS, CREATE_TRANSACTION
CurrencyMintcurrencyMintPOSTMS, CREATE_TRANSACTION
GetExchangesgetExchangesGETMS
GetAllExchangesgetAllExchangesGETMS
GetExchangesByOffergetExchangesByOfferGETMS
GetExchangesByExchangeRequestgetExchangesByExchangeRequestGETMS
GetLastExchangesgetLastExchangesGETMS
PublishExchangeOfferpublishExchangeOfferPOSTMS, CREATE_TRANSACTION
GetExpectedExchangeRequestsgetExpectedExchangeRequestsGETMS
GetAccountExchangeRequestsgetAccountExchangeRequestsGETMS

Account Currency Holdings

EndpointRequest TypeMethodTag
GetCurrencyAccountsgetCurrencyAccountsGETMS
GetAccountCurrencyCountgetAccountCurrencyCountGETMS
GetAccountCurrencyVaultsgetAccountCurrencyVaultsGETMS
GetAccountCurrencySavingsgetAccountCurrencySavingsGETMS
GetAccountCurrencyLoansgetAccountCurrencyLoansGETMS

Currency Phasing & Controls

EndpointRequest TypeMethodTag
GetCurrencyPhasedTransactionsgetCurrencyPhasedTransactionsGETMS, PHASING
GetCurrencyTaxRecordsgetCurrencyTaxRecordsGETMS

Lending & Loans

EndpointRequest TypeMethodTag
LendCurrencylendCurrencyPOSTMS, CREATE_TRANSACTION
LoanApplicationloanApplicationPOSTMS, CREATE_TRANSACTION
LoanRepaymentloanRepaymentPOSTMS, CREATE_TRANSACTION
RescueLoanrescueLoanPOSTMS, CREATE_TRANSACTION
GetLoangetLoanGETMS
GetLoanApplicationsgetLoanApplicationsGETMS
GetActiveLoansgetActiveLoansGETMS
GetPaidLoansgetPaidLoansGETMS
GetOverdueLoansgetOverdueLoansGETMS
GetAccountCurrencyLoansgetAccountCurrencyLoansGETMS

Savings, Vaults & Subscriptions

EndpointRequest TypeMethodTag
CurrencySavingscurrencySavingsPOSTMS, CREATE_TRANSACTION
CurrencyVaultcurrencyVaultPOSTMS, CREATE_TRANSACTION
CreateSubscriptionServicecreateSubscriptionServicePOSTMS, CREATE_TRANSACTION
SubscriptionPaymentsubscriptionPaymentPOSTMS, CREATE_TRANSACTION
UpdateSubscriptionPlansupdateSubscriptionPlansPOSTMS, CREATE_TRANSACTION
GetSubscriptionServicesgetSubscriptionServicesGETMS
GetSubscriptionPaymentsgetSubscriptionPaymentsGETMS

Common Parameters

All currency endpoints accept the following common parameters unless explicitly overridden:

ParameterTypeDescriptionRequired
requestTypestringAPI endpoint nameYes
secretPhrasestringAccount passphrase for signingYes (for POST)
publicKeystringAccount public key (hex)No
accountstringAccount ID or NXT-format addressNo
adminPasswordstringAdmin password for privileged opsNo
chainintChain ID for multi-chainNo
firstIndexintPagination start index (default: 0)No
lastIndexintPagination end index (default: MAX)No
heightintBlockchain height for historical queriesNo
timestampintFilter by timestampNo
includeCountsbooleanInclude count fields in responseNo
includeDeletedbooleanInclude deleted currenciesNo
includeCurrencyInfobooleanInclude currency metadata in responseNo
includeLoansbooleanInclude loan detailsNo
withoutWhitelistbooleanExclude whitelist filter in phasingNo

Authentication & Permissions

Currency endpoints are organized by permission requirements defined in API.java:

  • Read-only endpoints (GET): Public access, no authentication required
  • Transaction endpoints (POST): Require secretPhrase or publicKey for account identification
  • Admin endpoints: Require adminPassword parameter for administrative operations
  • CORS support: Enabled when nxt.apiServerCORS=true in configuration

Rate Limiting

Endpoint TypeLimit
Public read APIsNo limit
Write APIs10 req/s per IP
Admin APIsAuthenticated only

Implementation Files

ComponentFileDescription
API RegistryAPI.javaServer configuration, port management, CORS
API EnumAPIEnum.javaEndpoint registry with names and handlers
Response BuilderJSONData.javaJSON response structure builders
TagsAPITag.javaEndpoint categorization tags
Parameter ParserParameterParser.javaCommon parameter extraction utilities
ResponsesJSONResponses.javaStandardized error response definitions
Base HandlerAPIServlet.javaRequest handler base class
Base TransactionCreateTransaction.javaTransaction creation base class

Notes

  • All currency IDs are unsigned 64-bit integers represented as strings to prevent overflow
  • Amounts are in NQT (Nxt Quantum) — the smallest indivisible unit, with decimals determining divisibility
  • The default service port is 22024 for both HTTP and HTTPS
  • All responses include errorCode: 0 on success, with non-zero values indicating errors
  • The API servlet is mounted at /nxt and supports /nxt-proxy for proxy requests
  • JSON responses are generated by JSONData.java methods to ensure consistency across endpoints