<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: StarGate</title>
    <description>The latest articles on DEV Community by StarGate (@stargatezone).</description>
    <link>https://dev.to/stargatezone</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4202714%2F91c356f3-fe98-4025-a521-e2cd44be1583.png</url>
      <title>DEV Community: StarGate</title>
      <link>https://dev.to/stargatezone</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stargatezone"/>
    <language>en</language>
    <item>
      <title>Telegram Stars refunds and the 21-day window: what a bot that pays out for Stars must handle</title>
      <dc:creator>StarGate</dc:creator>
      <pubDate>Sat, 24 Oct 2026 11:50:11 +0000</pubDate>
      <link>https://dev.to/stargatezone/telegram-stars-refunds-and-the-21-day-window-what-a-bot-that-pays-out-for-stars-must-handle-3jh7</link>
      <guid>https://dev.to/stargatezone/telegram-stars-refunds-and-the-21-day-window-what-a-bot-that-pays-out-for-stars-must-handle-3jh7</guid>
      <description>&lt;p&gt;If your bot sells something that cannot be taken back (crypto, a gift card, a payout of any kind) for Telegram Stars, a refund or chargeback can leave you with neither the Stars nor the goods. This post collects what the Bot API and Telegram's terms actually say about refunds, and the pattern we use in a production bot: hold the payout through the refund window, detect refunds by polling &lt;code&gt;getStarTransactions&lt;/code&gt;, and let users post collateral to skip the hold.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Telegram says
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Stars are not available at once.&lt;/strong&gt; &lt;a href="https://telegram.org/tos/bot-developers" rel="noopener noreferrer"&gt;Bot Platform Developer Terms&lt;/a&gt;, section 6.2.4:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For technical reasons, Stars in your balance may not become available for advertising credits or rewards for up to 21 days after their receipt.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Chargebacks hit the bot's balance.&lt;/strong&gt; From the &lt;a href="https://core.telegram.org/bots/api" rel="noopener noreferrer"&gt;Bot API&lt;/a&gt; description of &lt;code&gt;StarTransaction&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that if the buyer initiates a chargeback with the payment provider from whom they acquired Stars (e.g., Apple, Google) following this transaction, the refunded Stars will be deducted from the bot's balance. This is outside of Telegram's control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The developer terms add that the seller "will be responsible for the funds returned" and that Telegram "expressly discourages the real-time sale of digital products" that cannot be reclaimed after a successful dispute or chargeback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You must handle disputes.&lt;/strong&gt; &lt;a href="https://core.telegram.org/bots/payments-stars" rel="noopener noreferrer"&gt;Payments in Telegram Stars&lt;/a&gt; requires bots to answer &lt;code&gt;/paysupport&lt;/code&gt; and to be "prepared to correctly process disputes and chargebacks". A bot refunds a payment itself with &lt;code&gt;refundStarPayment(user_id, telegram_payment_charge_id)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;None of these pages gives a deadline for chargebacks. The 21 days is the availability delay, and it is the window most services use for their own hold.&lt;/p&gt;

&lt;h2&gt;
  
  
  The attack
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Buy Stars through the App Store or Google Play.&lt;/li&gt;
&lt;li&gt;Pay your bot's invoice; the bot sends crypto immediately.&lt;/li&gt;
&lt;li&gt;File a chargeback with the store. The Stars are deducted from the bot's balance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The crypto is gone for good. This is not theoretical: it happened to us before we added a hold.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 1: hold the payout through the window
&lt;/h2&gt;

&lt;p&gt;On &lt;code&gt;successful_payment&lt;/code&gt;, store &lt;code&gt;telegram_payment_charge_id&lt;/code&gt; together with your order. If the order is above a risk threshold, give it a &lt;code&gt;hold_until = paid_at + 21 days&lt;/code&gt; and pay out from a scheduled job once that time has passed. Show the user the exact release date; a hold without a date looks like a scam.&lt;/p&gt;

&lt;p&gt;Keep the threshold and the per-user risk rules on the server. If the quote endpoint reveals exactly which users or amounts are held, it tells an attacker how to stay just under the line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 2: detect refunds by polling &lt;code&gt;getStarTransactions&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;There is no webhook for a chargeback. Refunds show up in the bot's transaction list instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;getStarTransactions(offset, limit)&lt;/code&gt; returns transactions "in chronological order", up to 100 per call. Keep the offset in persistent storage and walk forward from it.&lt;/li&gt;
&lt;li&gt;A refund is an &lt;strong&gt;outgoing&lt;/strong&gt; transaction: &lt;code&gt;receiver&lt;/code&gt; is set (the docs name "a user for a purchase refund" as an example), with &lt;code&gt;receiver.type = "user"&lt;/code&gt; and &lt;code&gt;receiver.transaction_type = "invoice_payment"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;receiver.invoice_payload&lt;/code&gt; is optional, so do not rely on it alone.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;StarTransaction.id&lt;/code&gt; "coincides with the identifier of the original transaction for refund transactions" and, for incoming payments, "coincides with SuccessfulPayment.telegram_payment_charge_id". That gives a reliable link from a refund back to your order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Match by payload first and fall back to the charge id. If neither gives exactly one order, do not guess: a fuzzy match can punish the wrong user. On a confirmed match, mark the order forfeited, record the debt on the account and block it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 3: collateral instead of waiting
&lt;/h2&gt;

&lt;p&gt;A hold protects you, but a 21-day wait is bad for users who sell regularly. The way around it is collateral: the user deposits crypto, and while its free amount covers the refund risk of a swap, that swap pays out at once.&lt;/p&gt;

&lt;p&gt;Rules that kept it safe for us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reserve, then pay.&lt;/strong&gt; Reserve collateral for a swap after the payment is confirmed and before the payout, under a lock (we use Symfony Lock), so two parallel payouts cannot both spend the same collateral.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freeze per swap.&lt;/strong&gt; Each reserved portion has its own unlock date, the end of that swap's refund window. One deposit can have several.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forfeit on refund.&lt;/strong&gt; The refund detector from pattern 2 forfeits exactly the collateral reserved for the refunded swap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cooldown after withdrawal.&lt;/strong&gt; A short cooldown after a collateral withdrawal stops a deposit, swap, withdraw, refund loop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cover held swaps first.&lt;/strong&gt; When new collateral arrives, release swaps that are already waiting before new ones use it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] &lt;code&gt;telegram_payment_charge_id&lt;/code&gt; stored with every order&lt;/li&gt;
&lt;li&gt;[ ] payouts above the threshold held, with the release date shown to the user&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;getStarTransactions&lt;/code&gt; polled from a persisted offset&lt;/li&gt;
&lt;li&gt;[ ] refunds matched by payload, then by charge id, with no fuzzy matching&lt;/li&gt;
&lt;li&gt;[ ] refund leads to forfeit, debt and block&lt;/li&gt;
&lt;li&gt;[ ] collateral reserved under a lock and frozen per swap&lt;/li&gt;
&lt;li&gt;[ ] &lt;code&gt;/paysupport&lt;/code&gt; answered&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Disclosure: we build &lt;a href="https://stargate.zone/about" rel="noopener noreferrer"&gt;StarGate&lt;/a&gt;, a Telegram bot and web app that swaps Stars for GRAM, USDT, ETH and BTC, and the patterns above come from running it. This post was drafted by an AI assistant from our code and notes, and its quotes were checked against the Telegram documentation linked above.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>telegram</category>
      <category>bots</category>
      <category>payments</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to sell Telegram Stars for crypto</title>
      <dc:creator>StarGate</dc:creator>
      <pubDate>Fri, 23 Oct 2026 13:25:23 +0000</pubDate>
      <link>https://dev.to/stargatezone/how-to-sell-telegram-stars-for-crypto-59b7</link>
      <guid>https://dev.to/stargatezone/how-to-sell-telegram-stars-for-crypto-59b7</guid>
      <description>&lt;p&gt;&lt;em&gt;Turn Telegram Stars into GRAM, USDT, ETH or BTC: the official route, the bot route, and the 21-day hold.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer.&lt;/strong&gt; You can sell Telegram Stars for crypto in two ways. If you are a channel or bot owner, Telegram's official Fragment platform withdraws earned Stars to a GRAM wallet once you have at least 1,000 Stars and 21 days have passed. Anyone else can pay Stars to a swap bot such as StarGate, which pays out GRAM, USDT, ETH or BTC to a wallet you choose, from 25 Stars.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can you sell Telegram Stars at all?
&lt;/h2&gt;

&lt;p&gt;Telegram Stars are Telegram's built-in currency. You buy them in the Telegram app or through official Telegram bots and spend them in bots and mini apps.&lt;/p&gt;

&lt;p&gt;There is no button in Telegram that turns purchased Stars back into money. What you can do is spend Stars in a bot that pays you crypto in return. That is how Stars exchange bots work: you pay a normal Telegram invoice in Stars, and the bot sends crypto to your wallet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 1: Fragment (channel and bot owners)
&lt;/h2&gt;

&lt;p&gt;Fragment is Telegram's own platform. It is the route for Stars you &lt;strong&gt;earned&lt;/strong&gt; as a creator: paid posts, subscriptions, bot sales.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only Stars received by your channel or bot can be withdrawn, not Stars you bought.&lt;/li&gt;
&lt;li&gt;The minimum is 1,000 Stars.&lt;/li&gt;
&lt;li&gt;Earned Stars become withdrawable 21 days after you receive them.&lt;/li&gt;
&lt;li&gt;The payout arrives in GRAM to the wallet you connect on Fragment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Option 2: a Stars swap bot (anyone with Stars)
&lt;/h2&gt;

&lt;p&gt;A swap bot accepts Stars as payment and sends crypto. With StarGate it works like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;a href="https://t.me/stargateton_bot?start=devto_sell_stars" rel="noopener noreferrer"&gt;@stargateton_bot&lt;/a&gt; or &lt;a href="https://stargate.zone/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sell-stars" rel="noopener noreferrer"&gt;stargate.zone&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;Stars&lt;/strong&gt; as what you send and the coin you want: GRAM, USDT (Jetton or ERC-20), ETH or BTC.&lt;/li&gt;
&lt;li&gt;Paste your wallet address. No wallet yet? A free wallet takes a minute to create.&lt;/li&gt;
&lt;li&gt;The app shows the exact amount you will receive before you pay. Confirm the Telegram invoice with one tap.&lt;/li&gt;
&lt;li&gt;Follow the order screen. The crypto goes to the address you gave.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One swap takes from 25 to 10,000 Stars. The rate follows the market and already includes the service fee: the amount shown before you confirm is the amount you get.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why some Stars payouts wait 21 days
&lt;/h2&gt;

&lt;p&gt;Telegram lets Stars buyers ask for a refund within 21 days. A fraudster could pay Stars, take the crypto and then refund the Stars. To protect against that, larger Stars swaps are paid out after the refund window closes. The order shows the exact release date, and the crypto arrives by itself after it.&lt;/p&gt;

&lt;p&gt;You can skip the wait with &lt;strong&gt;collateral&lt;/strong&gt;: a refundable deposit in crypto. While your collateral covers the swap, the payout is sent at once. Details: &lt;a href="https://stargate.zone/docs/hold-and-stake?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sell-stars" rel="noopener noreferrer"&gt;The 21-day hold and collateral&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fragment or a bot: side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Fragment&lt;/th&gt;
&lt;th&gt;Swap bot (StarGate)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Who can use it&lt;/td&gt;
&lt;td&gt;channel and bot owners&lt;/td&gt;
&lt;td&gt;anyone with Stars&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which Stars&lt;/td&gt;
&lt;td&gt;earned Stars&lt;/td&gt;
&lt;td&gt;any Stars you can spend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minimum&lt;/td&gt;
&lt;td&gt;1,000 Stars&lt;/td&gt;
&lt;td&gt;25 Stars&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;What you get&lt;/td&gt;
&lt;td&gt;GRAM&lt;/td&gt;
&lt;td&gt;GRAM, USDT, ETH or BTC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;When&lt;/td&gt;
&lt;td&gt;21 days after the Stars were earned&lt;/td&gt;
&lt;td&gt;at once with collateral, otherwise after the refund window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price&lt;/td&gt;
&lt;td&gt;Telegram's rate&lt;/td&gt;
&lt;td&gt;market rate, shown before you pay&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How much will I get for 1,000 Stars?
&lt;/h2&gt;

&lt;p&gt;It depends on the rate at the moment you swap: it follows the market and changes during the day. Do not trust a fixed number from an article, this one included. Open the swap form and enter the amount: it shows exactly what will arrive before you pay anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to avoid scams when selling Stars
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A real service never writes to you first. "Support" that messages you first is fake.&lt;/li&gt;
&lt;li&gt;Nobody honest asks for your seed phrase (secret words).&lt;/li&gt;
&lt;li&gt;Payouts go only to the address you entered. Nobody needs a "fee" from you to unlock a payout.&lt;/li&gt;
&lt;li&gt;Check the bot's username letter by letter. StarGate's official bot is &lt;code&gt;@stargateton_bot&lt;/code&gt;, support is &lt;code&gt;t.me/stargate_bridge&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Be careful with bots that "buy NFT gifts" for more than they are worth: many are wallet drainers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Can I sell Stars I bought, not earned?&lt;/strong&gt;&lt;br&gt;
Not through Fragment. Through a swap bot, yes: you spend them on the bot's invoice like on any other purchase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which coin should I choose?&lt;/strong&gt;&lt;br&gt;
GRAM if you stay in the Telegram ecosystem, USDT if you want a stable value, ETH or BTC if you already hold them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if I paid and the order closed?&lt;/strong&gt;&lt;br&gt;
Pay the invoice before the order timer runs out: an unpaid order closes by itself and nothing is charged. If you paid an invoice after the order had closed, write to support with the order number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can someone else pay for my order?&lt;/strong&gt;&lt;br&gt;
Yes, a friend can pay the invoice. The order and its payout stay yours. If the Stars payment is later refunded through Telegram, the order is forfeited.&lt;/p&gt;

&lt;h2&gt;
  
  
  Official links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Bot: &lt;a href="https://t.me/stargateton_bot?start=devto_sell_stars" rel="noopener noreferrer"&gt;t.me/stargateton_bot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Website: &lt;a href="https://stargate.zone/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sell-stars" rel="noopener noreferrer"&gt;stargate.zone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Support chat: &lt;a href="https://t.me/stargate_bridge" rel="noopener noreferrer"&gt;t.me/stargate_bridge&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Email: &lt;a href="mailto:hello@stargate.zone"&gt;hello@stargate.zone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;How a Stars swap works, step by step: &lt;a href="https://stargate.zone/docs/stars-swaps?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sell-stars" rel="noopener noreferrer"&gt;stargate.zone/docs/stars-swaps&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Written by the StarGate team. StarGate is a wallet, swap and bridge service for crypto and Telegram Stars. About us and contacts: &lt;a href="https://stargate.zone/about?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=sell-stars" rel="noopener noreferrer"&gt;stargate.zone/about&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@stargatezone/how-to-sell-telegram-stars-for-crypto-54aa961db402" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>telegram</category>
      <category>cryptocurrency</category>
      <category>blockchain</category>
      <category>web3</category>
    </item>
  </channel>
</rss>
