This guide covers how to deploy the ChainMatrix application.
- Frontend: Vercel
- Backend: Vercel (Recommended) or Render
Since the backend includes a vercel.json configuration, you can deploy both the frontend and backend to Vercel. This is often the easiest path.
- Push your code to a GitHub repository.
- Go to Vercel Dashboard and click Add New > Project.
- Import your GitHub repository.
- Framework Preset: Select Other.
- Root Directory: Click "Edit" and select
backend. - Environment Variables: Add the following variables from your
.env:FLARE_RPCFTSO_ADDRESS(use0x3d893C53D9e8056135C26C8c638B76C8b60Df726)SUPABASE_URLSUPABASE_KEYSPONSOR_WALLET_PRIVATE_KEY(if using smart accounts)
- Click Deploy.
- Note the URL: You will get a URL like
https://your-backend.vercel.app.
- Go to Vercel Dashboard and click Add New > Project.
- Import the SAME GitHub repository.
- Framework Preset: Vercel should auto-detect Vite.
- Root Directory: Click "Edit" and select
frontend. - Environment Variables:
VITE_API_URL: Set this to your Backend URL from the previous step (e.g.,https://your-backend.vercel.app).VITE_CLERK_PUBLISHABLE_KEY: Your Clerk Key.VITE_PRIVY_APP_ID: Your Privy App ID.VITE_MAPBOX_API: Your Mapbox token.- Other
VITE_variables from your.env.
- Click Deploy.
If you prefer Render for the backend (e.g., for persistent background jobs), follow these steps.
- Push your code to GitHub.
- Go to Render Dashboard and click New > Web Service.
- Connect your GitHub repository.
- Root Directory:
backend - Build Command:
npm install - Start Command:
node server.js - Environment Variables: Add all variables from your backend
.env. - Click Create Web Service.
- Note the URL: Copty the provided Render URL.
Follow the same steps as Option 1 (Frontend), but set VITE_API_URL to your Render Backend URL.
Ensure your backend allows requests from your frontend domain. In backend/server.js, you might need to update CORS if it's too restrictive, but app.use(cors()) usually allows all origins by default, which is fine for initial testing.
The backend currently connects to the Coston2 Testnet. Ensure your frontend wallet (MetaMask) is also connected to Coston2 if you are interacting with smart contracts there.
You do NOT host smart contracts like a website. Instead, you deploy them to the blockchain once. They then live there correctly forever.
Run the following command in your smart-contracts folder:
npx hardhat run scripts/deploy-flare-adapter.js --network costonThe deployment script will print the Contract Address. You must update this address in your project:
- Frontend: Update
VITE_FLARE_ADAPTER_ADDRESSinfrontend/.env. - Backend: Update
FLARE_ADAPTER_ADDRESSinbackend/.env.
Re-deploy your frontend and backend if you change these variables.
After deployment:
- Open your Frontend URL.
- Navigate to Live Charts.
- Verify that prices are loading (this confirms Frontend -> Backend communication).
If you see an error like ID: bom1::... when clicking confirm or entering amounts, it means your Frontend cannot find your Backend.
Cause: VITE_API_URL is missing or incorrect in your Vercel Frontend settings.
Fix:
- Go to your Vercel Project Settings -> Environment Variables.
- Add/Update
VITE_API_URL. - Value: Your Render Backend URL (e.g.,
https://chain-matrix-backend.onrender.com). - Important: You must Redeploy the frontend for this change to take effect (go to Deployments -> Redeploy).