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
Clone the Winter Cardano backend repository:
git clone https://github.com/zenGate-Global/winter-backend-cardano
Navigate to the project directory:
cd winter-cardano-backend
Install the dependencies:
npm install
Configuration
Create a copy of the
.env.example
file and rename it to.env
:cp .env.example .env
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_keyReplace 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 tofalse
for production
- It syncs database upon entity changes. Leave it as
POSTGRES
- leave
POSTGRES_HOST
asdb
to use with docker - leave
POSTGRES_PORT
as5432
to use with docker
- leave
REDIS
- leave
REDIS_HOST
asredis
for use with docker - leave
REDIS_PORT
as6379
for use with docker
- leave
TX_SUBMIT_API
- Direct url to the post endpoint to submit transactions
- Service found here: https://github.com/blinklabs-io/tx-submit-api
Database Setup
Ensure that you have a running PostgreSQL database instance. (docker does this for you)
Update the
POSTGRES_*
variables in the.env
file to match your database configuration.The backend will automatically synchronize the database schema on startup if
POSTGRES_SYNC
is set totrue
.
Redis Setup
Ensure that you have a running Redis instance. (docker does this for you)
Update the
REDIS_*
variables in the.env
file to match your Redis configuration.
Starting the Backend
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.
Make sure you have Docker and Docker Compose installed on your system.
Clone the repo, see docker-compose.yml
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.