npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gasfree-kit/ton-gasless

v1.0.1

Published

Gasless USDT transfers on TON via sponsored relay

Downloads

498

Readme

@gasfree-kit/ton-gasless

⚠️ Deprecation notice (v2.0.0) — the positional methods TonTransfer.transferUSDT, TonTransfer.checkBalance, and TonTransfer.getTransactionEstimateFee are deprecated in favour of the options-object methods TonTransfer.send, TonTransfer.getBalance, and TonTransfer.estimateFee.

The legacy positional methods will be removed three weeks after the v2.0.0 publish date in the next major release. The new methods throw on failure and return a flat result (no { success, message, data } wrapper). Public TON endpoints are used by default — API keys are now optional but recommended for production traffic.

Gasless USDT transfers on TON through a sponsored relay.

With this package, the user only needs USDT. The relay pays the TON gas and charges a small fee back in USDT.

What This Package Does

  • creates a TON wallet from a seed phrase
  • quotes the relay fee in USDT
  • checks that balance covers transfer amount plus fee
  • submits the gasless transfer
  • returns a transfer context you can log or persist

Transfer Diagram

 ┌──────────────────────────┐
 │         Your app         │
 └────────────┬─────────────┘
              │
              v
 ┌──────────────────────────┐
 │ @gasfree-kit/ton-gasless │
 └──────┬─────────────┬─────┘
        │             │
        v             v
 ┌────────────┐ ┌───────────────┐
 │  TON       │ │  Relay fee    │
 │  wallet    │ │  quote (USDT) │
 └──────┬─────┘ └───────┬───────┘
        │               │
        └───────┬───────┘
                │
                v
 ┌──────────────────────────┐
 │     Sponsored relay      │
 ├──────────────────────────┤
 │  • Pays TON gas          │
 │  • Deducts USDT fee      │
 └────────────┬─────────────┘
              │
              v
 ┌──────────────────────────┐
 │     TON blockchain       │
 └──────────────────────────┘

Prerequisites

This package depends on @gasfree-kit/core for:

  • Seed phrase generationgenerateSeedPhrase() creates the mnemonic used to set up wallets
  • Address validationvalidateTonAddress() catches malformed addresses before sending
  • Error classesGasfreeError, InsufficientBalanceError, etc. for consistent error handling

@gasfree-kit/core is installed automatically as a dependency.

Installation

npm install @gasfree-kit/ton-gasless @gasfree-kit/core

After installing, your package manager will prompt you to install the peer dependencies listed in package.json.

Configuration

All URL/API-key fields are optional — the SDK falls back to the public endpoints exported as TON_PUBLIC_ENDPOINTS. For production traffic, register keys with toncenter.com / tonapi.io and pass them in.

import type { TonGaslessClientConfig } from '@gasfree-kit/ton-gasless';

// Minimal — uses public endpoints with no API keys.
const minimalConfig: TonGaslessClientConfig = {};

// Production — bring your own keys.
const config: TonGaslessClientConfig = {
  tonCenterApiKey: 'your-toncenter-api-key',
  tonApiSecretKey: 'your-tonapi-secret-key',
  // Optional URL overrides (default to public endpoints):
  // tonCenterUrl: 'https://toncenter.com/api/v2/jsonRPC',
  // tonApiUrl: 'https://tonapi.io',
  // transferMaxFee: 1_000_000,
  // usdtAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
};

Config fields

| Field | Purpose | | ----------------- | -------------------------------------------------------- | | tonCenterUrl | TON Center endpoint. Defaults to TON_PUBLIC_ENDPOINTS. | | tonCenterApiKey | TON Center API key. Optional; recommended for prod. | | tonApiUrl | TON API endpoint. Defaults to TON_PUBLIC_ENDPOINTS. | | tonApiSecretKey | TON API secret key. Optional; recommended for prod. | | transferMaxFee | Maximum fee limit in base units, capped by the SDK. | | usdtAddress | Optional override for the TON USDT root. |

Quick Start

1. Generate a seed phrase

import { generateSeedPhrase } from '@gasfree-kit/core';

const seedPhrase = await generateSeedPhrase();

2. Set up a wallet

import { setupTonGaslessWallet } from '@gasfree-kit/ton-gasless';

const { wallet, account, address } = await setupTonGaslessWallet(seedPhrase, config);

console.log(address);

If you need a specific derivation path:

const walletResult = await setupTonGaslessWallet(seedPhrase, config, "0'/0/0");

3. Check USDT balance

import { TonTransfer } from '@gasfree-kit/ton-gasless';

const balance = await TonTransfer.getBalance({ seedPhrase, config });

console.log(balance.balance); // "42.50"
console.log(balance.balanceRaw); // 42500000n
console.log(balance.address); // wallet address

4. Estimate the fee

const estimate = await TonTransfer.estimateFee({
  seedPhrase,
  config,
  to: 'EQRecipient...',
  amount: '10.00',
});

console.log(estimate.fee); // "0.05" (gasless commission in USDT)

5. Execute the gasless transfer

const result = await TonTransfer.send({
  seedPhrase,
  config,
  to: 'EQRecipient...',
  amount: '50.00',
});

console.log(result.transactionHash);
console.log(result.fee); // bigint, base units
console.log(result.submittedAt);

The legacy positional methods (transferUSDT, checkBalance, getTransactionEstimateFee) remain available and return the previous { success, message, data } envelope. They are marked @deprecated and wrap the new methods above.

How The Flow Behaves

  1. The SDK validates the recipient address.
  2. The SDK asks the relay path for a fee quote.
  3. The SDK checks that the wallet balance can cover amount + fee.
  4. The transfer is submitted.
  5. The relay pays TON gas and deducts the fee in USDT.

Main Exports

| Export | What it does | | ------------------------ | ------------------------------------------------------------------ | | setupTonGaslessWallet | Creates the TON wallet from a seed phrase and resolves the address | | TonTransfer | Checks balances, estimates fees, and sends transfers | | getTonGaslessConfig | Expands and validates the runtime config | | tonUsdtTokenRoot | Built-in TON USDT root address | | usdtTonBaseUnits | Converts human-readable USDT to base units | | fromTonBaseUnitsToUsdt | Converts base units back to readable USDT | | getTonUsdtValue | Utility helper for TON to USDT conversions |

Safety Notes

  • transferMaxFee is capped by the SDK to prevent extreme fee deductions
  • invalid TON addresses are rejected before sending
  • self-transfers are blocked
  • the user must have enough USDT for both transfer amount and fee

License

MIT