A Reddit bot that replies with U.CASH Pay checkout links. Non-custodial: the bot never holds funds. It parses payment commands from comments, submissions, and private messages, and replies with a pay.u.cash checkout link the user can click to pay in crypto.
Redditors mention the bot and issue a command:
u/your_bot !pay 5 USD Coffee
u/your_bot !pay 0.001 BTC Tip jar
u/your_bot !pay 20
Command syntax:
!pay <amount> [currency] [title]
amount(required): numeric, supports decimals (e.g.5,0.001,19.99).currency(optional): a currency code, defaults toUSD(orUXCASH_DEFAULT_CURRENCY).title(optional): free text that becomes the checkout title.
The bot replies with a pay.u.cash checkout link built from the store Cloud Token and the parsed parameters.
- Mentions: comments and submissions anywhere on Reddit that mention the
bot's username (
u/your_bot). - Private messages (DMs): unread messages sent directly to the bot.
Each handled item is replied to once; handled Reddit item ids are kept in an in-process set to avoid duplicate replies within a run.
The bot supports two modes for producing the checkout link:
-
Client-side hosted link (default): builds a
GET https://pay.u.cash/embed.phpURL with query paramscloud,amount,currency,title,external_reference, andredirect. The store Cloud Token is publishable and safe to embed in a link the user opens in their browser. No server secret is required. -
Server-side tracked checkout (opt-in): when
UXCASH_TRACK_SERVER=1, the bot also callsPOST https://pay.u.cash/payment/ajax.phpwithfunction=create-transaction,amount,currency_code,cryptocurrency_code(empty),external_reference,title,redirect,cloud, andidempotent=1. This creates a tracked, idempotent checkout and the bot replies with the returned payment URL. Enable this when you want each checkout recorded server-side under a stableexternal_reference.
- Python 3.8+
- A Reddit account for the bot
- A Reddit "script" app (https://www.reddit.com/prefs/apps) to get a client id and secret
- A pay.u.cash store Cloud Token
-
Create a virtual environment and install dependencies:
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt -
Create a Reddit "script" app at https://www.reddit.com/prefs/apps:
- Name it whatever you like.
- Set the redirect URI to
http://localhost:8080. - Note the client id (under the app name) and client secret.
-
Copy
.env.exampleto.envand fill in your credentials:cp .env.example .env
Set
UXCASH_CLOUD_TOKENto your store Cloud Token from pay.u.cash. -
Run the bot:
python bot.py
All configuration is via environment variables (see .env.example):
| Variable | Required | Description |
|---|---|---|
REDDIT_CLIENT_ID |
yes | Reddit app client id |
REDDIT_CLIENT_SECRET |
yes | Reddit app client secret |
REDDIT_USERNAME |
yes | Bot Reddit username |
REDDIT_PASSWORD |
yes | Bot Reddit password |
REDDIT_USER_AGENT |
no | Descriptive user agent string |
UXCASH_CLOUD_TOKEN |
yes | Store Cloud Token from pay.u.cash (publishable) |
UXCASH_REDIRECT |
no | Redirect URL after payment |
UXCASH_TRACK_SERVER |
no | 1 to also create a server-side tracked checkout. Default 0 |
UXCASH_DEFAULT_CURRENCY |
no | Default currency when the command omits one. Default USD |
UXCASH_POLL_SECONDS |
no | Seconds between polls. Default 60 |
Once the bot is running and logged in, any user (including yourself for testing) can summon it. Example commands:
u/your_bot !pay 10 USD Server hosting
u/your_bot !pay 0.5
u/your_bot !pay 2.50 EUR Espresso
The bot replies with a markdown link to the pay.u.cash checkout.
- Sign up at pay.u.cash, then click the verification link in the email.
- Set receive addresses under Settings -> Addresses (raw address, ENS, Unstoppable Domains, or FIO).
- Create a store under Account -> Stores and copy its Store Cloud Token (use the store-level token, not the account-wide one).
- For fiat cards, connect your own Stripe under Settings -> Payment processors.
- Custody: This bot is non-custodial. It only constructs and posts pay.u.cash checkout links; funds go directly to the store's configured receive addresses.
- Recurring billing: pay.u.cash does not support automatic crypto recurring billing, so the bot only creates one-time checkout links per command.
- Reddit rate limits: Replies are subject to Reddit's rate limits and the
bot's account karma. The poll interval (
UXCASH_POLL_SECONDS) should be kept reasonable to avoid throttling. - Dedup scope: Handled item ids are tracked in memory for the lifetime of a
single process. Restarting the process re-reads from
skip_existing=Truestreams, so already-handled items won't be reprocessed after a restart.
- The store Cloud Token is publishable and intended for client-side use (it is safe in the browser and in a posted link). It is not a server secret.
- Reddit credentials are secrets. Keep
.envout of version control (it is gitignored). Never hard-code them. UXCASH_TRACK_SERVER=1makes outbound server requests to pay.u.cash with your Cloud Token; this is expected and safe.
MIT. See LICENSE.