Skip to Content

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

FileRead byHolds
.envThe API, event poller, Docker Compose, and CLI scriptsRPC_URL, CHAIN_ID, PRIVATE_KEY, DATABASE_URL, and the NEXT_PUBLIC_* values for the Docker app preview
app/.env.localpnpm app:devThe NEXT_PUBLIC_* values for the app on your machine
.env.prod (optional)./scripts/deployFactory.sh .env.prodA 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.

VariableValue
NEXT_PUBLIC_FACTORY_ADDRESSThe factory the app mints against.
NEXT_PUBLIC_CHAIN_ID98866 for Plume Mainnet.
NEXT_PUBLIC_API_URLhttp://localhost:8293, the API as your browser reaches it.
NEXT_PUBLIC_OPERATOR_ADDRESSOptional. 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.

WalletControlsWhere it livesNeeded for the app?
Factory ownerUpgrades for every cap table on its factory (updateCapTableImplementation)Cold storage, used only for a deploy or an upgradeNo
Issuer adminThe cap table it created with createCapTable: roles, authorized shares, and day-to-day writesYour browser wallet in /appYes
Server keyServer-signed routes such as POST /stakeholder/create and POST /transactions/issuance/stockPRIVATE_KEY in the root .envNo
  • 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_ADDRESS holds 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 bootstrap
  • REUSE_TAP_FACTORY=1 registers TAP’s shared demo factory in MongoDB. To use your own factory instead, leave it out and deploy a factory.
  • SKIP_APP=1 leaves port 3000 free for pnpm 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.

ServiceAddress
APIhttp://localhost:8293 
Product apppnpm app:dev, then http://localhost:3000/app 
MongoDBlocalhost: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 dev

Start 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.

Last updated on