Skip to content

Wallets

Methods for creating and managing wallets.

Quick Reference

MethodDescription
createWalletCreate a Wallet entity which can then transfer amounts of Tokens.
findBalancesSearch for Balances using either a simple filter or queryBuilder
findWalletsSearch for Wallets using either a simple filter or queryBuilder
getBalanceGet a specific token/wallet balance
getBalanceHistoryGet a list of changes to token/wallet balance
getWalletGet information about a specific Wallet
updateWalletUpdate a Wallet

createWallet

Create a Wallet entity which can then transfer amounts of Tokens.

ts
await client.createWallet(
  {
    foreign: 'test-wallet-2',
    name: 'Irrelevant',
    metadata: {
      awesome: true,
      invalid: false,
    },
  },
  {
    // GENERALOPTIONS
  },
);
ts
{
  wallet: {
    id: 4,
    foreign: '2026-01-01T10:00:00.000Z',
    name: 'Irrelevant',
    metadata: {
      awesome: true,
      invalid: false
    },
    type: 'regular',
    default_allow_negative: false,
    default_allow_positive: true,
    created_at: '2026-01-01T10:00:00.000Z',
    updated_at: '2026-01-01T10:00:00.000Z',
    status: 'active',
    default_dtw_to: '110',
    default_dtw_from: '011'
  }
};

createWalletFnInput

Input for createWallet

AttributeTypeRequiredDescription
foreignstringUser provided key for wallet. Must be unique
namestringUser provided key for wallet. Must be unique
metadata Metadata Key/value object describing this wallet
statusWalletStatus Current status for the wallet
default_allow_negativebooleanBoolean indicating if wallet (pending_amount + finished_amount) can be negative
default_allow_positivebooleanBoolean indicating if wallet (pending_amount + finished_amount) can be positive. Used for token balance to deny positive balance.
options{}Optional flags for input

createWalletFnOutput

Output of createWallet

AttributeTypeAlwaysDescription
wallet{}Wallet|Entities who can make transfers in this system

findBalances

Search for Balances using either a simple filter or queryBuilder

ts
await client
  .findBalances()
  .where({
    wallet: TEST.INFO.WALLETS.validId0,
  })
  .orWhere('amount', '>', 100)
  .orWhere({
    wallet: TEST.INFO.WALLETS.validId1,
    token: 'USD',
  })
  .orWhere((builder) => {
    builder
      .where('updated_at', '<', '2020-01-01')
      .where('amount', '<', -1000000);
  })
  .limit(5)
  .offset(0)
  .orderBy('wallet_foreign', 'desc')
  .options({
    tracking_id: 'hello',
    return_metadata_total: true,
  });
ts
{
  balances: [
    {
      updated_at: '2026-01-01T10:00:00.000Z',
      transfer_id: 2,
      token_id: 1,
      wallet_id: 16,
      pending_amount: 0,
      pending_amount_from: 0,
      pending_amount_to: 0,
      available_balance: 100000,
      finished_amount: 100000,
      latest_control_hash: null,
      amount: 100000,
      token_foreign: 'USD',
      token_metadata: null,
      wallet_foreign: '2026-01-01T10:00:00.000Z',
      wallet_metadata: null
    },
    {
      updated_at: '2026-01-01T10:00:00.000Z',
      transfer_id: 3,
      token_id: 3,
      wallet_id: 17,
      pending_amount: 0,
      pending_amount_from: 0,
      pending_amount_to: 0,
      available_balance: 100000,
      finished_amount: 100000,
      latest_control_hash: null,
      amount: 100000,
      token_foreign: 'GBP',
      token_metadata: null,
      wallet_foreign: '2026-01-01T10:00:00.000Z',
      wallet_metadata: null
    },
    {
      updated_at: '2026-01-01T10:00:00.000Z',
      transfer_id: 1,
      token_id: 2,
      wallet_id: 15,
      pending_amount: 0,
      pending_amount_from: 0,
      pending_amount_to: 0,
      available_balance: 100000,
      finished_amount: 100000,
      latest_control_hash: null,
      amount: 100000,
      token_foreign: 'EUR',
      token_metadata: null,
      wallet_foreign: '2026-01-01T10:00:00.000Z',
      wallet_metadata: null
    },
    {
      updated_at: '2026-01-01T10:00:00.000Z',
      transfer_id: 23,
      token_id: 2,
      wallet_id: 13,
      pending_amount: 0,
      pending_amount_from: 0,
      pending_amount_to: 0,
      available_balance: 123,
      finished_amount: 123,
      latest_control_hash: null,
      amount: 123,
      token_foreign: 'EUR',
      token_metadata: null,
      wallet_foreign: 'VALID9',
      wallet_metadata: null
    },
    {
      updated_at: '2026-01-01T10:00:00.000Z',
      transfer_id: 22,
      token_id: 2,
      wallet_id: 12,
      pending_amount: 0,
      pending_amount_from: 0,
      pending_amount_to: 0,
      available_balance: 121,
      finished_amount: 121,
      latest_control_hash: null,
      amount: 121,
      token_foreign: 'EUR',
      token_metadata: null,
      wallet_foreign: 'VALID8',
      wallet_metadata: null
    }
  ],
  metadata: {
    limit: 5,
    offset: 0,
    total: 7,
    more_rows: true,
    order: [
      {
        field: 'wallet_foreign',
        direction: 'desc'
      }
    ]
  }
};

findBalancesFnInput

Input for findBalances

AttributeTypeRequiredDescription
tokenstring | numberToken to get balance for
walletstring | numberWallet to get balance for
amountstring | numberBalance amount
available_balancestring | numberBalance amount available
pending_amountstring | numberBalance pending_amount
finished_amountstring | numberBalance finished_amount
metadata MetadataSearch Metadata filter for custom properties
options{}Optional flags for input

findBalancesFnOutput

Output of findBalances

AttributeTypeAlwaysDescription
balances({})[]Found balances
metadata{}Metadata about the search

findWallets

Search for Wallets using either a simple filter or queryBuilder

ts
await client
  .findWallets()
  .where({
    metadata: {
      general: true,
    },
  })
  .where('id', '>', 1)
  .where((builder) => {
    builder.whereMetadata('tost', 10).orWhereMetadata('test', 1);
  })
  .limit(5)
  .offset(0)
  .orderBy(['status', { column: 'id', order: 'desc' }])
  .select('id')
  .options({
    tracking_id: 'hello',
  });
ts
{
  wallets: [
    {
      id: 123
    },
    {
      id: 122
    },
    {
      id: 121
    }
  ],
  metadata: {
    limit: 5,
    offset: 0,
    more_rows: false,
    order: [
      {
        field: 'status',
        direction: 'asc'
      },
      {
        field: 'id',
        direction: 'desc'
      }
    ]
  }
};

findWalletsFnInput

Input for findWallets

AttributeTypeRequiredDescription
foreignstring | numberWallet foreign
namestring | numberWallet name
typeWalletType Type of the wallet
statusWalletStatus Current status for the wallet
metadata MetadataSearch Metadata filter for custom properties
options{}Optional flags for input

findWalletsFnOutput

Output of findWallets

AttributeTypeAlwaysDescription
wallets({})[]Found wallets
metadata{}Metadata about the search

getBalance

Get a specific token/wallet balance

ts
await client.getBalance(
  {
    wallet: 'myMbyExistingWallet',
    token: 'MBYTOKEN',
    datetime: '2020-01-01',
  },
  {
    create_wallet_if_not_exists: true,
    create_token_if_not_exists: true,
    create_if_not_exists: true,
    // GENERALOPTIONS
  },
);
ts
{
  balance: {
    token_id: 4,
    wallet_id: 19,
    wallet_foreign: 'myMbyExistingWallet',
    wallet_metadata: null,
    token_foreign: 'MBYTOKEN',
    token_metadata: null,
    pending_amount: 0,
    pending_amount_to: 0,
    pending_amount_from: 0,
    finished_amount: 0,
    available_balance: 0,
    amount: 0,
    latest_control_hash: null,
    updated_at: '2026-01-01T10:00:00.000Z'
  }
};

getBalanceFnInput

Input for getBalance

AttributeTypeRequiredDescription
tokenstring | numberId of the token to get balance in
walletstring | numberId of the wallet to get balance for
datetimestringDate and time this balance should be got
options{}Optional flags for input

getBalanceFnOutput

Output of getBalance

AttributeTypeAlwaysDescription
balance{}

getBalanceHistory

Get a list of changes to token/wallet balance

ts
await TEST.client.getBalanceHistory(
  {
    wallet: 'newWallet',
    token: 'USD',
  },
  {
    create_token_if_not_exists: true,
    create_wallet_if_not_exists: true,
    limit: 5,
    select: [
      'transfer_identifier',
      'pending_amount',
      'finished_amount',
      'pending_amount_from',
      'pending_amount_to',
      'amount',
      // 'balance_id',
      // 'transfer_id',
      // 'transfer_control_hash',
      // 'transfer_from_wallet_id',
      // 'transfer_from_wallet_foreign',
      // 'transfer_to_wallet_id',
      // 'transfer_to_wallet_foreign',
      // 'transfer_amount',
      // 'transfer_type',
      // 'transfer_status',
      // 'transfer_force',
      // 'transfer_created_at',
      // 'transfer_updated_at',
      // 'transfer_metadata',
      // 'transfer_transfer_group_id',
      // 'transfer_transfer_group_identifier',
      // 'transfer_reverses_id',
      // 'transfer_reverses_identifier',
      // 'transfer_status_finalized_at',
      // 'token_id',
      // 'token_foreign',
      // 'wallet_id',
      // 'wallet_foreign',
      // 'latest_control_hash',
      // 'updated_at',
    ],
    offset: 0,
    order: 'desc',
    return_metadata_total: true,
    // GENERALOPTIONS
  },
);
ts
{
  balances: [
    {
      transfer_identifier: 'depositUSD',
      pending_amount: 0,
      pending_amount_to: 0,
      pending_amount_from: 0,
      finished_amount: 10,
      amount: 10
    },
    {
      transfer_identifier: 'depositUSD',
      pending_amount: 10,
      pending_amount_to: 10,
      pending_amount_from: 0,
      finished_amount: 0,
      amount: 10
    }
  ],
  metadata: {
    limit: 5,
    offset: 0,
    total: 2,
    more_rows: false
  }
};

getBalanceHistoryFnInput

Input for getBalanceHistory

AttributeTypeRequiredDescription
tokenstring | numberId of the token to get balance in
walletstring | numberId of the wallet to get balance for
datetimestringSelect entries older than
options{}Optional flags for input

getBalanceHistoryFnOutput

Output of getBalanceHistory

AttributeTypeAlwaysDescription
balances({})[]Resolved balance change objects
metadata{}Metadata about the search

getWallet

Get information about a specific Wallet

ts
await client.getWallet(
  {
    wallet: TEST.INFO.WALLETS.withEURFunds0.foreign,
  },
  {
    // GENERALOPTIONS
    ignore_cache: true,
    create_if_not_exists: true,
    return_only_id: false,
  },
);
ts
{
  wallet: {
    id: 16,
    foreign: '2026-01-01T10:00:00.000Z',
    name: null,
    metadata: null,
    type: 'regular',
    default_allow_negative: false,
    default_allow_positive: true,
    created_at: '2026-01-01T10:00:00.000Z',
    updated_at: '2026-01-01T10:00:00.000Z',
    status: 'active',
    default_dtw_to: '110',
    default_dtw_from: '011'
  }
};

getWalletFnInput

Input for getWallet

AttributeTypeRequiredDescription
walletstring | numberWallet foreign
options{}Optional flags for input

getWalletFnOutput

Output of getWallet

AttributeTypeAlwaysDescription
wallet{}

updateWallet

Update a Wallet

ts
await client.updateWallet(
  {
    wallet: TEST.INFO.WALLETS.withEURFunds0.foreign,
    name: 'WT4',
    status: 'disabled',
    metadata: {
      metadata_number: 2,
    },
  },
  {
    return_when_not_updated: true,
    // GENERALOPTIONS
  },
);
ts
{
  wallet: {
    id: 16,
    foreign: '2026-01-01T10:00:00.000Z',
    name: 'WT4',
    metadata: {
      metadata_number: 2
    },
    type: 'regular',
    default_allow_negative: false,
    default_allow_positive: true,
    created_at: '2026-01-01T10:00:00.000Z',
    updated_at: '2026-01-01T10:00:00.000Z',
    status: 'disabled',
    default_dtw_to: '110',
    default_dtw_from: '011'
  },
  updated: true
};

updateWalletFnInput

Input for updateWallet

AttributeTypeRequiredDescription
walletstring | numberWallet foreign
metadata Metadata Key/value object describing this wallet
namestringUser provided key for wallet. Must be unique
statusWalletStatus Current status for the wallet
default_allow_positivebooleanBoolean indicating if wallet (pending_amount + finished_amount) can be positive. Used for token balance to deny positive balance.
default_allow_negativebooleanBoolean indicating if wallet (pending_amount + finished_amount) can be negative
options{}Optional flags for input

updateWalletFnOutput

Output of updateWallet

AttributeTypeAlwaysDescription
wallet{}Wallet|Entities who can make transfers in this system
updatedbooleanBoolean showing if the wallet was updated