Skip to main content

Winter Cardano Backend

The Winter Cardano backend is a server-side application that provides APIs for interacting with the Winter protocol on the Cardano blockchain. It is built using the Nest.js framework with TypeScript and runs on the Node.js runtime.

Architecture

The backend follows a modular and scalable architecture, leveraging the capabilities of Nest.js. It is designed to work seamlessly with the winter-cardano library, which handles the core functionality of the Winter protocol.

The main components of the backend include:

  • Blockchain Endpoints: These endpoints handle interactions with the Cardano blockchain, such as tokenizing commodities, recreating commodities, spending commodities, and retrieving commodity details. They utilize the winter-cardano library to build and submit transactions.

  • Database Integration: The backend integrates with a PostgreSQL database using TypeORM to store and retrieve data related to transactions and commodities. It also uses Redis for managing UTXO (Unspent Transaction Output) to prevent double-spending errors.

  • REST API: The backend exposes a REST API that allows clients to interact with the Winter protocol. The API endpoints are organized into two main categories: blockchain endpoints and database endpoints.

UTXO Management

UTXO management for a single wallet is a complex and evolving process. Currently redis is used to process blockchain endpoints sequentially. This prevents double spending errors. The backend checks for available utxos, if the uxto selected is in the process of being spent in the mempool, the backend polls for new utxos every ten seconds, up to a minute. Users will need to use the check endpoint to get status information.

Scalability and Modularity

Nest.js was chosen as the framework for the Winter Cardano backend due to its modularity and scalability features. It provides a structured and extensible architecture that allows for easy maintenance and growth of the application.

The modular design of Nest.js enables the separation of concerns and promotes code reusability. Each module encapsulates a specific functionality, making it easier to develop, test, and maintain individual components of the backend.

Performance and Efficiency

The Winter Cardano backend is designed to handle a high volume of requests efficiently. It leverages the power of Node.js and its event-driven, non-blocking I/O model to handle concurrent requests and maximize throughput.

The backend also implements efficient UTXO management using Redis to ensure the integrity of transactions and prevent double-spending. It intelligently selects available UTXOs and handles scenarios where UTXOs are being spent in the mempool.