Firebase
your backend in the cloud.
Create a Firebase project, switch on four services, deploy the functions and the rules, and note your API address.
011. Create the project
- New projectOpen console.firebase.google.com, Add project, give it a name. Note the project id.
- Blaze planUpgrade to the pay-as-you-go plan (Cloud Functions, Scheduler and outbound calls need it). In Google Cloud Billing add a budget alert.
- AuthenticationBuild, Authentication, Get started, Sign-in method, enable Anonymous. The app signs in anonymously and nothing else.
- FirestoreBuild, Firestore Database, Create database in Native mode, pick a region close to your users.
- Cloud Messaging is on by default in a new project. It is used by push campaigns (Push).
- Web API keyProject settings, General: copy the Web API key (starts with
AIza). You enter it in the console under App connection. It is public by design.

022. Deploy the functions and rules
Run these in PowerShell. cd, npm and firebase work the same; run the lines one by one instead of joining them with &&.
npm i -g firebase-tools
firebase login
cd firebase
firebase use --add # pick your project; writes .firebaserc
cd functions
npm ci
cd ..
firebase deploy --only firestore:rules,firestore:indexes,functions
- Region:
us-central1by default. To change it copyfunctions/.env.exampletofunctions/.envand setFUNCTIONS_REGION(for exampleeurope-west1) before deploying. - The
apifunction is deployed with public invoker access, because the app calls it without a Google login. It checks Firebase ID tokens itself where needed, and rate limits are set in the console. firestore.rulesdeny everything by default. A signed-in user may read only their ownusers/<uid>document and nothing is client-writable.
The deploy ends with "Deploy complete" and prints the function URL. Open <function URL>/v1/health in a browser: you get {"ok":true,...}. Open <function URL>/v1/config: you get JSON with "token":{"configured":false...} until you set a token.
032b. Deploying the 3.1 features: index, scheduled function and push
Version 3.1 adds two things to the backend that the deploy command above already includes, provided you run it in full. Check both after you update from 3.0:
- Firestore index
alerts(status, firedAt). It is defined infirestore.indexes.jsonand goes out withfirestore:indexes. Index building takes a few minutes; the scheduled function fails until it is ready. Look under Firestore, Indexes, for a status of "Enabled". - Scheduled function
evaluateAlerts. It runs every five minutes and fires price alerts. It needs Cloud Scheduler, so the Blaze plan. After deploy, open Cloud Scheduler in the Google Cloud console and check that the job exists. If you deployed only--only functions:apiearlier, run the full deploy once. - Alerts need push (FCM). An alert is delivered as a push notification. Add your
google-services.jsonto the app and keep Cloud Messaging enabled (see Push). Without push an alert waits and nothing reaches the holder. - Secret for collectible images. The first collectible image request creates a signing secret in
secrets/nftby itself. Nothing to enter.
firebase deploy --only firestore:indexes,functions
The features themselves stay off until you switch them on in the console. The console pages Invites and Price alerts show counts only.
043. Your API address
API_BASE_URL for the app is https://<region>-<project-id>.cloudfunctions.net/api. For your own domain add a Firebase Hosting rewrite from /api/** to the function api; any prefix before /v1 is ignored, and Hosting's CDN honours the API's cache headers.
054. A service account for the console
Project settings, Service accounts, Generate new private key. Save the JSON file outside the source folder and out of git. The console reads its path from GOOGLE_APPLICATION_CREDENTIALS. On Cloud Run or Compute Engine leave the variable empty and use the attached service account. This key bypasses the Firestore rules: treat it like a password and rotate it if it leaks.
06Run the API locally (optional)
cd firebase/functions
npm ci
npm run dev:api # http://localhost:8787, in-memory store, sample token NOVA on Base Sepolia
npm run serve # build + emulators: auth 9099, firestore 8080, functions 5001 (needs Java 21+)
On Windows PowerShell set keys with $env:ZEROEX_KEY="..."; npm run dev:api. The app does not allow clear-text HTTP, so for tests on a phone use the deployed HTTPS function.
07Limits and costs
- 0x: set the console budgets (calls per minute, per IP) below your 0x plan's limit.
- CoinGecko: about 5 calls per minute are safe without a key. Prices are cached (default 120 seconds) and served stale if CoinGecko fails.
- AI: capped per day, default 200 calls.
- Firestore reads: config and content are read once a minute per function instance.