Initial setup
Setup targets Plume Mainnet. When you’re done, MongoDB, the API, and the event poller run in Docker, and the product app runs on your machine.
Environment files
| File | Read by | Holds |
|---|---|---|
.env | The API, event poller, Docker Compose, and CLI scripts | RPC_URL, CHAIN_ID, PRIVATE_KEY, DATABASE_URL, and the NEXT_PUBLIC_* values for the Docker app preview |
app/.env.local | pnpm app:dev | The NEXT_PUBLIC_* values for the app on your machine |
.env.prod (optional) | ./scripts/deployFactory.sh .env.prod | A factory-owner key for a one-off factory deploy |
Create the root file from the template. Bootstrap creates app/.env.local if it’s missing.
cp .env.example .env.env.example targets Plume Mainnet (CHAIN_ID=98866, RPC_URL=https://rpc.plume.org) and points DATABASE_URL at MongoDB on host port 27027.
Frontend values
pnpm app:dev reads only app/.env.local. The Docker app preview reads the root .env. Keep the two in sync.
| Variable | Value |
|---|---|
NEXT_PUBLIC_FACTORY_ADDRESS | The factory the app mints against. |
NEXT_PUBLIC_CHAIN_ID | 98866 for Plume Mainnet. |
NEXT_PUBLIC_API_URL | http://localhost:8293, the API as your browser reaches it. |
NEXT_PUBLIC_OPERATOR_ADDRESS | Optional. An address that gets OPERATOR_ROLE on each new cap table. Bootstrap leaves it empty, which mints without an extra operator. |
The app connects to browser extension wallets such as Rabby or MetaMask (EIP-6963). It needs no cloud account or project id.
Three wallets and keys
Three different wallets control different things. Keep them separate.
| Wallet | Controls | Where it lives | Needed for the app? |
|---|---|---|---|
| Factory owner | Upgrades for every cap table on its factory (updateCapTableImplementation) | Cold storage, used only for a deploy or an upgrade | No |
| Issuer admin | The cap table it created with createCapTable: roles, authorized shares, and day-to-day writes | Your browser wallet in /app | Yes |
| Server key | Server-signed routes such as POST /stakeholder/create and POST /transactions/issuance/stock | PRIVATE_KEY in the root .env | No |
- The app only needs the issuer admin wallet. You can leave
PRIVATE_KEY=UPDATE_ME: the poller only reads the chain, and server-signed routes fail until you set a real key. NEXT_PUBLIC_OPERATOR_ADDRESSholds an address, not a key. Set it to the server key’s address if you want server-signed routes to work on the cap tables you mint in the app.- Never keep the factory owner key in the long-running
.env. Whoever holds it can upgrade every cap table on that factory. Load it from a separate file for a deploy or upgrade, then remove it.
PRIVATE_KEY in the local .env is for development only. Never put a production or factory-owner key there, and never commit a real key.
Bootstrap the stack
REUSE_TAP_FACTORY=1 SKIP_APP=1 pnpm bootstrapREUSE_TAP_FACTORY=1registers TAP’s shared demo factory in MongoDB. To use your own factory instead, leave it out and deploy a factory.SKIP_APP=1leaves port 3000 free forpnpm app:dev.
Bootstrap is safe to re-run. It creates missing env files, installs dependencies, builds the contracts if chain/out is missing, creates the offchain-db Docker volume, starts MongoDB and the API, waits for the API to answer, and registers a factory if you asked for one.
| Service | Address |
|---|---|
| API | http://localhost:8293 |
| Product app | pnpm app:dev, then http://localhost:3000/app |
| MongoDB | localhost:27027 (not 27017) |
Without SKIP_APP=1, bootstrap also starts a Docker preview of the app on port 3000. Run docker compose stop app before pnpm app:dev.
Local chain (optional)
Contract tests (pnpm test) run in Foundry’s in-memory EVM and don’t need a chain. To work offline against Anvil, run the API on your machine so every process reaches the chain at 127.0.0.1:
# In .env: RPC_URL=http://127.0.0.1:8545, CHAIN_ID=31337, PRIVATE_KEY=<an Anvil test key>
anvil
pnpm docker:mongo
pnpm deploy-factory
pnpm devStart MongoDB before pnpm deploy-factory, because the script registers the new factory there. Anvil keys are public test keys; never use them on a real network.
Next: run the server and app, then deploy or register a factory.