Structure

Overview of the structure of the Fireblocks retail demo application, including the database models and the business-logic services.

Database Models


User

Represents a user of the application.

Columns: id (PK), email, name, googleId, githubId, password, wallet (FK)

Wallet

Represents a user's wallet.

Columns: id (PK), name, user (FK), assets (FK), transactions (FK), assetBalances (FK), description

Asset

Represents a cryptocurrency asset.

Columns: id (PK), assetId, assetName, address, isSwept, balance, vaultAccount (FK), wallet (FK)

Transaction

Represents a cryptocurrency transaction.

Columns: id (PK), assetId, status, fireblocksTxId, txHash, amount, isSweeping, wallet (FK), sourceVaultAccount (FK), destinationVaultAccount (FK), sourceExternalAddress, destinationExternalAddress, outgoing, createdAt

VaultAccount

Represents a Fireblocks vault account.

Columns: id (PK), fireblocksVaultId, name, assets (FK), balance, sourceTransactions (FK), destinationTransactions (FK)

WalletAssetBalance

Represents the balance of an asset in a wallet.

Columns: id (PK), wallet (FK), assetId, totalBalance, incomingPendingBalance, outgoingPendingBalance

SupportedAssets

Represents the list of the assets supported by the demo application.

Columns: id (PK), explorerUrl, fireblocksAssetId, depositCounter, name


Services

Handles user authentication and creation.

Description: The AuthService provides the functionality for user authentication and log in with email & password / GoogleOAuth2 / GitHub userId.

Handles balance updates for users' asset records and tracks which assets have already been swept to Omnibus.

Manages wallet-related operations.

Interacts with Fireblocks vault accounts.

Handles transaction-related operations and updates users' transaction records on the database.

Handles the initialization of a Fireblocks API Client using environment variables.

Description: This service handles the creation of the Fireblocks API Client, which the app uses to interact with the Fireblocks API gateway.
For more information on SDK initialization, check the TypeScript SDK guide.
The ApiClient also introduces two important concepts when working with the Fireblocks API:
a. Idempotent Requests
b. Rate Limits

Interacts with Fireblocks API for transaction creation and processing.
Description: This service wraps the primary endpoints of the Fireblocks SDK to provide the required transaction-related functionality for the demo app.
For more information on these endpoints, check the Transaction section on our API documentation.
It also introduces the important concept of the externalTxId parameter, which is used for unique transaction identification and ensures transactions are idempotent forever.
Learn more in the Manage Withdrawals guide.

Interacts with Fireblocks API for vault account-related operations.
Description: This service wraps several endpoints of the Fireblocks SDK and provides vault account-related functionality to the demo application. It manages vault account creation and updates, as well as asset wallet and deposit address creation for users on the Fireblocks workspace.
For more information on these endpoints, check the Vaults section on our API documentation.
Also, useful information about your vault structure can be found in the Manage Deposits guide.

Manages UTXO asset deposits, monitors their count, and initiates UTXO consolidations in the omnibus vault account
Description: This service handles all the UTXO asset deposit consolidation functionality. It will update the deposit counter for each supported UTXO asset per deposit and will trigger a consolidation Tx to burn small unspent inputs on the omnibus wallet to allow high withdrawal availability for users. Additionally, the service has an automated job that runs periodically to act as a backup to the deposit-triggered process and prevent a situation where more than 250 UTXOs are stored in the omnibus wallet.
For more information, check the Consolidate UTXOs guide.

Handles the functionality to obtain the Tx fee estimations from Fireblocks API and calculates the required fee for a withdrawal Tx.
For more information, check the Estimate Transaction Fee guide.

Handles the functionality for sweeping account-based asset deposits from intermediate deposit vault accounts to the omnibus vault account.
Description: This service acts as a job that runs periodically and checks for balances in the intermediate deposit vault accounts created for users. Once a balance above the sweeping threshold is found, a sweeping Tx is triggered to accumulate all user deposits of account-based assets into the omnibus vault account.
For more information, check the Sweep to Omnibus guide.

Handles balance updates for user deposits based on the webhooks events sent from Fireblocks.
Learn more about Fireblocks webhooks in the Configure Webhooks guide.

Manages real-time communication with the front end.