Skip to content
Integra Protocol
API

@integraledger/lcp/polkadot

The exports of @integraledger/lcp/polkadot.

Interfaces

PolkadotExtrinsic

Properties

PropertyType
atobject
at.hash`0x${string}`
at.heightbigint
eventsreadonly object[]
hash`0x${string}`
successboolean

PolkadotReader

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

Properties

PropertyModifierType
networkreadonlyPolkadotNetwork

Methods

extrinsic()

extrinsic(block, index): Promise<PolkadotExtrinsic | null>

GET /blocks/{block}/extrinsics/{index}; null when the block or extrinsic does not exist.

Parameters
ParameterType
blockbigint | `0x${string}`
indexnumber
Returns

Promise<PolkadotExtrinsic | null>

finalizedHeight()

finalizedHeight(): Promise<bigint>

GET /blocks/head/header → number: the most recently finalized height.

Returns

Promise<bigint>

rawExtrinsics()

rawExtrinsics(block): Promise<readonly `0x${string}`[] | null>

GET /blocks/{block}/extrinsics-raw; null when the block does not exist.

Parameters
ParameterType
blockbigint | `0x${string}`
Returns

Promise<readonly `0x${string}`[] | null>


PolkadotRef

The read keys recorded at claim, computed from the signed bytes.

Properties

PropertyType
assetIdnumber
extrinsicHash`0x${string}`
networkPolkadotNetwork

PolkadotUnsigned

The call the payer's signer wraps in an extrinsic, and how that extrinsic completes the payment.

Properties

PropertyType
requestobject
request.callUint8Array
request.kind"substrate-call"
request.networkPolkadotNetwork

Methods

complete()

complete(extrinsic): Refusal | PolkadotPaymentPayload

Parameters
ParameterType
extrinsicUint8Array
Returns

Refusal | PolkadotPaymentPayload


ProfileCall

Properties

PropertyType
amountbigint
assetIdnumber
destUint8Array
remarkUint8Array

Type Aliases

PolkadotNetwork

PolkadotNetwork = "polkadot:68d56f15f85d3136970ec16946040bc1" | "polkadot:67f9723393ef76214df0118c34bbbd3d"


PolkadotPayload

PolkadotPayload = object

The x402 payload: the signed extrinsic and its call, lowercase hex.

Properties

PropertyType
callHex
extrinsicHex

PolkadotPaymentPayload

PolkadotPaymentPayload = X402Payment<PolkadotPayload>


PolkadotStatus

PolkadotStatus = { finality: "finalized" | "head"; height: bigint; state: "settled"; transaction: string; } | { state: "pending"; why: "not-located" | "not-found" | "unreadable"; } | { finality: "finalized" | "head"; height: bigint; state: "failed"; transaction: string; why: "not-this-extrinsic" | "dispatch-failed" | "no-remark" | "no-transfer"; }

A settlement or failure names the timepoint it read, <block hash>-<index>: the one given, or the canonical one when the given block left the chain and the canonical block at that height holds the same extrinsic at that index. Pending not-located asks for the payment to be located from the claim position.

Variables

CALL

const CALL: Readonly<{ batchAll: readonly number[]; remarkWithEvent: readonly number[]; transferKeepAlive: readonly number[]; }>

Pallet and call indices, the same on both networks.


exactPolkadotRemark

const exactPolkadotRemark: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (c, h) => Promise<Refusal | PolkadotUnsigned>; carrier: null; claims: true; id: "x402/exact/polkadot/lcp-assets-remark"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (ref, reader) => Promise<`0x${string}` | Refusal>; reference: (presented) => Promise<Refusal | PolkadotRef>; status: (ref, reader) => Promise<PolkadotStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>


LCP_ASSETS_REMARK

const LCP_ASSETS_REMARK: "lcp-assets-remark" = "lcp-assets-remark"

The profile's assetTransferMethod.


POLKADOT_NETWORKS

const POLKADOT_NETWORKS: readonly PolkadotNetwork[]

Functions

decodeProfileCall()

decodeProfileCall(call): Refusal | ProfileCall

The profile's call, exactly, with canonical compacts and no trailing byte.

Parameters

ParameterType
callUint8Array

Returns

Refusal | ProfileCall


encodeProfileCall()

encodeProfileCall(c): Uint8Array

batch_all([transfer_keep_alive(assetId, Id(dest), amount), remark_with_event(remark)])

Parameters

ParameterType
cProfileCall

Returns

Uint8Array


extrinsicHash()

extrinsicHash(xt): `0x${string}`

BLAKE2b-256 of the extrinsic's bytes, its length prefix included.

Parameters

ParameterType
xtUint8Array

Returns

`0x${string}`


polkadotLocate()

polkadotLocate(ref, reader, from, to): Promise<string | Refusal | null>

Finds a payment nobody named, by hashing every extrinsic of each block from from to to (at most 256 blocks). The first match gives its timepoint; a block that does not exist ends the scan with null.

Parameters

ParameterType
refPolkadotRef
readerPolkadotReader
frombigint
tobigint

Returns

Promise<string | Refusal | null>


polkadotPairingOf()

polkadotPairingOf(o): "x402/exact/polkadot/lcp-assets-remark" | undefined

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

Parameters

ParameterType
oPaymentRequirements

Returns

"x402/exact/polkadot/lcp-assets-remark" | undefined


polkadotRecover()

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

The hash from the landed extrinsic alone, for anyone holding its timepoint: its raw bytes end with the remark call, and the chain's record of it has the same hash, dispatched, with the Remarked event. Two calls.

Parameters

ParameterType
ref{ network: PolkadotNetwork; transaction: string; }
ref.networkPolkadotNetwork
ref.transactionstring
readerPolkadotReader

Returns

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


polkadotStatus()

polkadotStatus(ref, reader): Promise<PolkadotStatus>

Reads the extrinsic at its timepoint <block hash>-<index>. It must have the recorded hash, have dispatched, and carry the Remarked event for this hash's remark and a Transferred event of the recorded asset. A settlement and a failure alike carry the finality of the read: finalized when the finalized chain holds that block, head when it is above the finalized height. When the finalized chain holds another block at that height, the extrinsic at the same index of the canonical block is read instead if its hash is the recorded one; otherwise the answer is pending not-located. A block the reader does not have is pending not-found. A failed read, a bare broadcast hash or a reader for another network is pending.

Parameters

ParameterType
refPolkadotRef & object
readerPolkadotReader

Returns

Promise<PolkadotStatus>


splitSigned()

splitSigned(xt): Refusal | { end: number; signer: Uint8Array; }

The preamble of a signed v4 extrinsic: the length prefix, 0x84, MultiAddress::Id and a MultiSignature. Gives the signer and the index after the signature; the extension bytes that follow are not decoded.

Parameters

ParameterType
xtUint8Array

Returns

Refusal | { end: number; signer: Uint8Array; }


ss58Decode()

ss58Decode(address): Uint8Array<ArrayBufferLike> | Refusal

A simple-format SS58 address: one prefix byte 0–63, a 32-byte account, and a two-byte checksum.

Parameters

ParameterType
addressstring

Returns

Uint8Array<ArrayBufferLike> | Refusal

Last updated on

On this page