Skip to content
Integra Protocol
API

@integraledger/lcp/tron

Tron: the pairing `x402/exact/tron/lcp-trc20-memo`, whose payer-signed TRC-20 transfer carries the ATR hash as its memo, `raw_data.data`, in LCP string form, and the transaction pieces it uses.

For AI agents: this page as Markdown, and llms.txt, the index of every page.

Tron: the pairing x402/exact/tron/lcp-trc20-memo, whose payer-signed TRC-20 transfer carries the ATR hash as its memo, raw_data.data, in LCP string form, and the transaction pieces it uses.

The pieces are protobuf for the fields the profile uses, base58check addresses and the transaction id. Settlement is read by transaction id through a bounded reader.

Interfaces

TronBlock

A block as getblockbylimitnext and getblockbynum give it: its blockID, the number and parentHash of its header's raw_data, and the raw_data_hex of each of its transactions, in order (java-tron at 4e8389f1, framework/src/main/java/org/tron/core/services/http/Util.java:137-148, :295-298).

Properties

PropertyType
blockId`0x${string}`
numberbigint
parentHash`0x${string}`
transactionsreadonly string[]

TronChoice

Properties

PropertyTypeDescription
acceptedPaymentRequirements-
feeLimitbigintIn sun, from 1 to 15,000,000,000.
nowbigintMilliseconds since the epoch.
payerstringThe payer's base58check address.
refBlockobjectA recent block from the buyer's FullNode.
refBlock.id`0x${string}`-
refBlock.numberbigint-
requiredPaymentRequired-

TronCursor

The search's position: the last block it linked, by its number and blockID, at or below the solidified head. A pending answer returns it, and the next call takes it as query.search and reads on from the block after it.

Properties

PropertyModifierType
blockIdreadonly`0x${string}`
numberreadonlybigint

TronInfo

Properties

PropertyTypeDescription
blockNumberbigint-
logsreadonly object[]address is 20-byte hex as the node returns it; data, where given, the log's data in hex.
resultstringreceipt.result as the node returns it: "SUCCESS", "REVERT", …

TronNow

A node's latest block at a level, as its getnowblock names it: its number, its blockID and its time in ms.

Properties

PropertyType
blockId`0x${string}`
numberbigint
timestampbigint

TronRaw

The Transaction.raw fields this profile uses. B is what its bytes are backed by: decodeTronTx gives TronRaw<ArrayBuffer>, each byte field in its own fresh ArrayBuffer, and encodeTronRaw and tronCarrier take any backing.

Type Parameters

Type ParameterDefault type
B extends ArrayBufferLikeArrayBufferLike

Properties

PropertyType
callDataUint8Array<B>
contractAddressUint8Array<B>
dataUint8Array<B>
expirationbigint
feeLimitbigint
ownerUint8Array<B>
refBlockBytesUint8Array<B>
refBlockHashUint8Array<B>
timestampbigint

TronReader

Bounded, read-only calls against one network's FullNode: its /walletsolidity API for solidified data and its /wallet API at the head. Every failure rejects, for example with ReaderError from @integraledger/lcp/evm, and reads as unreadable transport; a rejection whose kind is too-large, as ReaderError carries it, is an answer over the reader's byte bound.

Properties

PropertyModifierTypeDescription
archival?readonlybooleanDeclared by the caller where its node holds the chain's whole history, so that with no position given absence can be read; absent, it is not declared.
networkreadonly`tron:${number}`-

Methods

block()

block(num, level): Promise<{ block: TronBlock | null; head: bigint | null; }>

getblockbynum at the level: the block, or null for the node's {}; and head, as blocks gives it.

Parameters
ParameterType
numbigint
levelTronLevel
Returns

Promise<{ block: TronBlock | null; head: bigint | null; }>

blocks()

blocks(start, end, level): Promise<{ blocks: readonly TronBlock[]; head: bigint | null; }>

getblockbylimitnext under /walletsolidity ("solid") or /wallet ("head"): the blocks from start up to end, not including it, at most 100, in the order the node gives them, none for its {}; and head, the number of that node's latest block at that level, read from that same node before the call, or null where the reader cannot.

Parameters
ParameterType
startbigint
endbigint
levelTronLevel
Returns

Promise<{ blocks: readonly TronBlock[]; head: bigint | null; }>

info()

info(txid, level): Promise<TronInfo | { notFound: true; timestamp: bigint | null; }>

/walletsolidity/gettransactioninfobyid ("solid") or /wallet/gettransactioninfobyid ("head"). When the node does not know the transaction, notFound with timestamp: the time in milliseconds of the latest block at that level on the node that answered (/walletsolidity/getnowblock or /wallet/getnowblock), read from that same node before the lookup, or null when the reader cannot read it from that node. A lookup naming no time never reads failed.

Parameters
ParameterType
txid`0x${string}`
levelTronLevel
Returns

Promise<TronInfo | { notFound: true; timestamp: bigint | null; }>

now()

now(level): Promise<TronNow>

/walletsolidity/getnowblock ("solid") or /wallet/getnowblock ("head"): the latest block at that level.

Parameters
ParameterType
levelTronLevel
Returns

Promise<TronNow>

transaction()

transaction(txid): Promise<{ rawDataHex: string; } | null>

/walletsolidity/gettransactionbyid; null: none.

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

Promise<{ rawDataHex: string; } | null>


TronRef

The read keys reference returns, JSON-serialisable. raw is the raw_data the owner signed, lowercase hex, which is the payment presented; txid its SHA-256, the single-use value; asset the contract's 21-byte address; expiration decimal milliseconds; payer the transaction's owner in base58check, read from the signed bytes; and payee the payTo of the option the payment answers, the key of the two party tests and no search key.

Properties

PropertyType
asset`0x${string}`
expirationstring
network`tron:${number}`
payeestring
payerstring
rawstring
txid`0x${string}`

TronUnsigned

Properties

PropertyTypeDescription
requestobjectWhat the payer signs. rawBytes is the transaction's raw_data, Transaction.raw as encodeTronRaw writes it; txid is its SHA-256, the 32-byte transaction id. tronRequest reads them.
request.kind"tron-txid"-
request.rawBytesUint8Array<ArrayBuffer>-
request.txidUint8Array<ArrayBuffer>-

Methods

complete()

complete(signature): Refusal | TronPayment

Takes the 65-byte secp256k1 signature r ‖ s ‖ v, v in {0, 1, 27, 28}.

Parameters
ParameterType
signatureUint8Array
Returns

Refusal | TronPayment

Type Aliases

TronLevel

TronLevel = "solid" | "head"

The level a read goes through: the full node's /walletsolidity API ("solid") or its /wallet API ("head").


TronMark

TronMark = "head" | "solidified"


TronNetwork

TronNetwork = `tron:${number}`

CAIP-2 with the decimal chain id: tron:728126428 mainnet, tron:3448148188 Nile, tron:2494104990 Shasta.


TronQuery

TronQuery = StatusQuery<TronRef, bigint, TronMark, TronCursor>

The query tronStatus takes: the profile read-status's, its search position a TronCursor.


TronStatus

TronStatus = StatusAnswer<bigint, TronMark, TronCursor>

The answer of tronStatus, as the profile read-status gives it. Its marks are head and solidified, in that order, its position the block number and its search position a TronCursor. A settled answer states presented: yes where the settled transaction's id is the reference's, the id being the SHA-256 of the raw_data the owner signed, and no otherwise; its signer is the transaction's owner in base58check, and its authority the contract's Permission_id, as Permission_id 0, 0 where the transaction names none.

Variables

exactTronMemo

const exactTronMemo: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<Refusal | `0x${string}`>; broadcaster: (presented) => Promise<Refusal | Broadcaster>; build: (c, h) => Promise<Refusal | TronUnsigned>; claims: boolean; data: PairingData; id: "x402/exact/tron/lcp-trc20-memo"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (input, reader) => Promise<Refusal | `0x${string}`>; reference: (presented, option) => Promise<Refusal | TronRef>; status: (ref, reader, query) => Promise<TronStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment | ToolCallCommitment; }]; unplaced: (option) => Refusal | PaymentRequirements; }>

x402/exact/tron/lcp-trc20-memo. The payee broadcasts (broadcaster answers "payee"): the seller's facilitator broadcasts the TRC-20 transfer the payer signed; status reads it by transaction id.


LCP_TRC20_MEMO

const LCP_TRC20_MEMO: "lcp-trc20-memo" = "lcp-trc20-memo"


TRANSFER_SELECTOR

const TRANSFER_SELECTOR: "a9059cbb" = "a9059cbb"

transfer(address,uint256)


TRANSFER_TOPIC

const TRANSFER_TOPIC: "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" = "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"

keccak256("Transfer(address,address,uint256)")


TRIGGER_SMART_CONTRACT

const TRIGGER_SMART_CONTRACT: 31 = 31


TRIGGER_URL

const TRIGGER_URL: "type.googleapis.com/protocol.TriggerSmartContract" = "type.googleapis.com/protocol.TriggerSmartContract"


TRON_BOUNDS

const TRON_BOUNDS: Readonly<{ callData: 68; feeLimit: 15000000000; maxTimeoutSeconds: 86340; rangeBlocks: 100; searchBlocks: 200; signatureBytes: 65; signatures: 5; transactionHex: 8192; }>

The pairing's bounds, each the chain's, the profile's or lcp's own resource bound, with its reason. transactionHex: lcp's bound on a signed transaction's hex digits, which the profile's transaction fits many times over and which bounds what is decoded. signatures: lcp's bound on the signatures decoded, enough for an owner's permission of five keys. signatureBytes: a secp256k1 signature r ‖ s ‖ v. callData: transfer(address,uint256), its selector and two 32-byte words. feeLimit: the network's largest fee_limit in sun. maxTimeoutSeconds: the profile's, which keeps a signed expiration within the node's 24-hour cap. rangeBlocks: the node's own bound on a range of getblockbylimitnext (java-tron at 4e8389f1, GetBlockByLimitNextServlet.java:18). searchBlocks: lcp's resource bound, the blocks one call of tronStatus reads of its search, two full ranges, so that each call's reads are bounded; the next call takes the search's position.

Functions

decodeTronTx()

decodeTronTx(hex): Refusal | { raw: TronRaw<ArrayBuffer>; rawBytes: Uint8Array<ArrayBuffer>; signatures: Uint8Array<ArrayBuffer>[]; }

Decodes a signed Transaction from lowercase hex: raw_data with exactly one TriggerSmartContract and only the fields TronRaw names, and 1 to 5 signatures of 65 bytes. The raw bytes must be exactly what encodeTronRaw writes for the fields read.

Parameters

ParameterType
hexstring

Returns

Refusal | { raw: TronRaw<ArrayBuffer>; rawBytes: Uint8Array<ArrayBuffer>; signatures: Uint8Array<ArrayBuffer>[]; }


encodeTronRaw()

encodeTronRaw(r): Uint8Array<ArrayBuffer>

Transaction.raw as java-tron serialises it: fields in ascending order, default values omitted. Throws TypeError when r is not an object, a bytes field is not a Uint8Array, or expiration, timestamp or feeLimit is not a bigint from 0 below 2^63, the values decodeTronTx reads back.

Parameters

ParameterType
rTronRaw

Returns

Uint8Array<ArrayBuffer>


tronAddress()

tronAddress(address): Promise<Uint8Array<ArrayBuffer> | Refusal>

Decodes a base58check address to its 21 bytes, which begin 0x41. The checksum is SHA-256 twice.

Parameters

ParameterType
addressstring

Returns

Promise<Uint8Array<ArrayBuffer> | Refusal>


tronCarrier()

tronCarrier(tx): Promise<Refusal | { h: `0x${string}`; txid: `0x${string}`; }>

The hash in the memo of a transaction whose one contract calls transfer, and the transaction id. A tx that is not decodeTronTx's { raw, rawBytes } is tron/tx-malformed.

Parameters

ParameterType
tx{ raw: TronRaw; rawBytes: Uint8Array; }
tx.rawTronRaw
tx.rawBytesUint8Array

Returns

Promise<Refusal | { h: `0x${string}`; txid: `0x${string}`; }>


tronRecover()

tronRecover(input, reader): Promise<Refusal | `0x${string}`>

Recovers the hash from the transaction id alone: the memo of the transaction whose raw bytes hash to the id. A ref whose txid is not a 32-byte hash is tron/wrong-reader, with nothing read. Raw data longer than the size bound decodeTronTx reads is tron/tx-too-large, the code that function gives such a transaction. Raw data whose SHA-256 is not the id is not the transaction it names, and is tron/unreadable, as a failed read is. The input's tx is the id, and its option the option the payment answers, an object, of which the read needs no member; an input whose tx is not a 32-byte hash, or whose option is not an object, is tron/wrong-reader, with nothing read. One call.

Parameters

ParameterType
inputRecoverInput<`tron:${number}`, PaymentRequirements | MppChallenge>
readerTronReader

Returns

Promise<Refusal | `0x${string}`>


tronRequest()

tronRequest(rawBytes): Promise<Refusal | { amount: string; asset: string; h: `0x${string}`; payer: string; payTo: string; raw: TronRaw<ArrayBuffer>; txid: Uint8Array<ArrayBuffer>; }>

Reads the raw_data a tron-txid request carries, as decodeTronTx reads a signed transaction's and tronCarrier reads its call and memo, with their codes, and gives txid, its SHA-256, which is the request's txid when the bytes are its rawBytes. raw is every field the bytes hold, which are all the fields decodeTronTx admits: the reference block's bytes and hash, expiration and timestamp in milliseconds, the memo data, fee_limit in sun, and the one contract, a TriggerSmartContract with no call value from owner to contractAddress whose call data is transfer(address,uint256). Read from them: payer, the owner, and asset, the contract, in base58check; payTo, the transfer's recipient, its address word's last 20 bytes under 0x41, in base58check; amount, the transfer's value, in decimal; and h, the hash the memo carries. Bytes longer than the longest transaction decodeTronTx reads, 4,096 bytes, are tron/tx-too-large, and a value that is not a Uint8Array tron/tx-malformed.

Parameters

ParameterType
rawBytesUint8Array

Returns

Promise<Refusal | { amount: string; asset: string; h: `0x${string}`; payer: string; payTo: string; raw: TronRaw<ArrayBuffer>; txid: Uint8Array<ArrayBuffer>; }>


tronStatus()

tronStatus(ref, reader, query): Promise<TronStatus>

Answers the read of the act the query asks about as the profile read-status gives it, by the pairing's profile, rule 8. The single-use value is the transaction id, the SHA-256 of the raw_data the owner signed, which the reference holds whole as the payment presented. The read takes the latest solidified block first, then the transaction by id at the solidified level and at the head, each lookup naming its own node's latest block time. Found, the transaction consumed the id: it is the payer's act where its owner is the reference's payer and not the option's payee, it succeeded where its receipt's result is SUCCESS, and what it moved is each Transfer log of its receipt whose sender is the owner, named by the id and the log's place among the receipt's logs, or, where the receipt holds no Transfer log and its signed call is a transfer of zero, that call's transfer of zero to its to; on the act payment it is the payment only where one of those names payTo. Its owner is the answer's signer, and its Permission_id the answer's authority. Absent from both lookups, each lookup's node at or past the solidified head's time, and the node holding the block at the position the caller gave (or declared archival where it gave none), the id is unconsumed: before the lapse, two slots past expiration, instrument-live. Only a failed answer needs the search for H, which the read makes only then: it reads every block after the position given, or after the search position an earlier answer returned, up to the solidified head read first through /walletsolidity, then on to the full node's head under /wallet, at most TRON_BOUNDS.rangeBlocks a call and TRON_BOUNDS.searchBlocks a read, each block linked to the one before it by its parentHash. Each transaction whose data, field 10 of its raw_data, is H's LCP string, its hex digits in either case as bound reads it, is read by its id: one of the form whose owner is the payer and that meets the act's tests is the act asked about; any other is named as a foreign item where a reason holds. Until a run shows that a block's answer lists every transaction of its block, a search read whole proves no absence, so no failed but before-position is answered. A ref, a reader or a query that is not one, a ref whose raw does not hash to its txid, is not the form's or is not owned by its payer, or a search position that is not a TronCursor, is unreadable unparseable, with nothing read; a reader for another network chain-mismatch; a read that rejects transport; one block over the reader's byte bound too-large; and absence where the node does not hold the history history-gap.

Parameters

ParameterType
refTronRef
readerTronReader
queryTronQuery

Returns

Promise<TronStatus>

References

Broadcaster

Re-exports Broadcaster


TronPayment

Re-exports TronPayment


X402Payment

Re-exports X402Payment


X402Read

Re-exports X402Read

Last updated on

On this page