Skip to content
Integra Protocol
API

@integraledger/lcp/stacks

The exports of @integraledger/lcp/stacks.

Interfaces

StacksLanded

A mined transaction as the Stacks Blockchain API reports it from the canonical chain. result is never read.

Properties

PropertyTypeDescription
blockHeightbigint-
call{ args: readonly `0x${string}`[]; contractId: string; functionName: string; } | nullThe contract call, with each argument's consensus serialization as 0x hex; null for any other payload.
minedtrue-
senderobject-
sender.addressstring-
sender.noncebigint-
status"success" | "abort_by_response" | "abort_by_post_condition" | "problematic_skipped"-

StacksMempool

An unmined transaction: pending, or one of the dropped_… states.

Properties

PropertyType
minedfalse
statusstring

StacksReader

Bounded reads of one network's Stacks Blockchain API. Any failure rejects with ReaderError.

Properties

PropertyModifierType
networkreadonly`stacks:${string}`

Methods

blockTenure()

blockTenure(height): Promise<bigint>

The tenure height of the block at height.

Parameters
ParameterType
heightbigint
Returns

Promise<bigint>

confirmedNonce()

confirmedNonce(principal): Promise<bigint | null>

The principal's last confirmed nonce, or null when it has none.

Parameters
ParameterType
principalstring
Returns

Promise<bigint | null>

tipTenure()

tipTenure(): Promise<bigint>

The tip's tenure height.

Returns

Promise<bigint>

transaction()

transaction(txid): Promise<StacksLanded | StacksMempool | null>

The transaction by its 0x-prefixed id, with its function arguments; null when the API does not know it.

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

Promise<StacksLanded | StacksMempool | null>


StacksRef

The read keys of a Stacks payment: its network, the token contract, the origin and its nonce as a decimal string, and the transaction id (absent for a sponsored transaction, whose id is fixed only by the sponsor's signature).

Properties

PropertyType
contractstring
network`stacks:${string}`
noncestring
originstring
transaction?`0x${string}`

Type Aliases

StacksNetwork

StacksNetwork = `stacks:${string}`

CAIP-2: stacks:1 (mainnet), stacks:2147483648 (testnet).


StacksStatus

StacksStatus = { blockHeight: bigint; finality: "block" | "bitcoin"; state: "settled"; } | { state: "pending"; why: "not-found" | "mempool" | "dropped" | "unreadable"; } | { blockHeight: bigint; finality: "block" | "bitcoin"; state: "failed"; why: "abort-by-response" | "abort-by-post-condition" | "skipped" | "not-this-instrument"; } | { finality: "block"; state: "failed"; why: "nonce-used"; }

Variables

MEMO_PREFIX

const MEMO_PREFIX: "0x0a0200000020" = "0x0a0200000020"

The Clarity serialization of (some <32-byte buffer>) before its bytes: 0x0a, 0x02, then the length 32.

Functions

memoArgument()

memoArgument(h): `0x${string}` | undefined

The memo argument's serialization for h: (some h) as a 32-byte buffer, lowercase.

Parameters

ParameterType
h`0x${string}`

Returns

`0x${string}` | undefined


memoHash()

memoHash(arg): `0x${string}` | null

H from a memo argument that is (some <32-byte buffer>), or null.

Parameters

ParameterType
argunknown

Returns

`0x${string}` | null


stacksRecover()

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

Zero-party: H from the fourth argument of a mined, successful call to the contract's transfer, in one reader call. A wrong reader is stacks/wrong-reader, a failed read stacks/unreadable, an unknown or unmined transaction stacks/not-found, any other status stacks/not-success, and no (some <32 bytes>) memo of that call stacks/no-memo.

Parameters

ParameterType
ref{ contract: string; network: `stacks:${string}`; transaction: `0x${string}`; }
ref.contractstring
ref.network`stacks:${string}`
ref.transaction`0x${string}`
readerStacksReader

Returns

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


stacksStatus()

stacksStatus(ref, reader): Promise<StacksStatus>

The payment's settlement, in at most three reader calls. A wrong reader, or a failed transaction or nonce read, is pending unreadable. A mined transaction must be the origin's at its nonce, calling the contract's transfer with (some H) as its fourth argument, else failed not-this-instrument; then the API's status decides. A mined transaction's answer, settled or failed, carries its finality: bitcoin once the tip's tenure height is at least the block's plus two, else block, and a failed tenure read counts as block. Unmined and dropped, or unknown, the origin's confirmed nonce at or above the transaction's is failed nonce-used, read at the API's tip: block.

Parameters

ParameterType
refStacksRef & object
readerStacksReader

Returns

Promise<StacksStatus>


stacksTxid()

stacksTxid(wire): `0x${string}`

SHA-512/256 of a transaction's whole consensus serialization, as 0x and lowercase hex.

Parameters

ParameterType
wireUint8Array

Returns

`0x${string}`

Last updated on

On this page