Skip to content
Integra Protocol
API

@integraledger/lcp/svm

The exports of @integraledger/lcp/svm.

Interfaces

ChannelBuildInput

Properties

PropertyTypeDescription
computeUnitLimitnumber-
computeUnitPricebigint-
feePayerstring-
instruction{ channel: string; deposit: bigint; gracePeriod: number; kind: "open"; openSlot: bigint; recipient: string; salt: bigint; signer: string; } | { amount: bigint; channel: string; kind: "top_up"; } | { channel: string; kind: "request_close"; }-
memo?stringThe one Memo v3 instruction's text; absent, the message carries no memo.
mintstring-
payerstring-
recentBlockhashstring-
tokenProgramstring-

ChannelIx

Properties

PropertyType
channelstring
dataUint8Array
kind"open" | "top_up" | "request_close"

SvmBuildInput

Properties

PropertyType
amountbigint
computeUnitLimitnumber
computeUnitPricebigint
decimalsnumber
feePayerstring
memostring
mintstring
payerstring
payTostring
recentBlockhashstring
tokenProgramstring

SvmLanded

A landed transaction as getTransaction returns it with encoding base64 and maxSupportedTransactionVersion 0.

Properties

PropertyTypeDescription
errunknown-
innerreadonly object[]meta.innerInstructions, flattened; program indexes the static keys, then loaded.writable, then loaded.readonly.
loadedobject-
loaded.readonlyreadonly Uint8Array<ArrayBufferLike>[]-
loaded.writablereadonly Uint8Array<ArrayBufferLike>[]-
wireUint8Array-

SvmReader

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

Properties

PropertyModifierType
networkreadonly`solana:${string}`

Methods

blockhashValid()

blockhashValid(blockhash): Promise<boolean>

isBlockhashValid at commitment confirmed.

Parameters
ParameterType
blockhashstring
Returns

Promise<boolean>

firstAvailableBlock()

firstAvailableBlock(): Promise<bigint>

getFirstAvailableBlock: the lowest slot whose block the node still holds.

Returns

Promise<bigint>

signatures()

signatures(address, page): Promise<readonly object[]>

getSignaturesForAddress, newest first. memo is the RPC's rendering of the transaction's memos ([len] text, joined by ; ), or null when it has none.

Parameters
ParameterType
addressstring
page{ before?: string; limit: 1000; }
page.before?string
page.limit1000
Returns

Promise<readonly object[]>

transaction()

transaction(signature, commitment): Promise<SvmLanded | null>

getTransaction; null when none is found at that commitment.

Parameters
ParameterType
signaturestring
commitment"finalized" | "confirmed"
Returns

Promise<SvmLanded | null>


SvmRef

The read keys recorded at claim. blockhash is empty for a durable-nonce transaction, which never expires.

Properties

PropertyTypeDescription
blockhashstring-
channel?stringThe channel account the transaction creates, for an opening that carries no memo: the search pages this address's signatures instead of the fee payer's, and reads each one as a candidate.
digest`0x${string}`-
feePayerstring-
fromSlotstringThe slot read at claim, as a decimal string.
network`solana:${string}`-
transaction?string-

SvmTx

Properties

PropertyTypeDescription
blockhashUint8Array-
instructionsreadonly SvmInstruction[]-
keysreadonly Uint8Array<ArrayBufferLike>[]The static account keys, in order.
messageUint8ArrayExactly the bytes every signer signed.
signaturesreadonly Uint8Array<ArrayBufferLike>[]-

Type Aliases

ChannelStatus

ChannelStatus = SvmStatus | { state: "failed"; why: "no-channel-instruction"; }


SolanaNetwork

SolanaNetwork = `solana:${string}`

CAIP-2: solana: and 32 base58 characters.


SvmCloseRef

SvmCloseRef = object

Properties

PropertyType
channelstring
networkSolanaNetwork
phase"close"
programstring
transactionstring

SvmCloseStatus

SvmCloseStatus = { commitment: "confirmed" | "finalized"; state: "settled"; } | { state: "pending"; why: "not-found" | "unreadable"; } | { state: "failed"; why: "err" | "not-a-close"; }


SvmStatus

SvmStatus = { commitment: "confirmed" | "finalized"; state: "settled"; } | { state: "pending"; why: "not-found" | "unreadable"; } | { state: "failed"; why: "err" | "not-this-instrument" | "no-transfer"; }

Variables

ATA_PROGRAM

const ATA_PROGRAM: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


COMPUTE_BUDGET

const COMPUTE_BUDGET: "ComputeBudget111111111111111111111111111111" = "ComputeBudget111111111111111111111111111111"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


MEMO_V3

const MEMO_V3: "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


MEMO_V4

const MEMO_V4: "Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH" = "Memo4c2pN8afCj432Lb7RMVKi9PbQnnW7ewFFaV3oAH"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


OPEN_DISCRIMINATOR

const OPEN_DISCRIMINATOR: 1 = 1


PAYMENT_CHANNELS

const PAYMENT_CHANNELS: "CHNLxYvVA28MJP9PrFuDXccuoGXAx7jBacfLEkahyGsX" = "CHNLxYvVA28MJP9PrFuDXccuoGXAx7jBacfLEkahyGsX"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


RENT_SYSVAR

const RENT_SYSVAR: "SysvarRent111111111111111111111111111111111" = "SysvarRent111111111111111111111111111111111"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


SEAL_DISCRIMINATOR

const SEAL_DISCRIMINATOR: 6 = 6


SETTLE_AND_SEAL_DISCRIMINATOR

const SETTLE_AND_SEAL_DISCRIMINATOR: 4 = 4


SYSTEM

const SYSTEM: "11111111111111111111111111111111" = "11111111111111111111111111111111"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


TOKEN

const TOKEN: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.


TOKEN_2022

const TOKEN_2022: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"

Solana rail pieces: the wire transaction, its one Memo instruction carrying the ATR hash in LCP string form, the digest of the message the payer signed, and settlement read through a bounded reader.

Functions

buildChannelMessage()

buildChannelMessage(i): Promise<Uint8Array<ArrayBufferLike> | Refusal>

The v0 message for a channel instruction: SetComputeUnitLimit, SetComputeUnitPrice, the payment-channels instruction with its accounts in the program's order, then one v3 Memo instruction when memo is given. The fee payer is also the open's rent payer and payee.

Parameters

ParameterType
iChannelBuildInput

Returns

Promise<Uint8Array<ArrayBufferLike> | Refusal>


buildSvmMessage()

buildSvmMessage(i): Promise<Uint8Array<ArrayBufferLike> | Refusal>

The versioned (v0) message bytes for a token payment: SetComputeUnitLimit, SetComputeUnitPrice, TransferChecked from the payer's associated token account to the payee's, then one v3 Memo instruction whose data is the memo's UTF-8 bytes. No lookup tables.

Parameters

ParameterType
iSvmBuildInput

Returns

Promise<Uint8Array<ArrayBufferLike> | Refusal>


channelInstruction()

channelInstruction(tx): Refusal | ChannelIx

The transaction's one top-level payment-channels instruction, by its discriminator.

Parameters

ParameterType
txSvmTx

Returns

Refusal | ChannelIx


channelPda()

channelPda(a): string | Refusal

The channel PDA: seeds "channel", payer, payee, mint, signer, u64le(salt), u64le(openSlot).

Parameters

ParameterType
a{ mint: string; openSlot: bigint; payee: string; payer: string; salt: bigint; signer: string; }
a.mintstring
a.openSlotbigint
a.payeestring
a.payerstring
a.saltbigint
a.signerstring

Returns

string | Refusal


channelVoucherMessage()

channelVoucherMessage(channelId, cumulative, expiresAt): Uint8Array

The 50 bytes a channel voucher signs: 56 01 ‖ channelId ‖ cumulative u64 LE ‖ expiresAt i64 LE. Throws TypeError when the channel id is not a base58 key or a number is out of range.

Parameters

ParameterType
channelIdstring
cumulativebigint
expiresAtbigint

Returns

Uint8Array


decodeSvmTx()

decodeSvmTx(wire): Refusal | SvmTx

Decodes a legacy or v0 wire transaction of at most 1,232 bytes.

Parameters

ParameterType
wireUint8Array

Returns

Refusal | SvmTx


findPda()

findPda(seeds, program): Refusal | { address: string; bump: number; }

The program-derived address of seeds under program: for bumps 255 down to 0, the first SHA-256(seeds ‖ bump ‖ program ‖ "ProgramDerivedAddress") that does not decompress to an Ed25519 point.

Parameters

ParameterType
seedsreadonly Uint8Array<ArrayBufferLike>[]
programstring

Returns

Refusal | { address: string; bump: number; }


openInstructionData()

openInstructionData(a): Uint8Array

The open instruction's data: 01 ‖ salt u64 ‖ deposit u64 ‖ gracePeriod u32 ‖ openSlot u64 ‖ one recipient (01000000 ‖ recipient ‖ bps 10 000 as u16), little-endian. 67 bytes. Throws TypeError on a value out of range.

Parameters

ParameterType
a{ deposit: bigint; gracePeriod: number; openSlot: bigint; recipient: string; salt: bigint; }
a.depositbigint
a.gracePeriodnumber
a.openSlotbigint
a.recipientstring
a.saltbigint

Returns

Uint8Array


openOf()

openOf(tx, program): Refusal | { channel: string; salt: bigint; }

The one top-level instruction of program whose data starts with OPEN_DISCRIMINATOR, with at least 33 bytes of data and 6 accounts: its salt (data bytes 1–8, little-endian) and its channel (account 5). Else svm/open-not-found.

Parameters

ParameterType
txSvmTx
programstring

Returns

Refusal | { channel: string; salt: bigint; }


sessionProof()

sessionProof(p): Uint8Array

The UTF-8 of the core's canonicalJson of {channelId, domain: "mpp-session-auth-v1", payer, sessionChallengeId}.

Parameters

ParameterType
p{ challengeId: string; channelId: string; payer: string; }
p.challengeIdstring
p.channelIdstring
p.payerstring

Returns

Uint8Array


sessionSalt()

sessionSalt(h): bigint

H's first 8 bytes read as a little-endian u64, so the salt's encoded bytes are exactly those 8 bytes.

Parameters

ParameterType
h`0x${string}`

Returns

bigint


solanaVoucher()

solanaVoucher(channelId, cumulative, expiresAt?): Uint8Array<ArrayBufferLike> | Refusal

The 50 bytes a voucher signs: 56 01 ‖ channel id ‖ cumulative u64 LE ‖ expiresAt i64 LE (0 when absent). A malformed channel id or an out-of-range number is svm/input-malformed.

Parameters

ParameterType
channelIdstring
cumulativebigint
expiresAt?bigint

Returns

Uint8Array<ArrayBufferLike> | Refusal


svmCarrier()

svmCarrier(tx): Refusal | { h: `0x${string}`; memo: string; }

The one top-level Memo instruction (v3 or v4) and the ATR hash its UTF-8 data carries in LCP string form. None, or more than one, is svm/memo-count.

Parameters

ParameterType
txSvmTx

Returns

Refusal | { h: `0x${string}`; memo: string; }


svmChannelStatus()

svmChannelStatus(ref, reader): Promise<ChannelStatus>

svmStatus with the presence test replaced: exactly one top-level payment-channels instruction whose discriminator is open (1) or top_up (3). At most two calls.

Parameters

ParameterType
refSvmRef & object
readerSvmReader

Returns

Promise<ChannelStatus>


svmCloseStatus()

svmCloseStatus(ref, reader): Promise<SvmCloseStatus>

Reads a reported close at finalized, then confirmed: a top-level instruction of program whose data byte 0 is settleAndSeal (channel at account 1) or seal (channel at account 0) naming the channel is settled; any other landed transaction is failed not-a-close. At most two calls.

Parameters

ParameterType
refSvmCloseRef
readerSvmReader

Returns

Promise<SvmCloseStatus>


svmDigest()

svmDigest(tx): Promise<`0x${string}`>

SHA-256 over the message bytes every signer signed.

Parameters

ParameterType
txSvmTx

Returns

Promise<`0x${string}`>


svmLocate()

svmLocate(ref, reader, h, status?): Promise<{ complete: boolean; found?: string; }>

Finds the instrument when no transaction was named: pages the fee payer's signatures, newest first, down to fromSlot, at most 10 pages of 1,000. A signature is a candidate only when its memo carries h in LCP string form. With channel in the reference, it pages that account's signatures instead, and every signature is a candidate. Each candidate is read through status, the pairing's own (svmStatus when none is given), at most 50 per pass. complete is true only when the node's first available block is at or before fromSlot, the pages reached fromSlot within those bounds, and every candidate was read: a listed candidate whose transaction reads pending leaves the search incomplete.

Parameters

ParameterTypeDefault value
refSvmRefundefined
readerSvmReaderundefined
h`0x${string}`undefined
status(ref, reader) => Promise<{ state: string; why?: string; }>svmStatus

Returns

Promise<{ complete: boolean; found?: string; }>


svmRecover()

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

Zero-party recovery: the ATR hash in the landed transaction's one memo. One or two calls.

Parameters

ParameterType
ref{ network: `solana:${string}`; transaction: string; }
ref.network`solana:${string}`
ref.transactionstring
readerSvmReader

Returns

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


svmStatus()

svmStatus(ref, reader): Promise<SvmStatus>

Reads a named transaction's settlement. It must be the message the payer signed (by digest), must have executed without error, and must carry a token or SOL transfer. A failed read, or a reader for another network, is pending. At most two calls.

Parameters

ParameterType
refSvmRef & object
readerSvmReader

Returns

Promise<SvmStatus>

Last updated on

On this page