Skip to main content
TypeScript exports for the TON Pay SDK packages @ton-pay/api and @ton-pay/ui-react. To install the packages, use:

Imports

Functions

createTonPayTransfer(params, options?)

Build a canonical message and return tracking identifiers.
  • params: CreateTonPayTransferParams.
  • options: APIOptions.
  • options.chain: mainnet | testnet.

getTonPayTransferByBodyHash(bodyHash, options?)

Fetch a transfer by Base64 hash of the signed message body content (payload).
  • bodyHash: Base64 hash of the signed message body content (payload). Use bodyBase64Hash from createTonPayTransfer.
  • options: APIOptions.
  • Return CompletedTonPayTransferInfo.

getTonPayTransferByReference(reference, options?)

Fetch a transfer by reference.
  • reference: use the reference returned by createTonPayTransfer.
  • options: APIOptions.
  • Return CompletedTonPayTransferInfo.

useTonPay(options?)

A React hook. Connect a wallet through TON Connect and send a transaction.
  • pay(getMessage): Receive senderAddr, request { message } from the factory, and send through TON Connect. Resolve { txResult, ...factoryReturn }.

TonPayButton

Prebuilt button. Handle wallet connect or disconnect flow and call handlePay.

Types: @ton-pay/api

CreateTonPayTransferParams

Request payload for createTonPayTransfer.
Specify amount in asset units. Follow asset decimals. For example: TON 9 decimals, USDT 6 decimals.

CreateTonPayTransferResponse

CompletedTonPayTransferInfo

APIOptions

Constants: @ton-pay/api

Errors

All API helpers throw Error with an HTTP cause if the network call fails. For example, createTonPayTransfer may throw “Failed to create TON Pay transfer”.

Peer dependencies