@gasfree-kit/ton-gasless 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @gasfree-kit/ton-gasless
2
+
3
+ Gasless USDT transfers on TON through a sponsored relay.
4
+
5
+ With this package, the user only needs USDT. The relay pays the TON gas and charges a small fee back in USDT.
6
+
7
+ ## What This Package Does
8
+
9
+ - creates a WDK-backed TON wallet
10
+ - quotes the relay fee in USDT
11
+ - checks that balance covers transfer amount plus fee
12
+ - submits the gasless transfer
13
+ - returns a transfer context you can log or persist
14
+
15
+ ## Transfer Diagram
16
+
17
+ ```mermaid
18
+ flowchart LR
19
+ App["Your app"] --> SDK["@gasfree-kit/ton-gasless"]
20
+ SDK --> Wallet["WDK TON wallet"]
21
+ SDK --> Quote["Relay fee quote"]
22
+ Quote --> Relay["Sponsored relay"]
23
+ Relay --> TON["TON blockchain"]
24
+ Relay --> Fee["USDT commission"]
25
+ ```
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @gasfree-kit/ton-gasless
31
+ ```
32
+
33
+ Peer dependencies:
34
+
35
+ ```bash
36
+ npm install @tetherto/wdk-wallet-ton-gasless tonweb
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ ```ts
42
+ import type { TonGaslessClientConfig } from '@gasfree-kit/ton-gasless';
43
+
44
+ const config: TonGaslessClientConfig = {
45
+ tonCenterUrl: 'https://toncenter.com/api/v2',
46
+ tonCenterApiKey: 'your-toncenter-api-key',
47
+ tonApiUrl: 'https://tonapi.io',
48
+ tonApiSecretKey: 'your-tonapi-secret-key',
49
+ // Optional:
50
+ // transferMaxFee: 1_000_000,
51
+ // usdtAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
52
+ };
53
+ ```
54
+
55
+ ### Config fields
56
+
57
+ | Field | Purpose |
58
+ | ----------------- | -------------------------------------------------- |
59
+ | `tonCenterUrl` | TON Center endpoint used by the wallet client |
60
+ | `tonCenterApiKey` | TON Center API key |
61
+ | `tonApiUrl` | TON API endpoint |
62
+ | `tonApiSecretKey` | TON API secret key |
63
+ | `transferMaxFee` | Maximum fee limit in base units, capped by the SDK |
64
+ | `usdtAddress` | Optional override for the TON USDT root |
65
+
66
+ ## Quick Start
67
+
68
+ ### 1. Set up a wallet
69
+
70
+ ```ts
71
+ import { setupTonGaslessWallet } from '@gasfree-kit/ton-gasless';
72
+
73
+ const seedPhrase = 'your twelve word seed phrase here ...';
74
+ const { wallet, account, address } = await setupTonGaslessWallet(seedPhrase, config);
75
+
76
+ console.log(address);
77
+ ```
78
+
79
+ If you need a specific derivation path:
80
+
81
+ ```ts
82
+ const walletResult = await setupTonGaslessWallet(seedPhrase, config, "0'/0/0");
83
+ ```
84
+
85
+ ### 2. Check USDT balance
86
+
87
+ ```ts
88
+ import { TonTransfer } from '@gasfree-kit/ton-gasless';
89
+
90
+ const balance = await TonTransfer.checkBalance(seedPhrase, config);
91
+
92
+ console.log(balance.data.usdBalance);
93
+ console.log(balance.data.tokenBalance);
94
+ ```
95
+
96
+ ### 3. Estimate the fee
97
+
98
+ ```ts
99
+ const estimate = await TonTransfer.getTransactionEstimateFee(
100
+ seedPhrase,
101
+ config,
102
+ '10.00',
103
+ 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
104
+ );
105
+
106
+ console.log(estimate.data.fee);
107
+ ```
108
+
109
+ ### 4. Execute the gasless transfer
110
+
111
+ ```ts
112
+ const result = await TonTransfer.transferUSDT(
113
+ seedPhrase,
114
+ config,
115
+ '50.00',
116
+ 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
117
+ );
118
+
119
+ console.log(result.data.transactionHash);
120
+ console.log(result.data.fee);
121
+ ```
122
+
123
+ ## How The Flow Behaves
124
+
125
+ 1. The SDK validates the recipient address.
126
+ 2. The SDK asks the relay path for a fee quote.
127
+ 3. The SDK checks that the wallet balance can cover `amount + fee`.
128
+ 4. The transfer is submitted.
129
+ 5. The relay pays TON gas and deducts the fee in USDT.
130
+
131
+ ## Main Exports
132
+
133
+ | Export | What it does |
134
+ | ------------------------ | ---------------------------------------------------------- |
135
+ | `setupTonGaslessWallet` | Creates the WDK-backed TON wallet and resolves the address |
136
+ | `TonTransfer` | Checks balances, estimates fees, and sends transfers |
137
+ | `getTonGaslessConfig` | Expands and validates the runtime config |
138
+ | `tonUsdtTokenRoot` | Built-in TON USDT root address |
139
+ | `usdtTonBaseUnits` | Converts human-readable USDT to base units |
140
+ | `fromTonBaseUnitsToUsdt` | Converts base units back to readable USDT |
141
+ | `getTonUsdtValue` | Utility helper for TON to USDT conversions |
142
+
143
+ ## Safety Notes
144
+
145
+ - `transferMaxFee` is capped by the SDK to prevent extreme fee deductions
146
+ - invalid TON addresses are rejected before sending
147
+ - self-transfers are blocked
148
+ - the user must have enough USDT for both transfer amount and fee
149
+
150
+ ## License
151
+
152
+ MIT
package/dist/index.d.mts CHANGED
@@ -37,7 +37,7 @@ declare function setupTonGaslessWallet(seedPhrase: string, config: TonGaslessCli
37
37
  address: string;
38
38
  }>;
39
39
 
40
- declare class TonGaslessTetherTransfer {
40
+ declare class TonTransfer {
41
41
  /**
42
42
  * Get transaction fee estimate for a gasless USDT transfer on TON.
43
43
  * The gasless commission is returned in USDT (paymaster token units).
@@ -56,7 +56,7 @@ declare class TonGaslessTetherTransfer {
56
56
  message: string;
57
57
  success: boolean;
58
58
  data: {
59
- nativeBalance: number;
59
+ tokenBalance: string;
60
60
  decimals: number;
61
61
  usdBalance: string;
62
62
  };
@@ -98,4 +98,4 @@ declare function fromTonBaseUnitsToUsdt(amount: bigint, dec?: number): string;
98
98
  */
99
99
  declare function getTonUsdtValue(amountInBaseUnits: bigint, exchangeRate: number): number;
100
100
 
101
- export { type TonGaslessClientConfig, type TonGaslessNetworkConfig, TonGaslessTetherTransfer, fromTonBaseUnitsToUsdt, getTonGaslessConfig, getTonUsdtValue, setupTonGaslessWallet, tonUsdtTokenRoot, usdtTonBaseUnits };
101
+ export { type TonGaslessClientConfig, type TonGaslessNetworkConfig, TonTransfer, fromTonBaseUnitsToUsdt, getTonGaslessConfig, getTonUsdtValue, setupTonGaslessWallet, tonUsdtTokenRoot, usdtTonBaseUnits };
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ declare function setupTonGaslessWallet(seedPhrase: string, config: TonGaslessCli
37
37
  address: string;
38
38
  }>;
39
39
 
40
- declare class TonGaslessTetherTransfer {
40
+ declare class TonTransfer {
41
41
  /**
42
42
  * Get transaction fee estimate for a gasless USDT transfer on TON.
43
43
  * The gasless commission is returned in USDT (paymaster token units).
@@ -56,7 +56,7 @@ declare class TonGaslessTetherTransfer {
56
56
  message: string;
57
57
  success: boolean;
58
58
  data: {
59
- nativeBalance: number;
59
+ tokenBalance: string;
60
60
  decimals: number;
61
61
  usdBalance: string;
62
62
  };
@@ -98,4 +98,4 @@ declare function fromTonBaseUnitsToUsdt(amount: bigint, dec?: number): string;
98
98
  */
99
99
  declare function getTonUsdtValue(amountInBaseUnits: bigint, exchangeRate: number): number;
100
100
 
101
- export { type TonGaslessClientConfig, type TonGaslessNetworkConfig, TonGaslessTetherTransfer, fromTonBaseUnitsToUsdt, getTonGaslessConfig, getTonUsdtValue, setupTonGaslessWallet, tonUsdtTokenRoot, usdtTonBaseUnits };
101
+ export { type TonGaslessClientConfig, type TonGaslessNetworkConfig, TonTransfer, fromTonBaseUnitsToUsdt, getTonGaslessConfig, getTonUsdtValue, setupTonGaslessWallet, tonUsdtTokenRoot, usdtTonBaseUnits };
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- TonGaslessTetherTransfer: () => TonGaslessTetherTransfer,
33
+ TonTransfer: () => TonTransfer,
34
34
  fromTonBaseUnitsToUsdt: () => fromTonBaseUnitsToUsdt,
35
35
  getTonGaslessConfig: () => getTonGaslessConfig,
36
36
  getTonUsdtValue: () => getTonUsdtValue,
@@ -112,7 +112,7 @@ function getTonUsdtValue(amountInBaseUnits, exchangeRate) {
112
112
  }
113
113
 
114
114
  // src/tonGaslessTetherTransfer.ts
115
- var TonGaslessTetherTransfer = class {
115
+ var TonTransfer = class {
116
116
  /**
117
117
  * Get transaction fee estimate for a gasless USDT transfer on TON.
118
118
  * The gasless commission is returned in USDT (paymaster token units).
@@ -150,7 +150,7 @@ var TonGaslessTetherTransfer = class {
150
150
  message: "TON balances retrieved successfully",
151
151
  success: true,
152
152
  data: {
153
- nativeBalance: Number(balance),
153
+ tokenBalance: balance.toString(),
154
154
  decimals: 6,
155
155
  usdBalance: String(usdBalance)
156
156
  }
@@ -230,7 +230,7 @@ var TonGaslessTetherTransfer = class {
230
230
  };
231
231
  // Annotate the CommonJS export names for ESM import in node:
232
232
  0 && (module.exports = {
233
- TonGaslessTetherTransfer,
233
+ TonTransfer,
234
234
  fromTonBaseUnitsToUsdt,
235
235
  getTonGaslessConfig,
236
236
  getTonUsdtValue,
package/dist/index.mjs CHANGED
@@ -74,7 +74,7 @@ function getTonUsdtValue(amountInBaseUnits, exchangeRate) {
74
74
  }
75
75
 
76
76
  // src/tonGaslessTetherTransfer.ts
77
- var TonGaslessTetherTransfer = class {
77
+ var TonTransfer = class {
78
78
  /**
79
79
  * Get transaction fee estimate for a gasless USDT transfer on TON.
80
80
  * The gasless commission is returned in USDT (paymaster token units).
@@ -112,7 +112,7 @@ var TonGaslessTetherTransfer = class {
112
112
  message: "TON balances retrieved successfully",
113
113
  success: true,
114
114
  data: {
115
- nativeBalance: Number(balance),
115
+ tokenBalance: balance.toString(),
116
116
  decimals: 6,
117
117
  usdBalance: String(usdBalance)
118
118
  }
@@ -191,7 +191,7 @@ var TonGaslessTetherTransfer = class {
191
191
  }
192
192
  };
193
193
  export {
194
- TonGaslessTetherTransfer,
194
+ TonTransfer,
195
195
  fromTonBaseUnitsToUsdt,
196
196
  getTonGaslessConfig,
197
197
  getTonUsdtValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gasfree-kit/ton-gasless",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Gasless USDT transfers on TON via sponsored relay",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,10 +13,11 @@
13
13
  }
14
14
  },
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "README.md"
17
18
  ],
18
19
  "dependencies": {
19
- "@gasfree-kit/core": "0.1.0"
20
+ "@gasfree-kit/core": "0.1.1"
20
21
  },
21
22
  "peerDependencies": {
22
23
  "@tetherto/wdk-wallet-ton-gasless": "^1.0.0-beta.4",