DogeJS / Doge on X / Price it in DOGE

Price it in DOGE

Type anything with a price. Get a funny share image of what it costs in Dogecoin at the live rate.

Free, no account, nothing leaves your browser. For developers: the docs

The price page on a phone: A coffee, $4.50 typed in, preset buttons, and the card below.

What you get

Price it in DOGE, step by step

dogejs.com/x/price/app/
A price card: A coffee is 80 DOGE. Much affordable.

A card you can post

Type "A coffee, $4.50" and get an image that says what it costs in DOGE, with the rate and the time at the bottom.

  • Download it or copy it, then attach it to your post
  • The rate and the time are printed on the card
  • Made in your browser, nothing is uploaded
The Advanced box on a phone: the currency for prices without a sign and a field for your own DOGE rate.

Your rate or the live one

The live price is read by your browser. If you would rather use your own number, type it under Advanced and the card says it is yours.

  • Choose the currency for prices without a sign
  • Use the live rate or set one by hand
  • A card made at your own rate says so
  • Whole numbers inside, so the same price gives the same DOGE every time
The price page on a phone with a pizza at 18 euros typed in and the card below it.

Euros, pounds and big numbers

Type the sign in front of the price, like €18 or £8, or a size like 67 million. The card follows as you type.

  • US, Canadian and Australian dollars, euros and pounds
  • Tap an example like Coffee, Pizza or A rocket launch
  • Any text with a price works
An illustration of a post box with the price text and the card attached.

Attach it to your post

One button opens the X post box with the words filled in. Attach the card and press Post.

  • We never post for you
  • The text is short and ends with #Dogecoin
  • Works on phone and computer

How it works

  1. Type a thing and its price

    For example a coffee at $4.50.

  2. Get the card

    It shows the price in DOGE at the live rate.

  3. Post it on X

    Attach the image to the post we open for you.

Questions

Where does the price come from?

CoinGecko's public price endpoint, read by your browser. The card shows the rate and the time it was read.

What if the live price cannot be read?

The page says so. Type a rate under Advanced and the card shows it as your rate. Try again later for the live one.

Which currencies work?

US, Canadian and Australian dollars, euros and pounds.

Why integers?

So that 4.50 at 0.1825 always gives the same DOGE in every browser, with no rounding surprises.

Is the card a payment request?

No. It is a picture that says what something costs in Dogecoin. No money moves.

Is this made by X?

No. DogeJS is an independent project and is not affiliated with X Corp. The tools only open X's own post box with the text filled in; you press Post yourself.

Price it in DOGE

It works for real, right here. No sign-up.

For developers

Price cards for developers

How prices are read and converted with integers only, where the rate comes from, and how the card is drawn.

How it works

  1. parsePriceText reads the item and the price, in $, C$, A$, €, £ or a currency code, with 1,234.56 or 1.234,56 and k, million or billion.
  2. The rate is read from CoinGecko's public price endpoint by your browser, with no key, when the page opens. Under Advanced you can type your own rate. When it cannot be read, the page says so and you can type a rate under Advanced; a card made at your own rate says so.
  3. All money is integers: cents in, koinu out (1 DOGE = 100,000,000 koinu), rate as fiat per DOGE x 1e8, rounded half up. No floating point.
  4. The 1600x900 card is drawn on a canvas in the browser with the rate and time written small at the bottom; Download, Copy image, then Post on X and attach it.

How the card renderer works: card renderer.

Use it in your own code

The package is @dogejs/xkit. It is not on npm yet: install it from its repository tag, then import the helpers. They are plain functions with no DOM at module level, so they run in Node 20+, in browsers and in workers.

Shell
npm install github:DogeJS-Dev/doge-on-x#v0.2.0
JavaScript
import { tipLink, decodeLink, checkProof, draw, postIntentUrl } from '@dogejs/xkit';

Use the same maths for a price tag on your own site, a bot reply, or a menu board.

Code examples

Each example runs in Node against the built package; the output is recorded from that run and checked by npm run examples.

Price things in DOGE

Three prices at one rate, with the card's headline and tagline. File examples/price.mjs; run: node examples/price.mjs.

JavaScript
// "A coffee, $4.50" in DOGE, with integers only.
import { formatFiat, formatRate, headline, minorToKoinu, parsePriceText, pricePost, tagline } from '@dogejs/xkit';

const rate = 18_250_000n; // priceE8: $0.1825 per DOGE x 1e8 (the page fetches the live rate)
for (const text of ['A coffee, $4.50', 'New sneakers, 120 EUR', 'A rocket launch, $67 million']) {
  const p = parsePriceText(text);
  const koinu = minorToKoinu(p.minor, rate);
  console.log(formatFiat(p.minor, p.currency), '->', headline(p.item, koinu), tagline(koinu));
}
console.log(formatRate(rate, 'USD'));
const p = parsePriceText('A coffee, $4.50'), k = minorToKoinu(p.minor, rate);
console.log(pricePost(headline(p.item, k), tagline(k)));
Output
$4.50 -> A coffee is 25 DOGE. Much affordable.
€120 -> New sneakers are 658 DOGE. Such treat. Wow.
$67,000,000 -> A rocket launch is 367,123,288 DOGE. To the moon. Wow.
1 DOGE = $0.1825
A coffee is 25 DOGE. Much affordable. #Dogecoin

Prices written many ways

What the parser understands, in minor units, and what one cent is in koinu. File examples/price-formats.mjs; run: node examples/price-formats.mjs.

JavaScript
// Prices are read the way people write them, and stay integers: cents in, koinu out.
import { friendlyDoge, minorToKoinu, parsePriceText } from '@dogejs/xkit';

for (const t of ['$4.50', '4,50 €', '£1,234.56', 'Rent 1.234,56 EUR', 'A car, 48k', 'C$ 15', 'free']) {
  const p = parsePriceText(t);
  console.log(JSON.stringify(t).padEnd(22), p ? `${p.minor} ${p.currency} minor units, item "${p.item}"` : 'not a price');
}
// 1 cent at $0.1825 per DOGE, rounded half up to the koinu (1 DOGE = 100,000,000 koinu)
const k = minorToKoinu(1n, 18_250_000n);
console.log(k, 'koinu =', friendlyDoge(k), 'DOGE on the card');
Output
"$4.50"                450 USD minor units, item ""
"4,50 €"               450 EUR minor units, item ""
"£1,234.56"            123456 GBP minor units, item ""
"Rent 1.234,56 EUR"    123456 EUR minor units, item "Rent"
"A car, 48k"           4800000 USD minor units, item "A car"
"C$ 15"                1500 CAD minor units, item ""
"free"                 not a price
5479452n koinu = 0.05 DOGE on the card

The Post on X link

The text the page prefills, and the composer link. The person attaches the downloaded card. File examples/price-post.mjs; run: node examples/price-post.mjs.

JavaScript
// The "Post on X" button of the price page: text and link, no image (the person attaches the downloaded card).
import { headline, minorToKoinu, parsePriceText, postIntentUrl, pricePost, tagline } from '@dogejs/xkit';

const p = parsePriceText('A large pizza, $18');
const koinu = minorToKoinu(p.minor, 18_250_000n);
const text = pricePost(headline(p.item, koinu), tagline(koinu));
console.log(text);
console.log(postIntentUrl({ text, url: 'https://dogejs.com/x/price/' }));
Output
A large pizza is 99 DOGE. Much affordable. #Dogecoin
https://x.com/intent/post?text=A%20large%20pizza%20is%2099%20DOGE.%20Much%20affordable.%20%23Dogecoin&url=https%3A%2F%2Fdogejs.com%2Fx%2Fprice%2F

API reference

The exports this page uses. The full list is on the Doge on X developer page.

Prices src/price.ts

ExportReturnsWhat it does
parsePriceText(text, fallback?)PriceInput | null"A coffee, $4.50" to { item, currency, minor }. Understands $, C$, A$, €, £, codes, 1,234.56 and 1.234,56, k / million / billion.
parseAmount(num, suffix?)bigint | nullOne number in minor units (cents).
minorToKoinu(minor, priceE8)bigintFiat minor units to koinu at a rate of fiat per DOGE x 1e8, rounded half up. No floats.
friendlyDoge(koinu)string"0.25", "5.6", "56", "1,234", "1.2 billion".
headline(item, koinu), tagline(koinu)string"A coffee is 56 DOGE." and a fixed fun line by size.
formatFiat(minor, currency), formatRate(priceE8, currency)string"$4.50"; "1 DOGE = $0.1825".
PRESETS, SYMBOL, KOINU, MAX_MINOR, MAX_ITEM, isFiatThe six example prices, currency symbols, 100000000n, the largest price, the longest item name, a currency check.

Post composer src/intent.ts

ExportReturnsWhat it does
postIntentUrl({ text, url? })stringhttps://x.com/intent/post?text=...&url=.... Throws if it would not fit in 280 (X's count) or the url is not http(s).
followIntentUrl(handle)stringhttps://x.com/intent/follow?screen_name=...
xLength(text, urls?)numberLength as X counts it: most Latin characters 1, CJK and emoji 2, each link 23.
fitPost(text, hasUrl, limit?)stringCuts a text at a word so text plus link fits limit (default 240), ending with an ellipsis.
POST_LIMIT, URL_WEIGHT, OUR_LIMIT280, 23, 240X's limit, the weight of a link, the limit our texts keep to.

Page links and texts src/links.ts

ExportReturnsWhat it does
tipLink(record, base?)stringbase + /x/t/# + fragment; base defaults to https://dogejs.com.
proofLink(record, base?)stringbase + /x/proof/# + fragment.
bioLine(record, base?)stringTips in Dogecoin: dogejs.com/x/t/#..., always without the proof so it stays short.
pinnedPost(), proofPost(handle, address), pricePost(headline, line), wowPost(line), profilePost(), lockPost(commit, entries), winnersPost(winners, commit)stringThe texts the pages prefill in the composer; each stays under 240 with its link.
SITE, PAGES'https://dogejs.com', { hub, tip, tipPage, proof, price, wow, profile, giveaway }The site and the page paths.

Self-hosting

Everything is static files. The page scripts are built from DogeJS-Dev/doge-on-x; the HTML and CSS of the pages are in DogeJS-Dev/website under site/x/.

Shell
git clone https://github.com/DogeJS-Dev/doge-on-x
cd doge-on-x
npm install
npm run build      # dist/x-tip.js, x-t.js, x-proof.js, x-price.js, x-wow.js, x-profile.js, x-giveaway.js
npm test           # unit tests
npm run examples   # runs every example on this page and compares its output
  1. Copy site/x/ from the website repository (the product page of each tool is x/<tool>/, the tool itself x/<tool>/app/), with ui.css, apps.css, styles.css, site.js, pay.js (tip pages) and signin.js (proof page) from the site root, and the images the pages name.
  2. Put the built dist/x-*.js next to the pages as site/x/x-*.js.
  3. Serve the folder from any static host. Nothing else is needed: no database, no keys, no X API.

What changes on your own host: the pages write links for the host they are served from (so your tip links point to your copy), and proofs are signed for your host. A proof page accepts proofs signed for dogejs.com and for its own host, nothing else. To make another host the default for links built in code, pass it as the base argument of tipLink, proofLink and bioLine, and the hosts you accept as allowedHosts of checkProof.