CryptoWallet docs
v3.1.0
Get help
● Set up · About 1 hour

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.

Blaze planCloud Functions nodejs24

011. Create the project

  1. New projectOpen console.firebase.google.com, Add project, give it a name. Note the project id.
  2. 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.
  3. AuthenticationBuild, Authentication, Get started, Sign-in method, enable Anonymous. The app signs in anonymously and nothing else.
  4. FirestoreBuild, Firestore Database, Create database in Native mode, pick a region close to your users.
  5. Cloud Messaging is on by default in a new project. It is used by push campaigns (Push).
  6. 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.
The App connection and RPC keys sections of the console
Keys are write-only fields: the console never shows them again

022. Deploy the functions and rules

Windows

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-central1 by default. To change it copy functions/.env.example to functions/.env and set FUNCTIONS_REGION (for example europe-west1) before deploying.
  • The api function 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.rules deny everything by default. A signed-in user may read only their own users/<uid> document and nothing is client-writable.
How to confirm success

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 in firestore.indexes.json and goes out with firestore: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:api earlier, run the full deploy once.
  • Alerts need push (FCM). An alert is delivered as a push notification. Add your google-services.json to 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/nft by 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.