Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
How does TON Payments work? What's the difference between them and Payment Channels?

I want to use TON blockchain (ton.org) to receive payments. What does that involve? What components do I need to implement?

Posted one year ago
Tal Kol
334 × 3 Administrator
Votes Newest


When discussing payments on TON, there are two methods you should be aware of:

1. Payment Channels

This method is useful when you have many small payments between several parties and gas cost (transaction fee) is an issue. This method will eliminate the blockchain fees and make them constant and independent on the number of payments.

The method works by using a template standard smart contract called PaymentChannel that the two parties deploy an instance of. Then the two parties deposit some amount of TON Coin into the contract. Then they transact off-chain and can do thousands of payments between them without paying any fees. Only when the channel is closed, the contract will calculate how the deposited money should be split between the parties and actually sent them the money on-chain.

More info: https://github.com/ton-blockchain/payment-channels

And here's a client library in JS that facilitates the process.

2. Simple Payment

This method is much simpler and should be used when you're expecting a single payment and the gas is not an issue. In this case you simply create a new wallet for the recipient (for example an e-commerce store) and implement a small backend usually in JavaScript or Python that queries the wallet periodically to see if any payments has been made to it.

You can deploy the wallet contract using any standard TON wallet like TonKeeper and then use its address in your backend to check periodically if payments have been received.

More info: https://ton.org/docs/#/payment-processing/deposits-single-wallet

And if you're a fan of JavaScript here's a good blog post showing how this can be easily done: https://society.ton.org/how-ton-wallets-work-and-how-to-access-them-from-javascript

const tonMnemonic = require("tonweb-mnemonic");
const TonWeb = require("tonweb");

async function main() {
  // mnemonic to key pair
  const mnemonic = "rail sound peasant ... portion gossip arrow"; // 24 words
  const mnemonicArray = mnemonic.split(" ");
  const keyPair = await tonMnemonic.mnemonicToKeyPair(mnemonicArray);
  console.log("public key:", Buffer.from(keyPair.publicKey).toString('hex'));
  // list available wallet versions
  const tonweb = new TonWeb(new TonWeb.HttpProvider("https://toncenter.com/api/v2/jsonRPC"));
  console.log("wallet versions:", Object.keys(tonweb.wallet.all).toString());
  // instance of wallet V4 r2 (from the list printed above)
  const WalletClass = tonweb.wallet.all["v4R2"];
  const wallet = new WalletClass(tonweb.provider, { publicKey: keyPair.publicKey });
  const address = await wallet.getAddress();
  console.log("address:", address.toString(true, true, true));
  const seqno = await wallet.methods.seqno().call();
  console.log("seqno:", seqno);
  await sleep(1500); // avoid throttling by toncenter.com
  const balance = await tonweb.getBalance(address);
  console.log("balance:", TonWeb.utils.fromNano(balance));


function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
Posted one year ago
Tal Kol
334 × 3 Administrator
1 Answer
one year ago
one year ago