Skip to content
Integra Protocol
API

@integraledger/lcp/ccd

The exports of @integraledger/lcp/ccd.

Interfaces

CcdChoice

Properties

PropertyType
acceptedPaymentRequirements
nownumber
requiredPaymentRequired

CcdReader

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

Properties

PropertyModifierType
networkreadonly`ccd:${string}`

Methods

item()

item(hash): Promise<CcdItem | null>

gRPC v2 GetBlockItemStatus; null when the node does not know the item.

Parameters
ParameterType
hashstring
Returns

Promise<CcdItem | null>


CcdRef

The read keys recorded at claim.

Properties

PropertyType
assetstring
idDigest`0x${string}`
network`ccd:${string}`
settleBynumber
transaction?string

CcdTransfer

Properties

PropertyType
amountbigint
kind"ccd" | "plt"
memoUint8Array<ArrayBufferLike> | null
receiverUint8Array
tokenId?string

CcdUnsigned

Properties

PropertyType
requestobject
request.amountstring
request.assetstring
request.expiresBynumber
request.kind"ccd-transfer"
request.memoUint8Array
request.network`ccd:${string}`
request.sponsorstring
request.toAddressstring

Methods

complete()

complete(signedTransaction): Refusal | CcdPaymentPayload

Takes the sender-signed V1 sponsored transaction in the SDK's signableToJSON form.

Parameters
ParameterType
signedTransactionJson
Returns

Refusal | CcdPaymentPayload

Type Aliases

CcdItem

CcdItem = { state: "received"; } | { state: "committed"; } | { sender: Uint8Array | null; state: "finalized"; success: boolean; transfers: readonly CcdTransfer[]; }


CcdNetwork

CcdNetwork = `ccd:${string}`

CAIP-2: ccd: and the first 32 lowercase hex digits of the genesis block hash.


CcdPaymentPayload

CcdPaymentPayload = object

Properties

PropertyType
acceptedPaymentRequirements
extensions?PaymentRequired["extensions"]
payloadobject
payload.signedTransactionobject
resource?PaymentRequired["resource"]
x402Version2

CcdStatus

CcdStatus = { finality: "finalized"; state: "settled"; } | { state: "pending"; why: "not-found" | "received" | "committed" | "unreadable"; } | { state: "failed"; why: "rejected" | "not-this-instrument"; }

Variables

exactCcd

const exactCcd: Readonly<{ advertise: X402Advertise; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (c, h) => Promise<Refusal | CcdUnsigned>; claims: boolean; id: "x402/exact/ccd"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (ref, reader) => Promise<`0x${string}` | Refusal>; reference: (presented) => Promise<Refusal | CcdRef>; status: (ref, reader) => Promise<CcdStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>

Functions

accountBytes()

accountBytes(address): Uint8Array<ArrayBufferLike> | Refusal

The 32 bytes of a base58check account address whose version byte is 1: its last four bytes are the first four of the double SHA-256 of the 33 before them.

Parameters

ParameterType
addressstring

Returns

Uint8Array<ArrayBufferLike> | Refusal


ccdIdDigest()

ccdIdDigest(sender, receiver, amount): Promise<`0x${string}` | Refusal>

SHA-256 over the 32 + 32 bytes of the two accounts and the amount as a 32-byte big-endian integer.

Parameters

ParameterType
senderUint8Array
receiverUint8Array
amountbigint

Returns

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


ccdMemo()

ccdMemo(h): Uint8Array

The CBOR text string of toLcpString(h): 78 4d and the 77 ASCII bytes.

Parameters

ParameterType
h`0x${string}`

Returns

Uint8Array


ccdOption()

ccdOption(o): o is PaymentRequirements

The pairing's filter: an exact option on a ccd: network, for CCD or a token symbol, whose payTo and extra.feePayer are base58check account addresses.

Parameters

ParameterType
ounknown

Returns

o is PaymentRequirements


ccdRecover()

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

The hash from a settlement block item alone: its one memo-carrying transfer's memo, through memoCarrier.

Parameters

ParameterType
ref{ network: `ccd:${string}`; transaction: string; }
ref.network`ccd:${string}`
ref.transactionstring
readerCcdReader

Returns

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


ccdStatus()

ccdStatus(ref, reader): Promise<CcdStatus>

Reads the named block item. Settled when it is finalized and successful, with exactly one transfer whose memo memoCarrier reads as ref.h (a PLT memo with tag 24 unwrapped) and whose sender, receiver and amount hash to ref.idDigest. Not final, unknown or unreadable is pending; a reader for another network is pending.

Parameters

ParameterType
refCcdRef & object
readerCcdReader

Returns

Promise<CcdStatus>


memoCarrier()

memoCarrier(memo): `0x${string}` | Refusal

The hash a memo carries: exactly one CBOR text string, nothing after it, whose bytes are ccdMemo of the hash it names (LCP's string form with lowercase hex, under the preferred two-byte head). bound, status and recover all read a memo through this one function.

Parameters

ParameterType
memoUint8Array

Returns

`0x${string}` | Refusal


pltMemo()

pltMemo(h): Uint8Array

CBOR tag 24 around a byte string holding ccdMemo(h): d8 18 58 4f and the 79 bytes.

Parameters

ParameterType
h`0x${string}`

Returns

Uint8Array

Last updated on

On this page