Ramper Documentation
  • 🌟WELCOME
  • 👨‍💻Developer Guide
    • Developer Dashboard
  • 🔐EMBEDDED WALLET SDK
    • Quickstart
      • For Web Apps
        • Multichain Supported
          • Wallet Integration
          • Approve NFT
          • Approve Token
          • Sign Typed
        • Get Started on Viction
      • For Unity Apps
      • For Telegram Mini Apps
        • Set up Telegram bot
        • Implement Ramper Telegram SDK
      • For React Native Apps
        • Installation
        • Getting Started
        • Wallet Integration
        • Sign Typed
        • Approve
    • Terms & Conditions
    • Privacy Policy
  • 💜RAMPER WALLET
    • About Ramper Wallet
    • 📖User Guides
      • Authentication
      • How to send NFTs
      • How to sign in to a new account
      • Wallet settings
      • How to Send & Receive tokens
      • How to add custom tokens
      • Manage Tokens
      • General settings
      • How to send assets via email
      • How to use Vault
      • How to send assets via OneID
      • How to migrate accounts from Old version to New version
    • ❓User FAQs
      • Which networks are supported on Ramper?
      • What social accounts can I use to log in to Ramper?
      • What is the difference between a Password and a Passphrase?
      • Zero-gas transactions
      • Does Ramper hold my funds?
      • Can I import my wallet from Ramper to another Web3 wallet?
      • Can I import my wallet to Ramper?
      • Why can't I see my assets?
      • What is gas fee?
      • Can I get my assets back if I send them to the wrong addresses?
      • I forgot the password of my social accounts. How can I access my funds on Ramper?
      • What happens if my social account is compromised?
      • Can I recover my wallet if I lose my social account?
      • Can I change the email that is associated with my wallet address?
      • I can't find the answer to my question. How can I get support?
      • What is a Protected Account?
      • I forgot the PIN code to log in to Ramper Wallet. How can I access my funds?
      • Which email domains are blocked?
    • Ramper Wallet (Extension) Integration
      • EVM Dapp Integration
      • Sei Dapp Integration
    • Privacy Policy
    • Terms of Service
  • 💸NFT CHECKOUT SDK
    • About Ramper NFT Checkout
    • Get Started on EVM
    • Get Started on NEAR
    • Setting Up Your Collection
    • Moving Your Collection to Production
    • Purchase History
    • Terms of Service
    • Privacy Policy
  • Import
Powered by GitBook
On this page
  • Guide
  • Method 1: Using npm (Recommended)
  • Method 2: Using CDN in HTML
  • Functions
  • getSDKVersion
  • hideIframe
  • initializeAsync
  • showIframe
  • signMessage
  • signOut
  1. EMBEDDED WALLET SDK
  2. Quickstart
  3. For Telegram Mini Apps

Implement Ramper Telegram SDK

PreviousSet up Telegram botNextFor React Native Apps

Last updated 7 months ago

Guide

There are 2 ways to add Ramper Embedded Wallet to a Telegram Mini App:

Method 1: Using npm (Recommended)

npm link:

import RamperTelegram from 'ramper-telegram';
const sdkConfig = {
    // gameId provided by Ramper, request before using the SDK
    gameId: 'sdk_sample',
    partner: 'coin98',
    // partner app id provided by Ramper, request before using the SDK
    appId: 'missing_app_id',
    // callback functions for handling sign in success, sign in fail and sign message
    onSignInSucess: (uProfile) => {
        // handle user profile after sign in success
        console.log('sign-in-success', uProfile);
    },
    onSignMessage: (msg) => {
        // handle message after sign in success
        console.log('sign-message-success', msg);
    },
    onSignInFail: (ev) => {
        // handle sign in fail
        console.error('sign-in-fail', ev);
    }
}

// Initialize RamperTelegram
RamperTelegram.initializeAsync(sdkConfig)
    .then(() => {
        console.log('init ramper success')
    })
    .catch((reason => {
        console.error('');
    }))

Method 2: Using CDN in HTML

<!-- Double check the version of the SDK before using it -->
<script src="https://game-sdk.static.cyborg.game/rampertelegram.umd.production.min.js"></script>
<script>
    RamperTelegram.initializeAsync({
        // gameId provided by Ramper, request before using the SDK
        gameId: 'sdk_sample',
        partner: 'coin98',
        // partner app id provided by Ramper, request before using the SDK
        appId: 'missing_app_id',
        // callback functions for handling sign in success, sign in fail and sign message
        onSignInSucess: (uProfile) => {
            // handle user profile after sign in success
            console.log('sign-in-success', uProfile);
        },
        onSignMessage: (msg) => {
            // handle message after sign in success
            console.log('sign-message-success', msg);
        },
        onSignInFail: (ev) => {
            // handle sign in fail
            console.error('sign-in-fail', ev);
        }
    }).then(() => {
        console.log('init ramper success')
    }).catch((reason => {
        console.error('');
    }))
</script>

Functions

getSDKVersion

Description

The string representation of this SDK version.

getSDKVersion(): string

Returns

string Returns string The SDK version.

Example

var sdkVersion = RamperTelegram.getSDKVersion(); // '1.0'

hideIframe

Description

Hide iframe

hideIframe(): void

Returns

void

Example

RamperTelegram.hideIframe();

initializeAsync

Description

Initializes the SDK library. This should be called before any other SDK functions. Login request be fired on this.

initializeAsync(config): Promise<any>

Parameters

• config: Object • Properties ts gameId: string; partner: string; onSignInSucess: (userProfile: UserProfile) => void; onSignMessage: (data: Object) => void; onSignInFail: (data: Object) => void;

Returns

Promise<void>

Example

RamperTelegram.initializeAsync({
    gameId: 'sdk_sample',
    partner: 'coin98',
    appId: 'missing_app_id',
    onSignInFail: (ev) => {
        console.error('sign in fail');
    },
    onSignInSucess: (uProfile) => {
        console.log('sign-in-success', uProfile);
    },
    onSignMessage: (msg) => {
        console.log('sign-message-success', msg);
    }
})

showIframe

Description

Open iframe with target url

showIframe(url, afterLoadUrlCallback): void

Parameters

• url: string set a callback to be fired on web loaded • afterLoadUrlCallback: any

Returns

void

Example

RamperTelegram.showIframe(
    'example.com',
    ()=>{
        console.log('load url success')
    }
)

signMessage

Description

Sign a string data.

signMessage(msg): void

Parameters

• msg: string

Returns

void

Example

RamperTelegram.signMessage('Hello World');

signOut

Description

Sign out the user.

signOut(callback): void

Parameters

Set a callback to be fired when a logout is triggered. • callback: Function

RamperTelegram.signOut(function() {
  console.log('logout event was triggered!');
})

Returns

void

🔐
https://www.npmjs.com/package/@ramper-v2/telegram-sdk