@integraledger/lcp/svm
The exports of @integraledger/lcp/svm.
Interfaces
ChannelBuildInput
Properties
ChannelIx
Properties
SvmBuildInput
Properties
| Property | Type |
|---|---|
amount | bigint |
computeUnitLimit | number |
computeUnitPrice | bigint |
decimals | number |
feePayer | string |
memo | string |
mint | string |
payer | string |
payTo | string |
recentBlockhash | string |
tokenProgram | string |
SvmLanded
A landed transaction as getTransaction returns it with encoding base64 and maxSupportedTransactionVersion 0.
Properties
SvmReader
Bounded, read-only calls against one network's endpoint. Every failure rejects with ReaderError.
Properties
Methods
blockhashValid()
blockhashValid(
blockhash):Promise<boolean>
isBlockhashValid at commitment confirmed.
Parameters
| Parameter | Type |
|---|---|
blockhash | string |
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<readonlyobject[]>
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
| Parameter | Type |
|---|---|
address | string |
page | { before?: string; limit: 1000; } |
page.before? | string |
page.limit | 1000 |
Returns
Promise<readonly object[]>
transaction()
transaction(
signature,commitment):Promise<SvmLanded|null>
getTransaction; null when none is found at that commitment.
Parameters
| Parameter | Type |
|---|---|
signature | string |
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
SvmTx
Properties
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
| Property | Type |
|---|---|
channel | string |
network | SolanaNetwork |
phase | "close" |
program | string |
transaction | string |
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
constATA_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
constCOMPUTE_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
constMEMO_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
constMEMO_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
constOPEN_DISCRIMINATOR:1=1
PAYMENT_CHANNELS
constPAYMENT_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
constRENT_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
constSEAL_DISCRIMINATOR:6=6
SETTLE_AND_SEAL_DISCRIMINATOR
constSETTLE_AND_SEAL_DISCRIMINATOR:4=4
SYSTEM
constSYSTEM:"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
constTOKEN:"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
constTOKEN_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
| Parameter | Type |
|---|---|
i | ChannelBuildInput |
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
| Parameter | Type |
|---|---|
i | SvmBuildInput |
Returns
Promise<Uint8Array<ArrayBufferLike> | Refusal>
channelInstruction()
The transaction's one top-level payment-channels instruction, by its discriminator.
Parameters
| Parameter | Type |
|---|---|
tx | SvmTx |
Returns
channelPda()
channelPda(
a):string|Refusal
The channel PDA: seeds "channel", payer, payee, mint, signer, u64le(salt), u64le(openSlot).
Parameters
| Parameter | Type |
|---|---|
a | { mint: string; openSlot: bigint; payee: string; payer: string; salt: bigint; signer: string; } |
a.mint | string |
a.openSlot | bigint |
a.payee | string |
a.payer | string |
a.salt | bigint |
a.signer | string |
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
| Parameter | Type |
|---|---|
channelId | string |
cumulative | bigint |
expiresAt | bigint |
Returns
Uint8Array
decodeSvmTx()
Decodes a legacy or v0 wire transaction of at most 1,232 bytes.
Parameters
| Parameter | Type |
|---|---|
wire | Uint8Array |
Returns
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
| Parameter | Type |
|---|---|
seeds | readonly Uint8Array<ArrayBufferLike>[] |
program | string |
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
| Parameter | Type |
|---|---|
a | { deposit: bigint; gracePeriod: number; openSlot: bigint; recipient: string; salt: bigint; } |
a.deposit | bigint |
a.gracePeriod | number |
a.openSlot | bigint |
a.recipient | string |
a.salt | bigint |
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
| Parameter | Type |
|---|---|
tx | SvmTx |
program | string |
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
| Parameter | Type |
|---|---|
p | { challengeId: string; channelId: string; payer: string; } |
p.challengeId | string |
p.channelId | string |
p.payer | string |
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
channelId | string |
cumulative | bigint |
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
| Parameter | Type |
|---|---|
tx | SvmTx |
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
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
| Parameter | Type |
|---|---|
ref | SvmCloseRef |
reader | SvmReader |
Returns
Promise<SvmCloseStatus>
svmDigest()
svmDigest(
tx):Promise<`0x${string}`>
SHA-256 over the message bytes every signer signed.
Parameters
| Parameter | Type |
|---|---|
tx | SvmTx |
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
| Parameter | Type | Default value |
|---|---|---|
ref | SvmRef | undefined |
reader | SvmReader | undefined |
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
| Parameter | Type |
|---|---|
ref | { network: `solana:${string}`; transaction: string; } |
ref.network | `solana:${string}` |
ref.transaction | string |
reader | SvmReader |
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
Returns
Promise<SvmStatus>
Last updated on