@integraledger/lcp/cardano
The exports of @integraledger/lcp/cardano.
Interfaces
CardanoOnChain
Properties
| Property | Type | Description |
|---|---|---|
blockHeight | bigint | - |
cbor? | Uint8Array<ArrayBufferLike> | The transaction as included, when asked for. |
slot | bigint | - |
valid | boolean | db-sync's tx.valid_contract. |
CardanoPayload
The payload x402's Cardano scheme defines.
Properties
CardanoPaymentPayload
Properties
| Property | Type |
|---|---|
accepted | PaymentRequirements |
extensions? | object |
payload | CardanoPayload |
resource? | object |
resource.url | string |
x402Version | 2 |
CardanoReader
Bounded, read-only calls against one network's indexer. Every failure rejects with ReaderError.
Properties
| Property | Modifier | Type |
|---|---|---|
network | readonly | CardanoNetwork |
Methods
tip()
tip():
Promise<{blockHeight:bigint;slot:bigint; }>
Returns
Promise<{ blockHeight: bigint; slot: bigint; }>
transaction()
transaction(
txId,withCbor):Promise<CardanoOnChain|null>
Parameters
| Parameter | Type |
|---|---|
txId | `0x${string}` |
withCbor | boolean |
Returns
Promise<CardanoOnChain | null>
CardanoRef
Properties
| Property | Type | Description |
|---|---|---|
network | CardanoNetwork | - |
ttlSlot | string | The last slot the transaction can land in, as a decimal string. |
txId | `0x${string}` | - |
CardanoTx
Properties
| Property | Type |
|---|---|
h | `0x${string}` | Refusal |
ttlSlot | bigint | null |
txId | `0x${string}` |
CardanoUnsigned
Properties
| Property | Type |
|---|---|
request | object |
request.accepted | PaymentRequirements |
request.auxiliaryData | Uint8Array |
request.kind | "cardano-transaction" |
Methods
complete()
complete(
signed):Promise<Refusal|CardanoPaymentPayload>
Parameters
| Parameter | Type |
|---|---|
signed | CardanoPayload |
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
constexactCardano: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: readonlyPaymentRequirements[];request:RequestCommitment; }];unplaced: (option) =>PaymentRequirements; }>
LCP_MARKER
constLCP_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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
option | unknown |
Returns
Refusal | undefined
cardanoPairingOf()
cardanoPairingOf(
option):"x402/exact/cardano"|undefined
This pairing's id for an option it can pay, or undefined.
Parameters
| Parameter | Type |
|---|---|
option | PaymentRequirements |
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
| Parameter | Type |
|---|---|
ref | { network: CardanoNetwork; txId: `0x${string}`; } |
ref.network | CardanoNetwork |
ref.txId | `0x${string}` |
reader | CardanoReader |
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
| Parameter | Type |
|---|---|
ref | CardanoRef |
reader | CardanoReader |
Returns
Promise<CardanoStatus>
decodeCardanoTx()
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
| Parameter | Type |
|---|---|
base64 | string |
Returns
Last updated on