@integraledger/lcp/tvm
The exports of @integraledger/lcp/tvm.
Interfaces
TonCell
A TON cell, as @ton/core's Cell gives one: its data bits, its references and its representation hash. The entry
point's public types name this shape rather than the optional peer's class, and a Cell is one.
Properties
| Property | Modifier | Type |
|---|---|---|
bits | readonly | object |
bits.length | readonly | number |
refs | readonly | readonly TonCell[] |
Methods
hash()
hash(
level?):Uint8Array
Parameters
| Parameter | Type |
|---|---|
level? | number |
Returns
Uint8Array
TonTx
A transaction as a TON Center v3 endpoint reports it. inBody is the inbound message body as a BoC.
Properties
| Property | Type |
|---|---|
aborted | boolean |
account | string |
finality | 0 | 1 | 2 |
hash | string |
inBody | Uint8Array<ArrayBufferLike> | null |
outMsgs | readonly object[] |
TvmChoice
Properties
| Property | Type | Description |
|---|---|---|
accepted | PaymentRequirements | - |
attachNanotons | bigint | The value attached to the outgoing message, above forwardTonAmount. |
jettonWallet | string | The payer's Jetton wallet for asset, raw (get_wallet_address on the master). |
now | number | Seconds since the epoch. |
required | PaymentRequired | - |
seqno | number | - |
stateInit? | string | TonCell | The wallet's state init, for a wallet not yet deployed: a cell, or a base64 BoC of one root cell. |
wallet | string | The payer's W5 wallet, raw. |
walletId | number | get_subwallet_id. |
TvmReader
Bounded, read-only calls against one network's TON Center v3 endpoint. Every failure rejects with ReaderError.
Properties
Methods
byHash()
byHash(
txHash):Promise<TonTx|null>
GET /api/v3/transactions?hash=…
Parameters
| Parameter | Type |
|---|---|
txHash | string |
Returns
Promise<TonTx | null>
byInBody()
byInBody(
bodyHash):Promise<readonlyTonTx[]>
GET /api/v3/transactionsByMessage?body_hash=…&direction=in
Parameters
| Parameter | Type |
|---|---|
bodyHash | `0x${string}` |
Returns
Promise<readonly TonTx[]>
byInMessage()
byInMessage(
msgHash):Promise<readonlyTonTx[]>
GET /api/v3/transactionsByMessage?msg_hash=…&direction=in
Parameters
| Parameter | Type |
|---|---|
msgHash | string |
Returns
Promise<readonly TonTx[]>
headUtime()
headUtime():
Promise<number>
GET /api/v3/masterchainInfo: the last indexed block's gen_utime.
Returns
Promise<number>
TvmRef
The read keys recorded at claim.
Properties
| Property | Type |
|---|---|
jettonWallet | string |
network | `tvm:${number}` |
transferBodyHash | `0x${string}` |
validUntil | number |
TvmUnsigned
Properties
| Property | Type | Description |
|---|---|---|
request | object | The 32-byte representation hash of the W5 request the wallet key signs. |
request.hash | Uint8Array | - |
request.kind | "ton-w5" | - |
Methods
complete()
complete(
signature):Refusal|TvmPayment
Takes the 64-byte Ed25519 signature.
Parameters
| Parameter | Type |
|---|---|
signature | Uint8Array |
Returns
Type Aliases
TvmNetwork
TvmNetwork =
`tvm:${number}`
tvm:<global_id>: tvm:-239 mainnet, tvm:-3 testnet.
TvmPayment
TvmPayment =
X402Payment<{asset:string;settlementBoc:string; }>
TvmStatus
TvmStatus = {
finality:"confirmed"|"finalized";state:"settled"; } | {state:"pending";why:"not-found"|"in-flight"|"not-final"|"unreadable"; } | {state:"failed";why:"aborted"|"no-transfer"|"bounced"|"expired"; }
Variables
exactTvm
constexactTvm:Readonly<{advertise: (doc,h,link,offer,agreementUrl?) =>Refusal|PaymentRequired;bound: (presented) =>Promise<`0x${string}`|Refusal>;build: (c,h) =>Promise<Refusal|TvmUnsigned>;carrier:"extra.forwardPayload";claims:boolean;id:"x402/exact/tvm";pattern:LcpPattern;read: (doc) =>Refusal|X402Read;recover: (ref,reader) =>Promise<`0x${string}`|Refusal>;reference: (presented) =>Promise<Refusal|TvmRef>;status: (ref,reader) =>Promise<TvmStatus>;tie: (accepts,request) => ["x402", {accepts: readonlyPaymentRequirements[];request:RequestCommitment; }];txId: (tx) =>string;unplaced: (option) =>PaymentRequirements; }>
OP
constOP:object
Type Declaration
| Name | Type | Default value |
|---|---|---|
internalSigned | 1936289396 | 0x73696e74 |
internalTransfer | 395134233 | 0x178d4519 |
jettonTransfer | 260734629 | 0x0f8a7ea5 |
sendMsg | 247711853 | 0x0ec3c86d |
Functions
lcpComment()
TEP-74's text comment: 32 zero bits, then the UTF-8 of the hash's LCP string. A value that is not a 32-byte hash is
x402/payload-malformed.
Parameters
| Parameter | Type |
|---|---|
h | `0x${string}` |
Returns
pairingOf()
pairingOf(
option):"x402/exact/tvm"|undefined
This pairing's id for an option it can pay, or undefined.
Parameters
| Parameter | Type |
|---|---|
option | PaymentRequirements |
Returns
"x402/exact/tvm" | undefined
tvmCarrier()
tvmCarrier(
settlementBoc):Refusal| {h:`0x${string}`;jettonWallet:string;payload:TonCell;transferBodyHash:`0x${string}`;validUntil:number; }
Reads the signed request in a settlement BoC: an internal message whose body is a W5 internal_signed request with
exactly one action_send_msg behind an empty list, carrying a Jetton transfer whose forward payload is a reference
to a text comment holding an LCP string.
Parameters
| Parameter | Type |
|---|---|
settlementBoc | string |
Returns
Refusal | { h: `0x${string}`; jettonWallet: string; payload: TonCell; transferBodyHash: `0x${string}`; validUntil: number; }
tvmRecover()
tvmRecover(
ref,reader):Promise<`0x${string}`|Refusal>
Recovers the hash from the payer Jetton wallet's transaction: the comment in its inbound Jetton transfer. One call.
Parameters
| Parameter | Type |
|---|---|
ref | { network: `tvm:${number}`; transaction: string; } |
ref.network | `tvm:${number}` |
ref.transaction | string |
reader | TvmReader |
Returns
Promise<`0x${string}` | Refusal>
tvmStatus()
tvmStatus(
ref,reader):Promise<TvmStatus>
Finds the transfer by its body hash on the payer's Jetton wallet, then follows its internal_transfer to the
payee's Jetton wallet. Settled when both executed without aborting, at the lower finality of the two. A
transaction on any other account is ignored. A failed read, or a reader for another network, is pending.
Parameters
Returns
Promise<TvmStatus>
tvmTxId()
tvmTxId(
tx):string
A TON transaction hash in one spelling: lowercase hex without 0x (x402's TON scheme gives transaction as
"Transaction hash (64-character hex string)"), whether it is given in hex, or in the base64 or base64url of its 32
bytes that TON Center answers. Any other string is returned unchanged.
Parameters
| Parameter | Type |
|---|---|
tx | string |
Returns
string
Last updated on