{
  "id": 209591,
  "title": "How I Modeled US Lottery Tax Withholding for 21 Countries Without a Backend",
  "url": "https://urgent.news/2026/08/06/how-i-modeled-us-lottery-tax-withholding-for-21-countries-without-a",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-06T07:03:41.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/autumnbuilds/how-i-modeled-us-lottery-tax-withholding-for-21-countries-without-a-backend-4m9"
  },
  "original_language": "en",
  "account": "Every time a US Powerball or Mega Millions jackpot reaches record-breaking heights, the advertised amount is deceptive. This figure represents the pre-tax annuity, paid out over 29 years. However, for non-US residents, determining the actual amount received is challenging. I created ChamTax to address this issue directly. The main engineering challenge was modeling the cross-border tax logic. Winning a US lottery involves at least two distinct tax jurisdictions: US non-resident withholding under IRC §871(a), which imposes a flat 30% at the source before the money leaves the country; and home-country taxation, which varies significantly across countries. Most of these interactions involve a foreign tax credit (FTC), where the US withholding is credited against the home country's tax owed, up to the smaller amount. However, if a country lacks an active tax treaty with the US, the two taxes add up in full. Building ChamTax without a backend required a client-side only approach, with all 21 country tax models and 50 US state rates stored as plain JavaScript objects within the browser. This design decision eliminated infrastructure costs and reduced the attack surface. For most countries, the tax model follows a simple pattern: calculate US withholding, apply home country tax, apply foreign tax credit, and subtract the remaining tax from the original amount. This resulted in a flat-country function that requires only a currency-invariant percentage and a configuration of { rate, ftcAvailable } for each country. Korea was the only country requiring real-money math, as it taxes foreign lottery winnings using a progressive bracket system with fixed KRW thresholds. This branch converts the USD payout to KRW, applies the 8-tier progressive tax table, and then converts the result back. One aspect that couldn't be verified was the tax laws of several countries, such as Thailand, Sri Lanka, Cambodia, Mongolia, Laos, and Pakistan. These countries lack a clear statutory rule for taxing foreign lottery winnings, so the calculator provides an explicit note describing the approximation used. The calculator utilizes 26 languages, with some languages (Uzbek, Khmer, Sinhala, Kyrgyz) having no native speaker for translation checks. To improve translation quality, a second AI pass was employed, specifically designed to flag low-confidence lines. This approach allowed for actionable feedback on uncertain translations, which is crucial as incorrect tax calculations can have significant financial consequences.",
  "summary": "Every time a US Powerball or Mega Millions jackpot balloons enough to hit global headlines, the advertised number is misleading in a very specific way: it represents the pre-tax annuity total, paid out over 29 years. For anyone living outside the US, finding a straightforward answer to \"okay, but what would actually land in my bank account, based on where I live?\" is surprisingly hard to come by.…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}