Skip to content
Integra Protocol
API

@integraledger/lcp/casper

CEP-3009 on Casper and the `x402/exact/casper` pairing: the ATR hash as the authorization's 32-byte `nonce`, written by the buyer's signer, read back from what the payer signed, and read from the executed call's arguments.

For AI agents: this page as Markdown, and llms.txt, the index of every page.

CEP-3009 on Casper and the x402/exact/casper pairing: the ATR hash as the authorization's 32-byte nonce, written by the buyer's signer, read back from what the payer signed, and read from the executed call's arguments.

Interfaces

CasperBlockCall

A call among a block's transactions, with the hash of the transaction that made it, 64 hex digits.

Extends

Properties

PropertyTypeDescriptionInherited from
argsobjectThe call's arguments as the token takes them: from is the authorization's from, or on cancel_authorization the authorizer whose nonce it cancels; validAfter and validBefore where the reader shows them.CasperCall.args
args.from?string--
args.nonce?Uint8Array<ArrayBufferLike>--
args.to?string--
args.validAfter?bigint--
args.validBefore?bigint--
args.value?bigint--
blockHeightbigint | null-CasperCall.blockHeight
entryPointstring | null-CasperCall.entryPoint
errorstring | null-CasperCall.error
executedboolean-CasperCall.executed
packageHashstring | null-CasperCall.packageHash
transactionstring--

CasperBlockPage

One page of a block's executed transactions, in the block's order: next starts the next page, null at its end.

Properties

PropertyType
callsreadonly CasperBlockCall[]
nextnumber | null

CasperCall

One executed contract call, as the reader reports it.

Extended by

Properties

PropertyTypeDescription
argsobjectThe call's arguments as the token takes them: from is the authorization's from, or on cancel_authorization the authorizer whose nonce it cancels; validAfter and validBefore where the reader shows them.
args.from?string-
args.nonce?Uint8Array<ArrayBufferLike>-
args.to?string-
args.validAfter?bigint-
args.validBefore?bigint-
args.value?bigint-
blockHeightbigint | null-
entryPointstring | null-
errorstring | null-
executedboolean-
packageHashstring | null-

CasperChoice

Properties

PropertyType
acceptedPaymentRequirements
fromstring
nownumber
requiredPaymentRequired

CasperCursor

The search's position: a height at which the item was read unset, above which the block that set it lies; or that block, the start of the next page of its transactions to read, and the transaction that set the item where an earlier page held it.

Properties

PropertyModifierType
block?readonlybigint
found?readonlystring
next?readonlynumber
unset?readonlybigint

CasperHead

The newest block a node has executed, every block being final: its height and its own timestamp in Unix milliseconds.

Properties

PropertyType
heightbigint
timestampbigint

CasperReader

Bounded, read-only calls against one network's node or its sidecar. Every failure rejects, for example with ReaderError from @integraledger/lcp/evm; any rejection reads as unreadable.

Properties

PropertyModifierType
networkreadonly`casper:${string}`

Methods

blockCalls()

blockCalls(height, start): Promise<CasperBlockPage | null>

The page of the executed transactions of the block at height that starts at start; null where the node does not serve the block.

Parameters
ParameterType
heightbigint
startnumber
Returns

Promise<CasperBlockPage | null>

head(): Promise<CasperHead>

The newest block the node has executed.

Returns

Promise<CasperHead>

lowest()

lowest(): Promise<bigint>

The lowest block height whose state the node serves, its available_block_range.low.

Returns

Promise<bigint>

nonceUsed()

nonceUsed(asset, from, nonce, height): Promise<boolean | null>

The item of (from, nonce) in asset's used_nonces dictionary, read with state_get_dictionary_item at the state root of the block at height: true where it is set, false where the node answers in the form it documents for a missing item, and null where the node does not serve that block's state.

Parameters
ParameterType
assetstring
fromstring
nonceUint8Array
heightbigint
Returns

Promise<boolean | null>

transaction()

transaction(hash): Promise<CasperCall | null>

info_get_transaction, as a Version1 transaction and then as a Deploy; null when the node knows neither.

Parameters
ParameterType
hashstring
Returns

Promise<CasperCall | null>


CasperRef

The read keys reference returns: the network, the token package, the authorization's from, the signed nonce (H on a payment, the agreement's value on an agreement), settleBy, which is validBefore up to Number.MAX_SAFE_INTEGER, the payee, the payTo of the option the payment answers, and the authorization as presented, for presented. Addresses and hashes are lowercase.

Properties

PropertyType
assetstring
fromstring
network`casper:${string}`
nonce`0x${string}`
payeestring
presentedCasperAuthorization
settleBynumber

CasperUnsigned

Properties

PropertyType
requestobject
request.kind"casper-eip712"
request.typedDataCep3009TypedData

Methods

complete()

complete(publicKey, signature): Refusal | CasperPaymentPayload

Both arguments are hex with a one-byte algorithm tag: 01 ed25519, 02 secp256k1.

Parameters
ParameterType
publicKeystring
signaturestring
Returns

Refusal | CasperPaymentPayload


Cep3009TypedData

Properties

PropertyTypeDescription
domainobject-
domain.chain_name`casper:${string}`-
domain.contract_package_hashstring-
domain.namestring-
domain.versionstring-
messageobject-
message.fromstring-
message.noncestring64 hex digits, no prefix.
message.tostring-
message.validAfterbigint-
message.validBeforebigint-
message.valuebigint-
primaryType"TransferWithAuthorization"-
typesobject-
types.EIP712DomainField[]-
types.TransferWithAuthorizationField[]-

Type Aliases

CasperAddress

CasperAddress = string

66 hex digits, no prefix: tag 00 (account hash) or 01 (package hash), then 32 bytes.


CasperAuthorization

CasperAuthorization = object

Properties

PropertyType
fromstring
noncestring
tostring
validAfterstring
validBeforestring
valuestring

CasperNetwork

CasperNetwork = `casper:${string}`

CAIP-2: casper: and the chainspec name.


CasperRefRead

CasperRefRead = CasperRef & object

The reference status reads with: the read keys, and H, which the caller adds, from which the other act's value comes.

Type Declaration

NameType
hAtrHash

CasperStatus

CasperStatus = StatusAnswer<bigint, "finalized", CasperCursor>

The answer of casperStatus: positions are block heights, and the one mark is finalized, since the node serves only executed transactions of final blocks; the search's position is a CasperCursor; presented on settled compares the executed call with the authorization as presented.


PackageHash

PackageHash = string

64 hex digits, no prefix.


X402Advertise

X402Advertise = (doc, h, link, offer, agreementUrl?) => PaymentRequired | Refusal

A pairing's advertise: the document with the legal context placed, and the agreement URL when one is given. A document, or an option in its accepts, that carries a refused member is x402/option-malformed.

Parameters

ParameterType
docPaymentRequired
hAtrHash
linkstring
offerPaymentRequirements
agreementUrl?string

Returns

PaymentRequired | Refusal

Variables

CASPER_DOMAIN_TYPEHASH

const CASPER_DOMAIN_TYPEHASH: "0xe20dd13933eeb9d6099b53d5ffd59cfd50fe774983038681a378371664fad4fb"

keccak256("EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash)")


CASPER_MAX_NAME_LENGTH

const CASPER_MAX_NAME_LENGTH: 64 = 64

The longest token name or version lcp reads from a Casper option, in characters. CEP-3009 fixes no length; lcp bounds what it hashes into the domain.


CASPER_MAX_PAGE_CALLS

const CASPER_MAX_PAGE_CALLS: 1024 = 1024

The most calls lcp reads on one page of a block's transactions, the reader's page being its own choice. A page that gives more is beyond the read's bound, unreadable, too-large.


CASPER_MAX_PAGES

const CASPER_MAX_PAGES: 8 = 8

The most pages of a block's transactions one status call reads. A block's size is the chain's; a search cut short returns its position, from which the next call resumes.


CASPER_MAX_PROBES

const CASPER_MAX_PROBES: 64 = 64

The most reads of the nonce's item one status call makes to find the block that set it: a bisection of 64-bit block heights ends within 64. A search cut short returns its position, from which the next call resumes.


CASPER_MAX_PUBLIC_KEY_HEX

const CASPER_MAX_PUBLIC_KEY_HEX: 68 = 68

The longest tagged public key lcp reads, in hex digits: a one-byte tag and a 33-byte secp256k1 key.


CASPER_MAX_SIGNATURE_HEX

const CASPER_MAX_SIGNATURE_HEX: 132 = 132

The longest tagged signature lcp reads, in hex digits: a one-byte tag and a 65-byte signature.


exactCasper

const exactCasper: Readonly<{ advertise: X402Advertise; bound: (presented, given?) => Promise<Refusal | `0x${string}`>; broadcaster: (presented) => Promise<Refusal | Broadcaster>; build: (c, h, act?) => Promise<Refusal | CasperUnsigned>; claims: boolean; data: PairingData; id: "x402/exact/casper"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; recover: (input, reader) => Promise<Refusal | `0x${string}`>; reference: (presented, option, given?) => Promise<Refusal | CasperRef>; status: (ref, reader, query) => Promise<CasperStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment | ToolCallCommitment; }]; unplaced: (option) => Refusal | PaymentRequirements; }>

x402/exact/casper. The payee broadcasts (broadcaster answers "payee"): the settler submits the call that executes the payer's signed authorization; status reads the nonce's item, the block that set it and its transactions.

Functions

casperIdDigest()

casperIdDigest(from, to, value): Promise<Refusal | `0x${string}`>

SHA-256 over the 33 + 33 bytes of the two addresses and the value as a 32-byte big-endian integer.

Parameters

ParameterType
fromstring
tostring
valuebigint

Returns

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


casperRecover()

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

The value a settlement transaction carries in H's place, from the transaction alone (profile rule 23): the nonce argument of the executed authorization call on the token package the option names, option.asset, which is H on a payment and the agreement's value on an agreement, which a holder of the ATR compares with agreementValue of its own H. An input whose tx is not 64 hex digits, or whose option names no package hash of 64 hex digits as its asset, is casper/wrong-reader, with nothing read.

Parameters

ParameterType
inputRecoverInput<`casper:${string}`, PaymentRequirements | MppChallenge>
readerCasperReader

Returns

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


casperStatus()

casperStatus(ref, reader, query): Promise<CasperStatus>

The read of the act the query asks about, as the profile read-status answers it through the profile x402/exact/casper's rules 12 to 22: the nonce's item, the block that set it and its transactions. A query, a reference or a search position that is not one, a reference without the authorization as presented among them, is unreadable, unparseable, with nothing read, and a reader for another network chain-mismatch; a read the node does not serve is history-gap. On settled the answer states presented, the executed call compared with the authorization as presented.

Parameters

ParameterType
refCasperRefRead
readerCasperReader
queryStatusQuery<CasperRefRead, bigint, "finalized", CasperCursor>

Returns

Promise<CasperStatus>


cep3009TypedData()

cep3009TypedData(a): Refusal | Cep3009TypedData

The CEP-3009 typed data for TransferWithAuthorization, with validAfter 0 and the hash as the nonce.

Parameters

ParameterType
a{ asset: string; from: string; name: string; network: `casper:${string}`; nonce: `0x${string}`; to: string; validBefore: bigint; value: string; version: string; }
a.assetstring
a.fromstring
a.namestring
a.network`casper:${string}`
a.nonce`0x${string}`
a.tostring
a.validBeforebigint
a.valuestring
a.versionstring

Returns

Refusal | Cep3009TypedData

References

Broadcaster

Re-exports Broadcaster


CasperPaymentPayload

Re-exports CasperPaymentPayload


X402Read

Re-exports X402Read

Last updated on

On this page