Skip to main content

Demo Blockchain Wallets & Subscriptions Configuration

This document describes how to configure blockchain wallet addresses and subscriptions for demo users.

Overview

When seeding demo users, you can now:
  1. Assign blockchain wallet addresses from your local Hardhat node to demo users
  2. Automatically create subscriptions for demo users based on their roles
  3. Automatically create credit balances for demo users

Configuration

Environment Variables

Add these to your .env file:

Getting Wallet Addresses and Private Keys from Hardhat

When you run npm run node in the contracts directory, Hardhat will display a list of accounts with their addresses and private keys. Copy both the address and private key for each account you want to use. IMPORTANT: Private keys are required for demo users to sign blockchain transactions. Without private keys, wallets can only receive/view transactions but cannot sign. Example output from Hardhat:
Format each account as address:private_key in the environment variable.

Subscription Tiers

Demo users are automatically assigned subscription tiers based on their roles:
  • PREMIUM (Yearly subscription, 10,000 credits):
    • ADMIN
    • BANKER
    • LAW_OFFICER
  • PRO (Monthly subscription, 5,000 credits):
    • ANALYST
    • ACCOUNTANT
    • REVIEWER
  • FREE (Pay-as-you-go, 1,000 credits):
    • APPLICANT
    • Other roles

Usage

  1. Start your Hardhat node:
  2. Copy wallet addresses and private keys from the Hardhat output and add them to .env:
  3. Seed demo users via API or script:

Implementation Details

Wallet Assignment

  • Wallets are assigned to demo users in the order they appear in DEMO_BLOCKCHAIN_ACCOUNTS
  • Format: address:private_key pairs (private key is required for signing transactions)
  • Only users without existing wallet addresses will be assigned new wallets
  • Wallet addresses are encrypted in the database (using EncryptedString)
  • Private keys are stored securely in profile_data (using EncryptedJSON)
  • If only address is provided (no private key), wallet can receive/view but cannot sign transactions

Subscription Creation

  • Subscriptions are created with is_active=True
  • Premium and Pro subscriptions have auto_renew=True
  • Free subscriptions have auto_renew=False
  • Subscriptions are linked to users via user_id

Credit Balance Creation

  • Credit balances are created with initial credits based on subscription tier
  • lifetime_earned is set to the initial credit amount
  • lifetime_spent starts at 0
  • Credits are stored in the universal credit type

Notes

  • If DEMO_BLOCKCHAIN_ACCOUNTS is not set, wallet assignment is skipped (no error)
  • If there are more users than wallet addresses, only the first N users get wallets
  • Existing wallets are not overwritten
  • Subscriptions and credits are created/updated on every user seed (idempotent)