Skip to main content

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​

NameTypeRequiredDescription
currencystringNoDefaults 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:

FieldTypeMeaning
statusstringWallet status.
currencystringWallet currency.
amountstringWallet 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):

  • currency set 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 ownerId or wallet id to pass β€” the token already scopes it to your company.
  • currency is shape-checked, not yet meaningful as a selector; treat getMyWallet() with no arguments as the call for your balance today.

API reference​

GET /me/wallets/{currency}

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​

NameTypeRequiredDescription
type"top_up"YesThe 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.cursorstringNoOpaque cursor from a previous page's pagination.next_cursor. Omit for the first page.
params.limitnumberNoPage size, 1-100. Fixed for the whole walk once you pass a cursor.
currencystringNoDefaults to "USDR". Same shape-check as getMyWallet.

Returns​

WalletTransactionsResponse:

FieldTypeMeaning
data[].idstringTransaction id.
data[].external_idstringClient-side reference for the transaction.
data[].typestringLowercase transaction type: "top_up" for an on-chain deposit, "b2b_manual_credit" for a credit booked by treasury.
data[].amountstringTransaction amount, as a decimal string with two decimals (e.g. "20.00").
data[].currencystringTransaction currency.
data[].created_atstringISO 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_cursorstring | nullOpaque next-page token; null once the walk is finished.
pagination.has_morebooleanSame end-of-list condition as a null next_cursor.
pagination.limitnumberEffective page size of the walk.
pagination.totalnumber | nullTotal 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):

  • type empty, currency set but not 3-5 uppercase letters, or params.limit set 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 as getMyWallet.
  • 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."
  • status never defaults when the upstream settlement status of a top_up is unknown β€” absent, not guessed. A b2b_manual_credit is the one row that always carries "COMPLETED", because its type alone proves the funds are credited.

API reference​

GET /me/wallets/{currency}/transactions/{type}