Skip to content
Integra Protocol
API

@integraledger/lcp/cardano

The exports of @integraledger/lcp/cardano.

Interfaces

CardanoOnChain

Properties

PropertyTypeDescription
blockHeightbigint-
cbor?Uint8Array<ArrayBufferLike>The transaction as included, when asked for.
slotbigint-
validbooleandb-sync's tx.valid_contract.

CardanoPayload

The payload x402's Cardano scheme defines.

Properties

PropertyType
noncestring
transactionstring

CardanoPaymentPayload

Properties

PropertyType
acceptedPaymentRequirements
extensions?object
payloadCardanoPayload
resource?object
resource.urlstring
x402Version2

CardanoReader

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

Properties

PropertyModifierType
networkreadonlyCardanoNetwork

Methods

tip()

tip(): Promise<{ blockHeight: bigint; slot: bigint; }>

Returns

Promise<{ blockHeight: bigint; slot: bigint; }>

transaction()

transaction(txId, withCbor): Promise<CardanoOnChain | null>

Parameters
ParameterType
txId`0x${string}`
withCborboolean
Returns

Promise<CardanoOnChain | null>


CardanoRef

Properties

PropertyTypeDescription
networkCardanoNetwork-
ttlSlotstringThe last slot the transaction can land in, as a decimal string.
txId`0x${string}`-

CardanoTx

Properties

PropertyType
h`0x${string}` | Refusal
ttlSlotbigint | null
txId`0x${string}`

CardanoUnsigned

Properties

PropertyType
requestobject
request.acceptedPaymentRequirements
request.auxiliaryDataUint8Array
request.kind"cardano-transaction"

Methods

complete()

complete(signed): Promise<Refusal | CardanoPaymentPayload>

Parameters
ParameterType
signedCardanoPayload
Returns

Promise<Refusal | CardanoPaymentPayload>

Type Aliases

CardanoNetwork

CardanoNetwork = "cardano:mainnet" | "cardano:preprod" | "cardano:preview"


CardanoStatus

CardanoStatus = { blockHeight: bigint; confirmations: bigint; state: "settled"; } | { state: "pending"; why: "not-found" | "unreadable"; } | { state: "failed"; why: "phase-2-invalid" | "expired"; }

Variables

exactCardano

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


LCP_MARKER

const LCP_MARKER: "lcp:sha256:0x" = "lcp:sha256:0x"

CIP-20 line 1 of the carrier; line 2 is the hash's 64 lowercase hex digits.

Functions

auxiliaryData()

auxiliaryData(h): Uint8Array<ArrayBufferLike> | Refusal

The exact auxiliary data the payer attaches: #6.259({0: {674: {"msg": [LCP_MARKER, <64 hex>]}}}). A value that is not a 32-byte hash is x402/payload-malformed.

Parameters

ParameterType
h`0x${string}`

Returns

Uint8Array<ArrayBufferLike> | Refusal


cardanoOptionCheck()

cardanoOptionCheck(option): Refusal | undefined

The pairing's filter: undefined for an option this pairing can pay, or the refusal naming why not.

Parameters

ParameterType
optionunknown

Returns

Refusal | undefined


cardanoPairingOf()

cardanoPairingOf(option): "x402/exact/cardano" | undefined

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

Parameters

ParameterType
optionPaymentRequirements

Returns

"x402/exact/cardano" | undefined


cardanoRecover()

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

Reads the hash back from the included transaction alone, by its id. One call.

Parameters

ParameterType
ref{ network: CardanoNetwork; txId: `0x${string}`; }
ref.networkCardanoNetwork
ref.txId`0x${string}`
readerCardanoReader

Returns

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


cardanoStatus()

cardanoStatus(ref, reader): Promise<CardanoStatus>

Reads the recorded id. A failed read, or a reader for another network, is pending. An absent transaction is expired once the tip's slot is past its TTL; a present one fails only when the ledger marks it invalid. Two calls.

Parameters

ParameterType
refCardanoRef
readerCardanoReader

Returns

Promise<CardanoStatus>


decodeCardanoTx()

decodeCardanoTx(base64): Promise<Refusal | CardanoTx>

Decodes a base64 transaction [body, witness set, bool, auxiliary data / nil], keeping each item's bytes as received. The id is the Blake2b-256 of the body's bytes; the auxiliary data must hash to the body's key 7.

Parameters

ParameterType
base64string

Returns

Promise<Refusal | CardanoTx>

Last updated on

On this page