@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). UsebodyBase64HashfromcreateTonPayTransfer.options:APIOptions.- Return
CompletedTonPayTransferInfo.
getTonPayTransferByReference(reference, options?)
Fetch a transfer by reference.
reference: use thereferencereturned bycreateTonPayTransfer.options:APIOptions.- Return
CompletedTonPayTransferInfo.
useTonPay(options?)
A React hook. Connect a wallet through TON Connect and send a transaction.
pay(getMessage): ReceivesenderAddr, 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.
amount in asset units. Follow asset decimals. For example: TON 9 decimals, USDT 6 decimals.
CreateTonPayTransferResponse
CompletedTonPayTransferInfo
status:pending,success, orerror;errorCode: TON Pay error codes in Check status and retrieve info.
APIOptions
Default:
mainnet.Constants: @ton-pay/api
Mainnet address riskToken constants such as
USDT always reference mainnet jetton master addresses and are not affected by the chain option. Using them on testnet may send transactions to mainnet contracts.For testnet, explicitly pass the correct testnet jetton master address instead of using token constants.Errors
All API helpers throwError with an HTTP cause if the network call fails. For example, createTonPayTransfer may throw “Failed to create TON Pay transfer”.
Peer dependencies
@tonconnect/ui-react– React UI kit for TON Connect SDK.- React 18 or later and
react-dom18 or later.