# @integraledger/lcp/avm

> The exports of @integraledger/lcp/avm.

Source: https://lcp.integraledger.com/reference/api/avm

## Interfaces

### AvmParams

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

#### Properties

| Property       | Type     |
| -------------- | -------- |
|  `feePerByte`  | `bigint` |
|  `firstValid`  | `bigint` |
|  `genesisHash` | `string` |
|  `genesisId`   | `string` |
|  `minFee`      | `bigint` |

***

### AvmPresented

The x402 payload on Algorand.

#### Properties

| Property        | Type                 |
| --------------- | -------------------- |
|  `paymentGroup` | readonly `string`\[] |
|  `paymentIndex` | `number`             |

***

### AvmReader

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

#### Properties

| Property   | Modifier   | Type                       |
| ---------- | ---------- | -------------------------- |
|  `network` | `readonly` | `` `algorand:${string}` `` |

#### Methods

##### search()

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

`GET /v2/transactions?txid=…`

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `txid`    | `string` |

###### 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

| Property     | Type                       |
| ------------ | -------------------------- |
|  `lastValid` | `string`                   |
|  `network`   | `` `algorand:${string}` `` |
|  `txid`      | `string`                   |

***

### AvmUnsigned

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

#### Properties

| Property        | Type             | Description         |
| --------------- | ---------------- | ------------------- |
|  `request`      | `object`         | "TX" ‖ msgpack(txn) |
| `request.bytes` | `Uint8Array`     | -                   |
| `request.kind`  | `"algorand-txn"` | -                   |

#### Methods

##### complete()

> **complete**(`signature`): [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`AvmPaymentPayload`](#avmpaymentpayload)

A 64-byte Ed25519 signature.

###### Parameters

| Parameter   | Type         |
| ----------- | ------------ |
| `signature` | `Uint8Array` |

###### Returns

[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`AvmPaymentPayload`](#avmpaymentpayload)

## Type Aliases

### AlgorandNetwork

> **AlgorandNetwork** = `` `algorand:${string}` ``

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

***

### AvmPaymentPayload

> **AvmPaymentPayload** = [`X402Payment`](https://lcp.integraledger.com/reference/api/x402#x402payment)\<[`AvmPresented`](#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`](https://lcp.integraledger.com/reference/api#refusal) | [`PaymentRequired`](https://lcp.integraledger.com/reference/api/x402#paymentrequired); `bound`: (`presented`) => `Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>; `build`: (`c`, `h`) => `Promise`\<[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`AvmUnsigned`](#avmunsigned)>; `carrier`: `null`; `claims`: `boolean`; `id`: `"x402/exact/algorand"`; `pattern`: [`LcpPattern`](https://lcp.integraledger.com/reference/api/x402#lcppattern); `read`: (`doc`) => [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`X402Read`](https://lcp.integraledger.com/reference/api/x402#x402read); `recover`: (`ref`, `reader`) => `Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>; `reference`: (`presented`) => `Promise`\<[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`AvmRef`](#avmref)>; `status`: (`ref`, `reader`) => `Promise`\<[`AvmStatus`](#avmstatus)>; `tie`: (`accepts`, `request`) => \[`"x402"`, \{ `accepts`: readonly [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements)\[]; `request`: [`RequestCommitment`](https://lcp.integraledger.com/reference/api/x402#requestcommitment); }]; `unplaced`: (`option`) => [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#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`](https://lcp.integraledger.com/reference/api#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

| Parameter | Type                            |
| --------- | ------------------------------- |
| `p`       | [`AvmPresented`](#avmpresented) |

#### Returns

[`Refusal`](https://lcp.integraledger.com/reference/api#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

| Parameter | Type                                                             |
| --------- | ---------------------------------------------------------------- |
| `o`       | [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements) |

#### Returns

`"x402/exact/algorand"` | `undefined`

***

### avmRecover()

> **avmRecover**(`ref`, `reader`): `Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>

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

#### Parameters

| Parameter     | Type                                                          |
| ------------- | ------------------------------------------------------------- |
| `ref`         | \{ `network`: `` `algorand:${string}` ``; `txid`: `string`; } |
| `ref.network` | `` `algorand:${string}` ``                                    |
| `ref.txid`    | `string`                                                      |
| `reader`      | [`AvmReader`](#avmreader)                                     |

#### Returns

`Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>

***

### avmStatus()

> **avmStatus**(`ref`, `reader`): `Promise`\<[`AvmStatus`](#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

| Parameter | Type                      |
| --------- | ------------------------- |
| `ref`     | [`AvmRef`](#avmref)       |
| `reader`  | [`AvmReader`](#avmreader) |

#### Returns

`Promise`\<[`AvmStatus`](#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

| Parameter | Type         |
| --------- | ------------ |
| `b`       | `Uint8Array` |

#### Returns

`boolean`
