Skip to content
Integra Protocol
API

@integraledger/lcp/avm

The exports of @integraledger/lcp/avm.

Interfaces

AvmParams

The buyer's read of algod GET /v2/transactions/params. genesisHash is its base64.

Properties

PropertyType
feePerBytebigint
firstValidbigint
genesisHashstring
genesisIdstring
minFeebigint

AvmPresented

The x402 payload on Algorand.

Properties

PropertyType
paymentGroupreadonly string[]
paymentIndexnumber

AvmReader

Bounded, read-only calls against one network's Indexer. Every failure rejects.

Properties

PropertyModifierType
networkreadonly`algorand:${string}`

Methods

search(txid): Promise<{ currentRound: bigint; found: { confirmedRound: bigint; note: Uint8Array; } | null; }>

GET /v2/transactions?txid=…

Parameters
ParameterType
txidstring
Returns

Promise<{ currentRound: bigint; found: { confirmedRound: bigint; note: Uint8Array; } | null; }>


AvmRef

The read keys recorded at claim, computed from the signed bytes. lastValid is a decimal string, so the issuer stores the reference as JSON.

Properties

PropertyType
lastValidstring
network`algorand:${string}`
txidstring

AvmUnsigned

The bytes the payer signs, and how the signature completes the payment.

Properties

PropertyTypeDescription
requestobject"TX" ‖ msgpack(txn)
request.bytesUint8Array-
request.kind"algorand-txn"-

Methods

complete()

complete(signature): Refusal | AvmPaymentPayload

A 64-byte Ed25519 signature.

Parameters
ParameterType
signatureUint8Array
Returns

Refusal | AvmPaymentPayload

Type Aliases

AlgorandNetwork

AlgorandNetwork = `algorand:${string}`

CAIP-2: the first 32 characters of the URL-safe base64 genesis hash.


AvmPaymentPayload

AvmPaymentPayload = X402Payment<AvmPresented>


AvmStatus

AvmStatus = { finality: "final"; round: bigint; state: "settled"; } | { state: "pending"; why: "not-found" | "unreadable"; } | { state: "failed"; why: "expired"; }

Variables

exactAvm

const exactAvm: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (c, h) => Promise<Refusal | AvmUnsigned>; carrier: null; claims: boolean; id: "x402/exact/algorand"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (ref, reader) => Promise<`0x${string}` | Refusal>; reference: (presented) => Promise<Refusal | AvmRef>; status: (ref, reader) => Promise<AvmStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>


MSGPACK_MAX_DEPTH

const MSGPACK_MAX_DEPTH: 32 = 32

The deepest nesting of msgpack arrays and maps in a signed transaction, the outermost container being level 1. An Algorand signed transaction nests three (the signed transaction, its transaction, and a map or array inside that).

Functions

avmCarrier()

avmCarrier(p): Refusal | { h: `0x${string}`; lastValid: bigint; txid: string; }

The payment transaction of an x402 Algorand payload: paymentGroup[paymentIndex], decoded as a signed asset transfer whose note is an LCP string. Gives the hash, the transaction id and the last valid round.

Parameters

ParameterType
pAvmPresented

Returns

Refusal | { h: `0x${string}`; lastValid: bigint; txid: string; }


avmPairingOf()

avmPairingOf(o): "x402/exact/algorand" | undefined

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

Parameters

ParameterType
oPaymentRequirements

Returns

"x402/exact/algorand" | undefined


avmRecover()

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

The hash from the landed payment's note, for anyone holding the transaction id. One call.

Parameters

ParameterType
ref{ network: `algorand:${string}`; txid: string; }
ref.network`algorand:${string}`
ref.txidstring
readerAvmReader

Returns

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


avmStatus()

avmStatus(ref, reader): Promise<AvmStatus>

Reads the payment by its id. Found is settled and final; absent after the last valid round is expired; otherwise pending. A failed read, or a reader for another network, is pending.

Parameters

ParameterType
refAvmRef
readerAvmReader

Returns

Promise<AvmStatus>


msgpackWithinCaps()

msgpackWithinCaps(b): boolean

True when b is exactly one msgpack value (the msgpack specification's formats) whose arrays and maps nest at most MSGPACK_MAX_DEPTH deep, and whose every declared length (a string's, binary's or extension's bytes, an array's elements, a map's keys and values) is no more than the bytes that remain, so no count is trusted past the input. The value is scanned, never built.

Parameters

ParameterType
bUint8Array

Returns

boolean

Last updated on

On this page