@integraledger/lcp/tron
The exports of @integraledger/lcp/tron.
Interfaces
TronChoice
Properties
| Property | Type | Description |
|---|---|---|
accepted | PaymentRequirements | - |
feeLimit | bigint | In sun, from 1 to 15,000,000,000. |
now | bigint | Milliseconds since the epoch. |
payer | string | The payer's base58check address. |
refBlock | object | A recent block from the buyer's FullNode. |
refBlock.id | `0x${string}` | - |
refBlock.number | bigint | - |
required | PaymentRequired | - |
TronInfo
Properties
| Property | Type | Description |
|---|---|---|
blockNumber | bigint | - |
logs | readonly object[] | address is 20-byte hex as the node returns it. |
result | string | receipt.result as the node returns it: "SUCCESS", "REVERT", … |
TronRaw
The Transaction.raw fields this profile uses.
Properties
| Property | Type |
|---|---|
callData | Uint8Array |
contractAddress | Uint8Array |
data | Uint8Array |
expiration | bigint |
feeLimit | bigint |
owner | Uint8Array |
refBlockBytes | Uint8Array |
refBlockHash | Uint8Array |
timestamp | bigint |
TronReader
Bounded, read-only calls against one network's FullNode and SolidityNode. Every failure rejects with ReaderError.
Properties
Methods
info()
info(
txid,level):Promise<TronInfo|null>
/walletsolidity/gettransactioninfobyid ("solid") or /wallet/gettransactioninfobyid ("head"); null: none.
Parameters
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
TronUnsigned
Properties
| Property | Type | Description |
|---|---|---|
request | object | The 32-byte transaction id the payer signs. |
request.kind | "tron-txid" | - |
request.txid | Uint8Array | - |
Methods
complete()
complete(
signature):Refusal|TronPayment
Takes the 65-byte secp256k1 signature r ‖ s ‖ v, v in {0, 1, 27, 28}.
Parameters
| Parameter | Type |
|---|---|
signature | Uint8Array |
Returns
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
constexactTronMemo: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: readonlyPaymentRequirements[];request:RequestCommitment; }];txId: (tx) =>string;unplaced: (option) =>PaymentRequirements; }>
LCP_TRC20_MEMO
constLCP_TRC20_MEMO:"lcp-trc20-memo"="lcp-trc20-memo"
TRANSFER_SELECTOR
constTRANSFER_SELECTOR:"a9059cbb"="a9059cbb"
transfer(address,uint256)
TRANSFER_TOPIC
constTRANSFER_TOPIC:"ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"="ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
keccak256("Transfer(address,address,uint256)")
TRIGGER_SMART_CONTRACT
constTRIGGER_SMART_CONTRACT:31=31
TRIGGER_URL
constTRIGGER_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
| Parameter | Type |
|---|---|
hex | string |
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
| Parameter | Type |
|---|---|
r | TronRaw |
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
| Parameter | Type |
|---|---|
option | PaymentRequirements |
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
| Parameter | Type |
|---|---|
address | string |
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
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
| Parameter | Type |
|---|---|
ref | { network: `tron:${number}`; txid: `0x${string}`; } |
ref.network | `tron:${number}` |
ref.txid | `0x${string}` |
reader | TronReader |
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
| Parameter | Type |
|---|---|
ref | TronRef |
reader | TronReader |
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
| Parameter | Type |
|---|---|
tx | string |
Returns
string
Last updated on