Viction
  • Getting Started
  • General
    • Overview
    • Viction Blockchain
      • PoSV Consensus
      • Comparison
    • Staking
      • Staking Requirements
      • Staking Rewards
      • How to stake on Viction Wallet
    • Network Information
      • Viction Mainnet
      • Viction Testnet
    • Viction RPC API
  • Smart Contract Development
    • Solidity
      • A Simple Smart Contract
      • Solidity by Example
    • Standards & Specification
      • VRC25 Specification
      • VRC725 Specification
    • IDEs and Tools
      • Remix
      • Ethers.js
      • web3.js
      • thirdweb CLI
    • Deployment & Verification
      • Hardhat
      • Foundry
  • DApp Development
    • Integration
      • Exchange/Wallet integration
      • VRC25 Exchange/Wallet integration
      • Viction Staking Governance
      • VIC ZeroGas
      • VRRF
    • Data and analytics
    • Embedded Wallet (MPC)
    • Walkthrough: Build a Dapp on Viction
      • Setup Environment
      • Write the Smart Contract
      • Interacting with the Dapp in a browser
  • Masternode
    • Requirements
    • Run a Full Node
      • Binary
      • Create a Viction Masternode
      • Tmn
      • Docker
    • Apply Your Node
    • Slashing Mechanism
    • Chain Data Snapshots
    • Troubleshooting
  • Viction Wallet
    • User Guide
      • Authentication
      • How to create a new wallet
      • How to restore a wallet?
      • Wallet settings
      • Send & Receive Tokens
      • Add custom token
      • Manage Tokens
      • Send NFT
      • General settings
    • Developer Guide
    • Privacy Policy
    • Term and Services
  • Viction Bridge
    • Spacegate
    • Arken Bridge
    • Hyperlane
  • Viction Data Availability
    • Viction DA RPC API
    • DA Integration Use cases
      • Simple Guide for Integrating OP Stack Rollup with Viction DA Layer
  • How to
    • How to Connect to Viction Blockchain
      • Coin98 Super Wallet
      • Metamask
      • Ledger
    • How to troubleshoot when the node is up but couldn't begin to sync block
    • How to Vote for Viction Saigon Network Upgrade Proposal
    • How to issue a token via VICIssuer
    • How to verify if a contract has been issued via VICIssuer
    • How to deploy the VRC725 contract
    • How to apply ZeroGas for VRC725 contract
    • How to Migrate Dapps from Ethereum
    • How to register Token or NFT logo on Vicscan
    • How to verify a contract on Vicscan
    • How to confirm a project on Vicscan
    • How to check if a token is gas sponsored on Viction
    • How to verify gas sponsored transactions
    • How to create Telegram Mini Apps
    • How to use VictionSafe (Multisig)
  • FAQ
    • APIs
    • General
      • Viction
      • Ecosystem
      • VIC - Economics
      • Contact & Support
    • Masternodes and Voting
      • Masternodes
      • Voter
    • Products
      • VicScan (Explorer)
      • VicMaster
      • VicStats
      • VicIssuer
        • How to Verify & Publish Contract Source Code on VicScan
      • Viction Wallet
      • Viction Data Availability Network
  • Legal
    • Terms of Use
    • Privacy Policy
  • Whitepaper and Research
  • Archive
    • TOMOE
    • How to Deploy a VRC25 Token on Viction
    • How to deploy an ICO smart contract on Viction
    • How to deploy an NFT token
    • An Example of Building a Dapp on Viction
    • Migrate Ethereum Dapp to Viction
    • TomoMasterDAO
      • Introduction
      • Governance model
        • On-Chain vs Off-Chain Voting
        • Board
        • Proposals
        • Voting and Outcome
      • Tokenomics
      • How to utilize and trade tDAO
      • Proposal guidelines for TomoMasterDAO
    • Old Viction Testnet
    • Deploy on Viction
      • CLI Commands
      • Viction Private Testnet Setup
Powered by GitBook
On this page
  • What are Telegram Mini Apps?
  • Mini App type
  • Core Infrastructure
  • Integration
  • 1. Create a Telegram Bot
  • 2. Register a Game with @GameBot
  • 3. Deploy your smart contracts and assets
  • 4. Using Telegram Stars for in-game purchase
  • 5. Share your game
  1. How to

How to create Telegram Mini Apps

This guide will show you how to create Telegram Mini Apps on Viction

What are Telegram Mini Apps?

Telegram Mini Apps are lightweight web apps that run inside Telegram chats. They allow developers to create social experiences, games, marketplaces, and other services that tap into Telegram’s features and ~1B audience globally.

Mini App type

There are two main types of Mini Apps:

Inline Apps

Inline Apps show up as results when a user types the bot’s username followed by a query. The user taps an app result to launch the Mini App. Inline Apps are great for:

  • Search experiences

  • Quick interactions

  • Discovering new content

Direct Link Apps

Users can open a Direct Link App just by tapping a link. Direct Link Apps are aware of the current chat context and support shared, collaborative experiences. Direct Link Apps are ideal for:

  • Social experiences

  • Games

  • Productivity tools

  • And more

Core Infrastructure

  1. A Telegram-supported wallet: which allows developers to embed web3 wallet into their games. You might refer to the following that support Viction

  • Particle Network

  • Ramper

  • Wallet Connect

** Wallet bot could serve managing your assets without switching between apps outside of Telegram:*

  • WalletX

  • Coin98 (coming soon)

  1. A Webapp to link to Telegram

  2. A Telegram Bot to redirect users to the Webapp

  3. Payments - via crypto/Telegram Stars

Integration

1. Create a Telegram Bot

Generate a private Telegram Bot

Visit the @BotFather bot (developed by Telegram’s core team) and enter /newbot to create a new bot. You will receive an API token for your bot. Keep this token private as it will allow you to control your bot.

Connect the Webapp to your Bot

Use the /newapp command in the @BotFather bot by selecting your bot. Provide details such as the app name, description, photo, etc. Finally, enter the URL of your webapp. Your mini app will now appear in the Telegram app and can be launched by users.

Additional Capabilities

Mini apps opened from a direct link have limited capabilities. They cannot read or send messages on behalf of the user. However, they support cooperative and multiplayer features within the current chat context. Users must redirect to inline mode to actively pick a result in order to send messages.

Mini apps are powerful tools for creating fully-fledged web services, team collaborations, multiplayer games, and more. The possibilities are endless.

2. Register a Game with @GameBot

The first step is to register your game with @BotFather. Send the /newgame command to @BotFather, and provide the required details including:

  • The title and description of your game

  • A cover photo

  • The message text a user will see when starting a game

  • The URL of your Mini App

3. Deploy your smart contracts and assets

Viction provide a all-in-one development platform for web3 telegram games to enable seamless game deployment with ease

  1. Web3 wallet

  2. Management dashboard

  3. Audited contract templates for games

  4. Game Engine SDK

  5. Embedded Marketplace

  6. In-game purchase

…Guide by steps from Sequence/Thirdweb/Elympics…

4. Using Telegram Stars for in-game purchase

** There is no current option to enable purchasing Stars using $VIC or other assets on Viction*

In short, you must:

  • Deliver the goods and services purchased by the user

You may find that some API methods for Payments request a provider_token. This parameter is only needed for sales of physical goods and services – for digital ones, you can leave it empty.

Step-by-Step Process

See Bot API: Payments for the complete list of available methods and objects. Be sure to provide the proper set of parameters to account for the type of goods you are selling, differentiating between digital and physical orders.

1. Create Invoice

The user contacts @merchantbot and requests to purchase something. The bot forms an invoice message with a description of the goods or service and amount to be paid (expressed in Telegram Stars). There are two ways of creating an invoice:

A. Bot Invoice

Remember to specify XTR in the currency field, since all sales of digital goods and services are carried out exclusively in Telegram Stars.

B. Inline Invoice

2. Choose Forwarding Behavior

If a single-chat invoice is sent to the chat with @merchantbot, it can only be paid once. If a single-chat invoice is sent to any other chat, it can be paid many times by many users.

To get a better understanding of how this works, try toggling the “Pay from Forwards” parameter when creating invoices with our demo @ShopBot.

Regardless of whether or not the Pay button is available in an invoice, the merchant bot always has the power to decide whether or not to accept new payments for a particular invoice.

3. Pre-Checkout

The bot may return an error if it can't process the order for any reason. We highly recommend specifying a reason for failure to complete the order in human readable form (e.g. "Sorry, we're all out of rubber duck digital posters! Would you be interested in a cast iron bear digital poster instead?"). Telegram will display this reason to the user.

Warning: It is critical to make sure your bot only accepts multiple payments when the order can be processed correctly. This is especially important if you are using multi-chat, inline or single-chat, multi-use invoices.

4. Checkout

Warning: You must always check that you received a successful_payment update before delivering the goods or services purchased by the user – simply answering a pre_checkout_query does not guarantee a successful order or payment.

If the message was sent to any other chat, the Pay button remains and can be used again. It is up to the merchant bot whether to actually accept multiple payments.

5. Share your game

Once registered, your game will receive a shareable game URL and a game code which players can enter to launch the game. You can share this URL and code on your website, social media, and within Telegram chats to spread your game to other players.

PreviousHow to verify gas sponsored transactionsNextHow to use VictionSafe (Multisig)

Last updated 5 months ago

Stars can ONLY be acquired through in-app purchases via Apple and Google or , then spent on digital products offered by bots – from e-books and online courses to items in .

Walkthrough

You will find the necessary methods for building your payment implementation in the .

Send an invoice via (currency: “XTR”)

Await an with the field pre_checkout_query

Approve or cancel the order via

Await an with the field successful_payment

Store the ’s telegram_payment_charge_id – it may be needed to issue a refund in the future

Use the method to generate an invoice and send it to a chat. You can pass an empty string as the provider_token parameter, since the invoice is for digital goods and services.

If @merchantbot supports , you can use to allow users to share invoices for your goods and services to their one-on-one chats with friends, or to their groups and channels. These invoices will have a Pay button that can be used multiple times.

There are two ways for handling forwarded copies of your invoices, controlled by the parameter start_parameter in the method.

A. Multi-chat invoice. Forwarded copies show a Pay button, which multiple users can press and attempt to pay for the goods or services. are always multi-chat invoices.

B. Single-chat invoice. Invoice can only be paid from the chat to which it was sent, forwarded copies show a URL button with a deep link to the bot. The deep link can be used to generate a similar invoice in the chat with the bot, to show an error message, or for other purposes.

The user purchases Stars from Telegram (if necessary), then presses the pay button. At this moment the Bot API sends an with the field pre_checkout_query that contains all the available information about the order to the bot.

Your bot must reply using within 10 seconds after receiving this update or the transaction is canceled.

If the bot confirms the order and the payment is successful, the API will send a receipt message of the type from the user. Once your bot receives this message, it should proceed with sending the digital goods or services purchased by the user.

PremiumBot
Telegram games
Bot Payments API for Digital Goods and Services
Payments Section of the Bot API Manual
sendInvoice
Update
answerPreCheckoutQuery
Update
SuccessfulPayment
sendInvoice
inline mode
inputInvoiceMessageContent
sendInvoice
Inline invoices
More info on Deep Linking »
Update
answerPrecheckoutQuery
successful_payment