Skip to main content

Setting Up the Winter Cardano Backend

To set up and run the Winter Cardano backend, follow the steps below:

Prerequisites

  • Node.js
  • PostgreSQL database
  • Redis

Installation

  1. Clone the Winter Cardano backend repository:

    git clone https://github.com/zenGate-Global/winter-backend-cardano
  2. Navigate to the project directory:

    cd winter-cardano-backend
  3. Install the dependencies:

    npm install

Configuration

  1. Create a copy of the .env.example file and rename it to .env:

    cp .env.example .env
  2. Open the .env file and provide the necessary configuration values:

    # Network
    NETWORK=mainnet

    # Wallet
    ZENGATE_WALLET_MNEMONIC=your_cardano_wallet_mnemonic

    # PostgreSQL Database
    POSTGRES_HOST=db
    POSTGRES_PORT=5432
    POSTGRES_DB=your_database_name
    POSTGRES_USER=your_database_user
    POSTGRES_PASSWORD=your_database_password
    POSTGRES_SYNC=false
    POSTGRES_LOGGING=false

    # Redis
    REDIS_HOST=redis
    REDIS_PORT=6379

    # Cardano API Providers
    MAESTRO_KEY=your_maestro_api_key
    OGMIOS_HOST=your_ogmios_host
    OGMIOS_PORT=your_ogmios_port
    TX_SUBMIT_API=your_tx_submit_api_url
    KOIOS_BASE_URL=your_koios_base_url

    #IPFS
    NFT_STORAGE_API_KEY=your_key

    Replace the placeholder values with your actual configuration details.

Please note:

  • Its highly recommended to use your cardano wallet mnemonic exclusively for the backend
  • Its highly recommended to use 24 words for your cardano wallet mnemonic
  • For POSTGRES_SYNC
    • It syncs database upon entity changes. Leave it as true during active development. Change to false for production
  • POSTGRES
    • leave POSTGRES_HOST as db to use with docker
    • leave POSTGRES_PORT as 5432 to use with docker
  • REDIS
    • leave REDIS_HOST as redis for use with docker
    • leave REDIS_PORT as 6379for use with docker
  • TX_SUBMIT_API

Database Setup

  1. Ensure that you have a running PostgreSQL database instance. (docker does this for you)

  2. Update the POSTGRES_* variables in the .env file to match your database configuration.

  3. The backend will automatically synchronize the database schema on startup if POSTGRES_SYNC is set to true.

Redis Setup

  1. Ensure that you have a running Redis instance. (docker does this for you)

  2. Update the REDIS_* variables in the .env file to match your Redis configuration.

Starting the Backend

  1. Run the following command to start the backend server:

    npm run start

    The backend server will start running on the specified port (default: 3000).

Docker Compose (Optional)

Alternatively, you can use Docker Compose to run the backend along with the required services.

  1. Make sure you have Docker and Docker Compose installed on your system.

  2. Clone the repo, see docker-compose.yml

  3. Run the following command to start the backend and its dependencies:

    docker-compose up

    The backend server and the required services will start running in containers.

That's it! You have now set up the Winter Cardano backend and it is ready to handle requests.