Telegram Module setup

Introduction

This documentation guides developers through the process of setting up a crypto wallet using Telegram and our module. By integrating the Telegram Login Widget and configuring it with the provided data-auth-url, developers can create Ethereum wallets for their users linked to their Telegram IDs. The response from this process includes essential user details and an Ethereum address for further use.

Prerequisites

Before proceeding, ensure that you have the following prerequisites:

  • A website or application where you want to implement the Telegram Login Widget.

  • The Telegram API Token for your bot (which you can obtain from the Telegram BotFather).

  • Whitelist your website domain on the Bot settings.

  • The https://api.0xgasless.com/auth/telegram/callback URL to configure the Telegram Login Widget.

Step 1: Adding the Telegram Login Widget

  1. In your website's HTML code, include the Telegram Login Widget with the following configuration:

<script async src="https://telegram.org/js/telegram-widget.js?4"
        data-telegram-login="{your-bot-username}" 
        data-size="large"
        data-radius="10"
        data-auth-url="https://api.0xgasless.com/auth/telegram/callback">
</script>

Replace {your-bot-username} with your bot's username.

  1. Add a button or element to trigger the Telegram Login Widget. For example:

htmlCopy code<button id="telegram-login-button">Login with Telegram</button>
  1. Make sure you have the Telegram widget script loaded before your code executes.

Step 2: Handling the Callback

  1. Capture the received data, including id, username, first_name, last_name, and ethAddress. This information will be returned as JSON data.

  2. Store this user data in your database or use it as needed for your application.

Last updated