Ads3Ads3
How Ad Network Works
Advertiser
Publisher
Quest
  • Telegram
  • Twitter
  • Discord
  • Press Kit
  • English
  • 简体中文
How Ad Network Works
Advertiser
Publisher
Quest
  • Telegram
  • Twitter
  • Discord
  • Press Kit
  • English
  • 简体中文
  • Exchange

  • Get Started

    • Introduction
    • Creating an Exchange Task
    • Traffic Export
    • Traffic Import
  • Code Integration

    • SDK Ad Integration
    • SDK Ad Integration (Advanced)
  • Reference

    • Glossary
    • SDK Installation

Prerequisites

  • You must already have an ExchangeId. If you do not have one, please refer to Creating an Exchange Task.

SDK Installation

Please refer to SDK Installation for details on how to install the SDK.

Displaying Ads

Once the user clicks on the "Watch Ad" button, execute the following code, for example:

watch_ad
watch_ad
import { TonExchangeAdPopupShow } from 'ton-ai-sdk'

TonExchangeAdPopupShow({
  exchangeId: 'your_exchange_id',
  onAdClick: (ad) => {
    // The user triggered an ad click
    // You can issue a reward here
  },
  onAdError: (error) => {
    // An error occurred while the user was watching the ad
    // You can choose to do nothing here or handle the error as you see fit
  },
})

Tips

Within the onAdClick function, you can reward users, such as increasing their life points or enhancing a character's abilities.

Tips

Errors may occur due to:

  • Network errors when retrieving ads
  • Errors during ad playback
  • No ads available at the moment

The SDK will display the ad, and the ad effect will look like this:

ad_popup
ad_popup

After the ad countdown ends, various event listeners will trigger, allowing you to issue rewards or perform other actions as desired.

Next
SDK Ad Integration (Advanced)