Integrate payments with MEMO

Establish a TON Wallet

Begin by setting up your TON wallet and securely storing your seed phrase or private key. This wallet will function as a "hot wallet," holding all your tokens.

Configure Your Backend

Install the SDK

With the SDK installed, you'll unlock access to a range of features offered by the GRAM20 Protocol API.

Implement Transaction Monitoring

Regularly monitor your wallet for transactions using the following code snippets:

import { getHistory, getHistoryByTick, HistoryInfo } from 'gram20-sdk/v1';

// Retrieve historical gram20 token transactions
const gramHistory = await getHistory(YOUR_HOT_WALLET, 'gram'); // Returns an Array<HistoryInfo>

type HistoryInfo = {
  address: string;
  tick: string;
  time: number;
  hash: string;
  delta: number;
  comment: string;
  peer: string;
  lt: number;
};

Generate Unique MEMOs for Backend Transactions

Implement a system to recognize specific transactions as being intended for individual users through the transaction history.

Update User Balances

Upon detecting a new transaction for a user, update their balance in your database accordingly. Be mindful of the delta value, as a positive number indicates incoming tokens, while a negative number signifies outgoing tokens.

Ask user to send tokens

To request a transaction from a user through the TG20 Mini App, you can utilize our integrated Deep Links. This feature enables a seamless process for users to send transactions directly to you.

Last updated