Skip to content
Integra Protocol
API

@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

PropertyModifierType
bitsreadonlyobject
bits.lengthreadonlynumber
refsreadonlyreadonly TonCell[]

Methods

hash()

hash(level?): Uint8Array

Parameters
ParameterType
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

PropertyType
abortedboolean
accountstring
finality0 | 1 | 2
hashstring
inBodyUint8Array<ArrayBufferLike> | null
outMsgsreadonly object[]

TvmChoice

Properties

PropertyTypeDescription
acceptedPaymentRequirements-
attachNanotonsbigintThe value attached to the outgoing message, above forwardTonAmount.
jettonWalletstringThe payer's Jetton wallet for asset, raw (get_wallet_address on the master).
nownumberSeconds since the epoch.
requiredPaymentRequired-
seqnonumber-
stateInit?string | TonCellThe wallet's state init, for a wallet not yet deployed: a cell, or a base64 BoC of one root cell.
walletstringThe payer's W5 wallet, raw.
walletIdnumberget_subwallet_id.

TvmReader

Bounded, read-only calls against one network's TON Center v3 endpoint. Every failure rejects with ReaderError.

Properties

PropertyModifierType
networkreadonly`tvm:${number}`

Methods

byHash()

byHash(txHash): Promise<TonTx | null>

GET /api/v3/transactions?hash=…

Parameters
ParameterType
txHashstring
Returns

Promise<TonTx | null>

byInBody()

byInBody(bodyHash): Promise<readonly TonTx[]>

GET /api/v3/transactionsByMessage?body_hash=…&direction=in

Parameters
ParameterType
bodyHash`0x${string}`
Returns

Promise<readonly TonTx[]>

byInMessage()

byInMessage(msgHash): Promise<readonly TonTx[]>

GET /api/v3/transactionsByMessage?msg_hash=…&direction=in

Parameters
ParameterType
msgHashstring
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

PropertyType
jettonWalletstring
network`tvm:${number}`
transferBodyHash`0x${string}`
validUntilnumber

TvmUnsigned

Properties

PropertyTypeDescription
requestobjectThe 32-byte representation hash of the W5 request the wallet key signs.
request.hashUint8Array-
request.kind"ton-w5"-

Methods

complete()

complete(signature): Refusal | TvmPayment

Takes the 64-byte Ed25519 signature.

Parameters
ParameterType
signatureUint8Array
Returns

Refusal | TvmPayment

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

const exactTvm: 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: readonly PaymentRequirements[]; request: RequestCommitment; }]; txId: (tx) => string; unplaced: (option) => PaymentRequirements; }>


OP

const OP: object

Type Declaration

NameTypeDefault value
internalSigned19362893960x73696e74
internalTransfer3951342330x178d4519
jettonTransfer2607346290x0f8a7ea5
sendMsg2477118530x0ec3c86d

Functions

lcpComment()

lcpComment(h): Refusal | TonCell

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

ParameterType
h`0x${string}`

Returns

Refusal | TonCell


pairingOf()

pairingOf(option): "x402/exact/tvm" | undefined

This pairing's id for an option it can pay, or undefined.

Parameters

ParameterType
optionPaymentRequirements

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

ParameterType
settlementBocstring

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

ParameterType
ref{ network: `tvm:${number}`; transaction: string; }
ref.network`tvm:${number}`
ref.transactionstring
readerTvmReader

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

ParameterType
refTvmRef
readerTvmReader

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

ParameterType
txstring

Returns

string

Last updated on

On this page