WalletD developers
Exchanges

Post a cross-commodity exchange group atomically

Posts a cross-commodity exchange as one atomic group.

POST/v1/ledgers/{ledgerId}/exchanges

Posts a cross-commodity exchange as one atomic group. Per-commodity zero-sum stays the invariant - the ledger never balances USD against IQD - so an exchange is two or more postings, each balanced in its own commodity, created together and linked by an exchange record that stores the rate as the exact fraction rate_num / rate_den it was struck at. Requires an Idempotency-Key. Because the stored rate describes a trade, the members are not individually reversible; a half-reversed exchange would leave the record describing something that no longer happened.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

ledgerId*string
Formatuuid

Header Parameters

Idempotency-Key*string

Replays return the original response byte-identically within the retention window.

Length1 <= length <= 255

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://example.com/v1/ledgers/497f6eca-6276-4993-bfeb-53cbbbba6f08/exchanges" \  -H "Idempotency-Key: string" \  -H "Content-Type: application/json" \  -d '{    "type": "string",    "from_commodity": "string",    "to_commodity": "string",    "rate_num": 1,    "rate_den": 1,    "postings": [      {        "legs": [          {            "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65",            "direction": "credit",            "amount": 1,            "commodity": "string"          },          {            "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65",            "direction": "credit",            "amount": 1,            "commodity": "string"          }        ]      },      {        "legs": [          {            "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65",            "direction": "credit",            "amount": 1,            "commodity": "string"          },          {            "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65",            "direction": "credit",            "amount": 1,            "commodity": "string"          }        ]      }    ]  }'
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "from_commodity": "string",  "to_commodity": "string",  "rate_num": 0,  "rate_den": 0,  "txn_ids": [    "f6c4a82f-6b80-4863-aa86-516323128055"  ],  "created_at": "2019-08-24T14:15:22Z"}