Deploy and self-host the open-source Spraay Shopify app (batch USDC payouts on Base) for a merchant’s store. Use when installing, deploying, troubleshooting the Spraay Shopify app — including Railway setup, env vars, Supabase/Postgres, 502 or OAuth fixes, or adding crypto payouts to Shopify admin.
--- name: spraay-shopify-selfhost description: Deploy and self-host the open-source Spraay Shopify app (batch USDC payouts on Base) for a merchant's store. Use this skill whenever a user wants to install, deploy, set up, self-host, or troubleshoot the Spraay Shopify app (github.com/plagtech/spraay-shopify) - including creating the custom app in the Shopify Dev Dashboard, deploying to Railway, configuring environment variables, setting up the Supabase/Postgres database, fixing 502 errors or OAuth redirect issues, or connecting a custom domain. Also use when a Shopify merchant asks how to add crypto payouts, USDC payments, or affiliate crypto payments to their store admin. --- # Self-Host the Spraay Shopify App Walk a merchant from zero to a working batch-USDC-payouts page inside their Shopify admin in ~15 minutes. The app is open source (MIT), non-custodial, and requests **zero Shopify scopes** — it cannot read or write any store data. **Repo:** https://github.com/plagtech/spraay-shopify ## Audited version | Field | Value | |---|---| | Commit | `3acf3b674a14500728c2607d8be937ad600887ad` | | Audit date | 2026-10-30 | | Batch contract | `0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC` (Base, verified) | | USDC | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` (Base) | > **Supply-chain note:** this skill deploys third-party code that receives Shopify secrets, database credentials, and wallet-signing authority. Always deploy from the **pinned commit above** (or a newer tagged release you have personally reviewed). Do not deploy from an unpinned `main` branch — the code could change after this audit. ## Stack at a glance - Remix + `@shopify/shopify-app-remix`, Vite, Polaris UI (fully embedded in admin) - wagmi v3 + viem v2 — MetaMask and Coinbase Smart Wallet - Base (chain 8453), USDC `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` - Batch contract `0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC` (verified; never substitute another address) - Supabase PostgreSQL via Prisma, isolated in a `shopify` schema - Railway hosting (Dockerfile, node:20-alpine) ## Prerequisites checklist Confirm the user has (or help them create) each of these before starting: 1. A Shopify store (dev store is fine for testing) 2. A free Shopify Partners account → https://dev.shopify.com 3. A Railway account (hobby tier is enough) 4. A Supabase project (free tier is enough) 5. A wallet holding USDC on Base (MetaMask or Coinbase Smart Wallet) ## Step 1 — Fork at the audited commit and deploy to Railway 1. Fork `plagtech/spraay-shopify` (Node 20+ required if running outside Docker: `>=20.19 <22 || >=22.12`). 2. **Pin to the audited commit** — in the fork, reset the default branch to the audited SHA before deploying: ```bash git clone https://github.com/<your-fork>/spraay-shopify.git cd spraay-shopify git reset --hard 3acf3b674a14500728c2607d8be937ad600887ad git push --force-with-lease ``` If the user prefers not to pin and instead deploys from the latest `main`, advise them to review the diff between the audited commit and HEAD (`git diff 3acf3b6..HEAD`) before deploying, since the code will have access to their Shopify secret and database credentials. 3. Deploy: Railway → New Project → Deploy from GitHub repo → select the fork. The repo ships a `railway.json` and Dockerfile, so the build is automatic. Alternatively, the **Deploy on Railway** button in the README works — the template pre-prompts for every required env var, with PORT defaulted to 3000. 4. Generate a public domain for the service (Settings → Networking). Note the URL, e.g. `your-app.up.railway.app`. The app will crash-loop until env vars are set — that's expected. Continue. ## Step 2 — Create the custom app in Shopify 1. Go to https://dev.shopify.com → Apps → **Create app** → **Custom distribution** (single merchant). Custom distribution is Shopify's intended path for merchant-specific tooling — no App Store review involved. 2. Set **App URL** to the Railway URL from Step 1 (https, no trailing slash). 3. Add all three OAuth redirect URLs (each prefixed by the App URL): - `https://your-domain/auth/callback` - `https://your-domain/auth/shopify/callback` - `https://your-domain/api/auth/callback` 4. Copy the **Client ID** and **Client Secret**. ## Step 3 — Environment variables Set these in Railway → service → Variables. The repo's `.env.example` documents each one; the authoritative reference: | Variable | Value | Notes | |---|---|---| | `SHOPIFY_API_KEY` | App Client ID | Public — ships in the browser bundle; safe to share | | `SHOPIFY_API_SECRET` | App Client Secret | Secret — signs webhook HMACs and OAuth. Never commit or paste into chat logs | | `SHOPIFY_APP_URL` | `https://your-app.up.railway.app` | Must exactly match the App URL in Shopify settings; no trailing slash | | `SCOPES` | *(empty)* | Intentional. The app never touches store data. Leave blank unless the fork adds Shopify API usage — then keep it in sync with `shopify.app.toml` | | `DATABASE_URL` | `postgresql://user:pass@host:6543/postgres?schema=shopify&pgbouncer=true` | Supabase **pooled** connection (transaction pooler, port 6543) — used at runtime | | `DIRECT_URL` | `postgresql://user:pass@host:5432/postgres?schema=shopify` | Supabase **direct** connection (port 5432) — used by `prisma migrate` | | `NODE_ENV` | `production` | | | `PORT` | `3000` | **Load-bearing.** See gotcha below | | `SHOP_CUSTOM_DOMAIN` | *(optional)* | Only if the dev store uses a custom domain | **The PORT=3000 gotcha (most common failure):** the Dockerfile's `EXPOSE 3000` sets Railway's domain target port to 3000. If `PORT` is unset, Railway injects `PORT=8080`, the app binds :8080, the proxy still routes to :3000, and **every route returns 502**. If the user reports 502s on all routes, check this first. **Database notes:** keep `?schema=shopify` on **both** URLs so the app's tables stay isolated from anything else in the Supabase project. Both URLs point at the same database — only the port and pooling differ. **Credential hygiene:** start with a dedicated Supabase database role limited to the `shopify` schema rather than the project-level `postgres` superuser. Rotate the Shopify client secret and database credentials immediately if you ever deploy an unreviewed revision of the app. After saving variables, redeploy. Migrations run automatically on boot (`prisma generate && prisma migrate deploy`, then `remix-serve`). A clean boot — migrate succeeds and `remix-serve` prints its listen URL — means Steps 1–3 are done. **Diagnostic tip:** a 502 while Railway shows the deployment "Online" is a port/proxy mismatch, not a crash. If the logs show a successful migrate and a listening server, fix `PORT`, don't debug the app. ## Step 4 — Install and test 1. From the Dev Dashboard, install the app on the store. Complete the OAuth prompt. 2. Open the app from the Shopify admin sidebar — the Polaris UI should render embedded. 3. **Start small:** run a test payout with 1–2 recipients and negligible amounts before processing real payroll. Header row is optional (first two columns are assumed address, amount); optional extra columns `name`, `email`, `memo` are supported, and the payout screen has a **Download CSV template** link and **Load sample data** button. Example: ```csv wallet_address,amount 0xYourOtherWallet...,1.00 ``` 4. Review screen shows recipients, total, and the 0.3% protocol fee → connect wallet → approve USDC → execute → confirm the BaseScan link resolves. ## Optional — local development For hacking on the app itself (not needed for a production deploy): `npm install && npm run dev`. The Shopify CLI creates a tunnel and injects `SHOPIFY_API_KEY`, `SHOPIFY_API_SECRET`, and `SHOPIFY_APP_URL`, so local `.env` only needs `DATABASE_URL` and `DIRECT_URL`. ## Optional — custom domain Point a subdomain (e.g. `payouts.yourstore.com`) at the Railway service via CNAME, wait for the SSL cert to issue, then update `SHOPIFY_APP_URL` **and** the App URL + redirect URLs in Shopify settings to match. All three must agree or OAuth breaks. ## Troubleshooting | Symptom | Likely cause | Fix | |---|---|---| | 502 on every route | Railway injected PORT=8080 | Pin `PORT=3000` | | OAuth redirect error / "invalid redirect_uri" | App URL mismatch | `SHOPIFY_APP_URL`, Shopify App URL, and redirect URL prefixes must be identical (scheme, host, no trailing slash) | | Prisma migrate fails | Using pooled URL for migrations | Migrations need `DIRECT_URL` (port 5432); runtime uses `DATABASE_URL` (port 6543) | | App loads outside admin but not embedded | Wrong App URL or missing HTTPS | Embedded apps require the exact HTTPS App URL configured in Shopify | | Wallet won't connect | Wrong network | The app targets Base (8453); switch network in the wallet | ## Security posture (tell the user) - **Zero scopes:** the app requests no Shopify permissions — it structurally cannot access orders, customers, or products. - **Non-custodial:** USDC moves only when the merchant's own wallet signs, in their browser. The server never holds keys or funds. - **Self-hosted:** credentials, database, and infrastructure belong to the merchant. - **Pinned source:** always deploy from the audited commit (`3acf3b6`) or a tagged release you have reviewed. The deployed app receives your Shopify secret and database credentials — deploying unreviewed code is a supply-chain risk. - The 0.3% protocol fee is itemized on the review screen and collected on-chain by the batch contract. It is contract-enforced on Base, not app code — self-hosting or forking does not remove it, and there is no subscription or plan. - Security issues → report privately to support@spraay.app, not a public issue. ## Related - Running payouts after deployment → `shopify-batch-payouts` skill - Protocol docs → https://docs.spraay.app
don't have the plugin yet? install it then click "run inline in claude" again.
get a merchant from zero to a working batch-USDC-payouts page inside their Shopify admin in about 15 minutes. the spraay shopify app is open source (MIT), non-custodial, and requests zero Shopify scopes , it structurally cannot read or write any store data. use this skill when a merchant wants to install, deploy, set up, self-host, or troubleshoot the app, including creating the custom app in Shopify's developer dashboard, deploying to Railway, configuring environment variables, setting up the Supabase/Postgres database, fixing 502 errors or OAuth redirect issues, connecting a custom domain, or adding crypto payouts to their store admin.
repo: https://github.com/plagtech/spraay-shopify
before starting, confirm the user has (or help create) each of these:
external connections and setup:
shopify schema to isolate tables.3acf3b674a14500728c2607d8be937ad600887ad (committed 2026-10-30, verified batch contract 0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC on Base).audited build:
| field | value |
|---|---|
| commit | 3acf3b674a14500728c2607d8be937ad600887ad |
| audit date | 2026-10-30 |
| batch contract | 0x1646452F98E36A3c9Cfc3eDD8868221E207B5eEC (Base, verified) |
| USDC address | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (Base) |
supply-chain note: this skill deploys third-party code that receives Shopify secrets, database credentials, and wallet-signing authority. always deploy from the pinned commit above (or a newer tagged release you have personally reviewed). do not deploy from an unpinned main branch , the code could change after this audit. if the fork's main branch has diverged, review the diff (git diff 3acf3b6..HEAD) before deploying.
inputs: GitHub account, Railway account, read access to https://github.com/plagtech/spraay-shopify
process:
plagtech/spraay-shopify on GitHub.git clone https://github.com/<your-fork>/spraay-shopify.gitcd spraay-shopifygit reset --hard 3acf3b674a14500728c2607d8be937ad600887adgit push --force-with-leasemain branch without pinning, instruct them to review the diff (git diff 3acf3b6..HEAD) first and sign off on any code changes before proceeding. document this decision in a commit message or ticket for audit trail.railway.json and Dockerfile, so the build is automatic. alternatively, use the Deploy on Railway button in the README, which pre-fills env var prompts with PORT defaulted to 3000.your-app.up.railway.app. do not worry if the deployment crashes or logs show "Waiting for env vars" , this is expected until environment variables are set in step 3.outputs: a Railway project with a public domain URL (HTTPS, no trailing slash); deployment status shows "Online" or "Building" but crashes are normal until env vars are applied.
inputs: Shopify Partners account, Shopify store (dev or prod), Railway URL from step 1
process:
https://your-app.up.railway.app.https://your-domain/auth/callbackhttps://your-domain/auth/shopify/callbackhttps://your-domain/api/auth/callbackoutputs: a custom app in Shopify with Client ID, Client Secret, and three registered OAuth redirect URLs.
inputs: Railway project, Supabase connection strings, Shopify Client ID and Secret, Railway domain URL
process:
| variable | value | notes |
|---|---|---|
SHOPIFY_API_KEY |
paste Client ID | public, safe to share, ships in browser bundle |
SHOPIFY_API_SECRET |
paste Client Secret | secret, signs webhook HMACs and OAuth, never commit or expose |
SHOPIFY_APP_URL |
https://your-app.up.railway.app |
must match App URL in Shopify settings exactly (scheme, host, no trailing slash) |
SCOPES |
leave blank | intentional , app requests zero Shopify permissions; only fill if fork adds API usage, then sync with shopify.app.toml |
DATABASE_URL |
Supabase pooled connection (port 6543) | example: postgresql://user:pass@db.supabase.co:6543/postgres?schema=shopify&pgbouncer=true |
DIRECT_URL |
Supabase direct connection (port 5432) | example: postgresql://user:pass@db.supabase.co:5432/postgres?schema=shopify |
NODE_ENV |
production |
|
PORT |
3000 |
load-bearing: must match Dockerfile EXPOSE 3000 |
SHOP_CUSTOM_DOMAIN |
optional custom domain | only if the dev store is configured with a custom domain |
prisma generate && prisma migrate deploy) followed by remix-serve printing its listen URL. if migrations succeed and the app is listening on :3000, steps 1, 3 are complete.outputs: all env vars set in Railway; service redeploys and shows successful migration + app listening on :3000 in logs.
critical gotcha , PORT=3000: the Dockerfile's EXPOSE 3000 sets Railway's domain target port to 3000. if PORT is unset or set to 8080, Railway injects PORT=8080, the app binds to :8080, but the proxy still routes incoming traffic to :3000, resulting in 502 errors on every route. if a user reports 502s immediately after deployment, check this first , it is a proxy configuration issue, not an app crash.
database isolation: both DATABASE_URL and DIRECT_URL must include ?schema=shopify so the app's tables stay isolated from any other data in the Supabase project. both URLs point at the same database server; only the connection pooling and port differ. migrations (which need direct connections) use DIRECT_URL; runtime app queries use DATABASE_URL.
credential hygiene: (optional best practice) create a Supabase database role limited to the shopify schema instead of using the project-level postgres superuser. rotate the Shopify client secret and database credentials immediately if you ever deploy an unreviewed revision of the app to production.
inputs: Railway service online and listening, Shopify app created and registered, USDC on Base in merchant's wallet
process:
wallet_address (required) and amount (required); optional columns are name, email, memo. example:wallet_address,amount
0xYourOtherWallet...,0.01
the payout screen has a Download CSV template link and Load sample data button for reference.outputs: test payout executed on Base, visible on BaseScan; no errors in app logs.
inputs: Node.js, npm, Supabase credentials, Railway service or local .env file
process:
git clone https://github.com/<your-fork>/spraay-shopify.git && cd spraay-shopify.npm install && npm run dev. the Shopify CLI creates a tunnel and auto-injects SHOPIFY_API_KEY, SHOPIFY_API_SECRET, and SHOPIFY_APP_URL..env.local (or .env.development) with DATABASE_URL and DIRECT_URL pointing to your Supabase project.http://localhost:3000 (or a Shopify-assigned tunnel URL) and connects to your test Shopify store.outputs: local dev server listening; app embedded in test store admin.
inputs: a subdomain (e.g. payouts.yourstore.com), DNS access, custom domain not already in use by another Railway service
process:
payouts.yourstore.com).cname.railway.app). add a CNAME record in your DNS provider pointing the subdomain to the target.SHOPIFY_APP_URL in Railway env vars to the new domain with HTTPS, e.g. https://payouts.yourstore.com.outputs: custom domain resolves to the Railway service over HTTPS; OAuth redirects work; app loads embedded in admin.
if the user has pinned the commit and deployed without review: proceed normally to step 2. the audited commit is safe to deploy.
if the user wants to deploy from the latest main branch instead of pinning: instruct them to run git diff 3acf3b6..HEAD and review all code changes. ask them to sign off on the diff (ideally in writing, e.g. a ticket or commit message) before deploying to production. warn them that the app receives Shopify secrets and database credentials, so deploying unreviewed code is a supply-chain risk. if they proceed, note the decision and the review date for the audit trail.
if the user reports 502 errors on all routes after deployment: first check if Railway shows the service as "Online". if so, this is a port/proxy mismatch, not an app crash. verify that PORT=3000 is set in env vars and redeploy. if the Railway logs show a successful migration and the app is listening on :3000, the issue is definitely the PORT mismatch. do not spend time debugging app code.
if the user reports "invalid redirect_uri" during OAuth: the App URL, SHOPIFY_APP_URL, or one of the redirect URL prefixes does not match exactly. have them verify all three against the Shopify Dev Dashboard entry: scheme (https), host, no trailing slash. if a custom domain is used, all three must use the custom domain, not the Railway domain. update any mismatches, redeploy, and retry.
if Prisma migrate fails: check the error log. if it says "ERROR: FATAL: remaining connection slots are reserved for non-replication superuser connections" or mentions a pooled connection, the user is pointing DIRECT_URL at the pooled connection (port 6543). migrations must use the direct connection (port 5432). swap DATABASE_URL and DIRECT_URL if they are reversed, or regenerate the correct connection strings from Supabase.
if the app loads outside the admin but not embedded inside it: the App URL in Shopify Dev Dashboard may be incorrect (e.g. http instead of https, or a mismatched domain). embedded apps require the exact HTTPS domain configured in Shopify. update SHOPIFY_APP_URL to match, ensure it is HTTPS, and reinstall the app on the store.
if the merchant's wallet will not connect or shows "wrong network": the app targets Base mainnet (chain ID 8453). instruct the user to switch their wallet (MetaMask or Coinbase Smart Wallet) to the Base network before attempting to connect.
if the user wants to deploy with a custom Shopify role instead of the postgres superuser: create a Supabase database role with permission to the shopify schema only. update DATABASE_URL and DIRECT_URL to use the new role credentials. this is optional but recommended for production security.
if the user wants to add custom Shopify API scopes (e.g. because they forked and added order reading): update the SCOPES env var to match the scopes declared in shopify.app.toml in the fork, and register those scopes in the Shopify app configuration. redeploy and reinstall.
if the user reports that the app is live but they want to troubleshoot a specific payout failure: defer to the shopify-batch-payouts skill for runtime debugging after deployment is complete.
a successful deployment delivers:
your-app.up.railway.app) that responds to requests without 502 errors.the user knows the deployment worked when:
security posture (tell the user):