TON (The Open Network)
💎 Probably, the best blockchain over there
Last updated
💎 Probably, the best blockchain over there
Last updated
The Open Network (TON) is a decentralized and open internet platform made up of several components. These include: TON Blockchain, TON DNS, TON Storage, and TON Sites. TON Blockchain is the core protocol that connects TON’s underlying infrastructure together to form the greater TON Ecosystem.
Directual TON plugin allows you to create Web-apps, Telegram Mini Apps easily and securely using no-code approach.
Go to API → Webhooks and add a new one. Turn on CORS for it!
First — you have Get transactions step in your scenario. It calls /v2/blockchain/accounts/{account_id}/transactions
method of TON API.
Usually, such scenarios run on a scheduler manner (hourly, for example), the data structure (let's name it trigger
) contains a single object.
Specify the wallet address to get the transactions and the field where to save the API response:
The response looks like:
Key things here are:
transactions.in_msg.value
transactions.in_msg.decoded_body.text
Let's use JSON-step for parsing the response! For that we need:
Create a new data structure ton transactions
with needed fields;
Add a field type of arrayLink
to transactions data structure to the structure trigger
Configure JSON-step: add the json-scheme (copy it above) and set up matching
All right, we get all the transactions. Then we can identify them using comments/values, etc.
Hint: if you want to extract oder number from text like Your order is #12345
, use the following expression (turn on JS-evaluation):
Add a Pay in TONs component to your web-page
Configure the plugin (paste to the webhook
URL of the webhook we'e created).
Pay attention that amount
is in nanoTons. 1 000 000 000 nanoTONs = 1 TON
The user will see the two-component:
First step – connecting wallet (Telegram wallet, MyTonWallet, Tonkeeper, etc.)
Second step – confirming transaction
When the user confirms the transaction, you'll get a notification via webhook (don't forget to turn on CORS for it!)
Notification body:
user
will be null
if your user is not authorised.
Don't use that notification for confirming your orders! Because one can send a fake request to your webhook. Use that notification as a trigger for checking the blockchain!
Bear in mind that there may be a certain lag between notification and transaction completing (usually 1-3 minutes). Thus, use Delay step in the scenario, that is triggered by the webhook.