Wallets
Your Wallet holds the USDR balance that funds
every order you create. getMyWallet reads its
current balance and getMyWalletTransactions walks its transaction history.
Both are token-scoped β there is no wallet id or owner to pass, the
authenticated credentials already identify your company's one wallet.
getMyWallet(currency)β
Reads the authenticated company's wallet.
Signatureβ
getMyWallet(currency?: string): Promise<MyWallet>
Parametersβ
| Name | Type | Required | Description |
|---|---|---|---|
currency | string | No | Defaults to "USDR". Shape-checked as 3-5 uppercase letters; not yet a selector β an organization holds exactly one wallet today, so any well-formed value returns it. |
Returnsβ
MyWallet:
| Field | Type | Meaning |
|---|---|---|
status | string | Wallet status. |
currency | string | Wallet currency. |
amount | string | Wallet balance, as a decimal string. |
Exampleβ
import {
RetornaClientBuilder,
RetornaEnvironment,
} from "@retorna-tech/retorna-gateway-sdk";
const client = new RetornaClientBuilder()
.environment(RetornaEnvironment.SANDBOX)
.clientId(process.env.RETORNA_CLIENT_ID!)
.clientSecret(process.env.RETORNA_CLIENT_SECRET!)
.privateKey(process.env.RETORNA_PRIVATE_KEY!)
.buildClient();
const wallet = await client.getMyWallet(); // defaults to "USDR"
console.log(wallet.amount, wallet.currency, wallet.status);
Errorsβ
Client-side (RetornaSdkError):
currencyset but not 3-5 uppercase letters.
From the API (RetornaB2BError, see the error catalog):
B2B_UNAUTHORIZEDβ credentials, token, or signature rejected.B2B_COMPANY_NOT_FOUNDβ no company is associated with the credentials used.B2B_WALLET_NOT_CONFIGUREDβ your company has no wallet provisioned yet.B2B_WALLET_NOT_FOUNDβ the configured wallet does not exist upstream.
Notesβ
- There is no
ownerIdor wallet id to pass β the token already scopes it to your company. currencyis shape-checked, not yet meaningful as a selector; treatgetMyWallet()with no arguments as the call for your balance today.
API referenceβ
getMyWalletTransactions(type, params, currency)β
Walks the wallet's transaction history for a given transaction type.
Signatureβ
getMyWalletTransactions(
type: WalletTransactionType,
params?: ListWalletTransactionsParams,
currency?: string
): Promise<WalletTransactionsResponse>
Parametersβ
| Name | Type | Required | Description |
|---|---|---|---|
type | "top_up" | Yes | The listing to read. "top_up" is the only value published today and returns every credit to the wallet: on-chain deposits and credits booked by treasury. |
params.cursor | string | No | Opaque cursor from a previous page's pagination.next_cursor. Omit for the first page. |
params.limit | number | No | Page size, 1-100. Fixed for the whole walk once you pass a cursor. |
currency | string | No | Defaults to "USDR". Same shape-check as getMyWallet. |
Returnsβ
WalletTransactionsResponse:
| Field | Type | Meaning |
|---|---|---|
data[].id | string | Transaction id. |
data[].external_id | string | Client-side reference for the transaction. |
data[].type | string | Lowercase transaction type: "top_up" for an on-chain deposit, "b2b_manual_credit" for a credit booked by treasury. |
data[].amount | string | Transaction amount, as a decimal string with two decimals (e.g. "20.00"). |
data[].currency | string | Transaction currency. |
data[].created_at | string | ISO 8601 timestamp. |
data[].status | "PENDING" | "COMPLETED" (optional) | Always "COMPLETED" on a b2b_manual_credit: treasury books it straight into the balance, there is nothing left to settle. On an on-chain top_up it is present only when a settlement status was reported upstream. |
pagination.next_cursor | string | null | Opaque next-page token; null once the walk is finished. |
pagination.has_more | boolean | Same end-of-list condition as a null next_cursor. |
pagination.limit | number | Effective page size of the walk. |
pagination.total | number | null | Total of the filtered dataset, or null when unknown. |
Exampleβ
let cursor: string | undefined;
do {
const page = await client.getMyWalletTransactions("top_up", { cursor, limit: 50 });
for (const tx of page.data) {
console.log(tx.id, tx.external_id, tx.amount, tx.currency, tx.status, tx.created_at);
}
cursor = page.pagination.next_cursor ?? undefined;
} while (cursor);
Errorsβ
Client-side (RetornaSdkError):
typeempty,currencyset but not 3-5 uppercase letters, orparams.limitset but not an integer between 1 and 100.
From the API (RetornaB2BError):
B2B_UNAUTHORIZEDβ credentials, token, or signature rejected.B2B_COMPANY_NOT_FOUNDβ no company is associated with the credentials used.B2B_WALLET_NOT_CONFIGURED/B2B_WALLET_NOT_FOUNDβ same asgetMyWallet.B2B_INVALID_PAGINATION_CURSORβ the cursor could not be decoded, or was not issued by this listing.
Notesβ
- Same cursor rules as order listings β see
pagination for the full details, including why
an empty
?cursor=is invalid rather than "start over." statusnever defaults when the upstream settlement status of atop_upis unknown β absent, not guessed. Ab2b_manual_creditis the one row that always carries"COMPLETED", because its type alone proves the funds are credited.