Skip to content
Integra Protocol
API

@integraledger/lcp/tron

The exports of @integraledger/lcp/tron.

Interfaces

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-

TronInfo

Properties

PropertyTypeDescription
blockNumberbigint-
logsreadonly object[]address is 20-byte hex as the node returns it.
resultstringreceipt.result as the node returns it: "SUCCESS", "REVERT", …

TronRaw

The Transaction.raw fields this profile uses.

Properties

PropertyType
callDataUint8Array
contractAddressUint8Array
dataUint8Array
expirationbigint
feeLimitbigint
ownerUint8Array
refBlockBytesUint8Array
refBlockHashUint8Array
timestampbigint

TronReader

Bounded, read-only calls against one network's FullNode and SolidityNode. Every failure rejects with ReaderError.

Properties

PropertyModifierType
networkreadonly`tron:${number}`

Methods

info()

info(txid, level): Promise<TronInfo | null>

/walletsolidity/gettransactioninfobyid ("solid") or /wallet/gettransactioninfobyid ("head"); null: none.

Parameters
ParameterType
txid`0x${string}`
level"head" | "solid"
Returns

Promise<TronInfo | null>

solidHead()

solidHead(): Promise<{ number: bigint; timestamp: bigint; }>

/walletsolidity/getnowblock: the latest solidified block's number and time in milliseconds.

Returns

Promise<{ number: bigint; timestamp: bigint; }>

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 recorded at claim, JSON-serialisable. asset is the contract's 21-byte address; expiration is decimal milliseconds.

Properties

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

TronUnsigned

Properties

PropertyTypeDescription
requestobjectThe 32-byte transaction id the payer signs.
request.kind"tron-txid"-
request.txidUint8Array-

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

TronNetwork

TronNetwork = `tron:${number}`

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


TronPayment

TronPayment = X402Payment<{ transaction: string; }>


TronStatus

TronStatus = { blockNumber: bigint; finality: "solidified" | "head"; state: "settled"; } | { state: "pending"; why: "not-found" | "unreadable"; } | { result?: string; state: "failed"; why: "contract-failed" | "no-transfer" | "expired"; }

Variables

exactTronMemo

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


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"

Functions

decodeTronTx()

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

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; rawBytes: Uint8Array; signatures: Uint8Array<ArrayBufferLike>[]; }


encodeTronRaw()

encodeTronRaw(r): Uint8Array

Transaction.raw as java-tron serialises it: fields in ascending order, default values omitted.

Parameters

ParameterType
rTronRaw

Returns

Uint8Array


pairingOf()

pairingOf(option): "x402/exact/tron/lcp-trc20-memo" | undefined

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

Parameters

ParameterType
optionPaymentRequirements

Returns

"x402/exact/tron/lcp-trc20-memo" | undefined


tronAddress()

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

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

Parameters

ParameterType
addressstring

Returns

Promise<Uint8Array<ArrayBufferLike> | 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.

Parameters

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

Returns

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


tronRecover()

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

Recovers the hash from the transaction id alone: the memo of the transaction whose raw bytes hash to the id. One call.

Parameters

ParameterType
ref{ network: `tron:${number}`; txid: `0x${string}`; }
ref.network`tron:${number}`
ref.txid`0x${string}`
readerTronReader

Returns

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


tronStatus()

tronStatus(ref, reader): Promise<TronStatus>

Reads the transaction by id: at the Solidity node first, then at the FullNode's head. Settled when its receipt result is SUCCESS and it holds a Transfer log from ref.asset. Failed as expired only when the latest solidified block is two slots past the expiration and no node holds it. A failed read, or a reader for another network, is pending. At most three calls.

Parameters

ParameterType
refTronRef
readerTronReader

Returns

Promise<TronStatus>


tronTxId()

tronTxId(tx): string

A Tron transaction id in one spelling: lowercase hex without 0x, the SHA-256 of raw_data as the node's txID gives it, whether it is given with or without 0x and in either case. Any other string is returned unchanged.

Parameters

ParameterType
txstring

Returns

string

Last updated on

On this page