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.
033. 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.
044. 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.
05Run 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.
06Limits 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.