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:- Assign blockchain wallet addresses from your local Hardhat node to demo users
- Automatically create subscriptions for demo users based on their roles
- 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 runnpm 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:
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
-
Start your Hardhat node:
-
Copy wallet addresses and private keys from the Hardhat output and add them to
.env: -
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_keypairs (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(usingEncryptedJSON) - 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_earnedis set to the initial credit amountlifetime_spentstarts at 0- Credits are stored in the
universalcredit type
Notes
- If
DEMO_BLOCKCHAIN_ACCOUNTSis 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)