@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
| Property | Type | Description | Inherited from |
|---|---|---|---|
args | object | The 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 | - | - |
blockHeight | bigint | null | - | CasperCall.blockHeight |
entryPoint | string | null | - | CasperCall.entryPoint |
error | string | null | - | CasperCall.error |
executed | boolean | - | CasperCall.executed |
packageHash | string | null | - | CasperCall.packageHash |
transaction | string | - | - |
CasperBlockPage
One page of a block's executed transactions, in the block's order: next starts the next page, null at its end.
Properties
| Property | Type |
|---|---|
calls | readonly CasperBlockCall[] |
next | number | null |
CasperCall
One executed contract call, as the reader reports it.
Extended by
Properties
| Property | Type | Description |
|---|---|---|
args | object | The 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 | - |
blockHeight | bigint | null | - |
entryPoint | string | null | - |
error | string | null | - |
executed | boolean | - |
packageHash | string | null | - |
CasperChoice
Properties
| Property | Type |
|---|---|
accepted | PaymentRequirements |
from | string |
now | number |
required | PaymentRequired |
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
| Property | Modifier | Type |
|---|---|---|
block? | readonly | bigint |
found? | readonly | string |
next? | readonly | number |
unset? | readonly | bigint |
CasperHead
The newest block a node has executed, every block being final: its height and its own timestamp in Unix milliseconds.
Properties
| Property | Type |
|---|---|
height | bigint |
timestamp | bigint |
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
| Property | Modifier | Type |
|---|---|---|
network | readonly | `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
| Parameter | Type |
|---|---|
height | bigint |
start | number |
Returns
Promise<CasperBlockPage | null>
head()
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
| Parameter | Type |
|---|---|
asset | string |
from | string |
nonce | Uint8Array |
height | bigint |
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
| Parameter | Type |
|---|---|
hash | string |
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
| Property | Type |
|---|---|
asset | string |
from | string |
network | `casper:${string}` |
nonce | `0x${string}` |
payee | string |
presented | CasperAuthorization |
settleBy | number |
CasperUnsigned
Properties
| Property | Type |
|---|---|
request | object |
request.kind | "casper-eip712" |
request.typedData | Cep3009TypedData |
Methods
complete()
complete(
publicKey,signature):Refusal|CasperPaymentPayload
Both arguments are hex with a one-byte algorithm tag: 01 ed25519, 02 secp256k1.
Parameters
| Parameter | Type |
|---|---|
publicKey | string |
signature | string |
Returns
Refusal | CasperPaymentPayload
Cep3009TypedData
Properties
| Property | Type | Description |
|---|---|---|
domain | object | - |
domain.chain_name | `casper:${string}` | - |
domain.contract_package_hash | string | - |
domain.name | string | - |
domain.version | string | - |
message | object | - |
message.from | string | - |
message.nonce | string | 64 hex digits, no prefix. |
message.to | string | - |
message.validAfter | bigint | - |
message.validBefore | bigint | - |
message.value | bigint | - |
primaryType | "TransferWithAuthorization" | - |
types | object | - |
types.EIP712Domain | Field[] | - |
types.TransferWithAuthorization | Field[] | - |
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
| Property | Type |
|---|---|
from | string |
nonce | string |
to | string |
validAfter | string |
validBefore | string |
value | string |
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
| Name | Type |
|---|---|
h | AtrHash |
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
| Parameter | Type |
|---|---|
doc | PaymentRequired |
h | AtrHash |
link | string |
offer | PaymentRequirements |
agreementUrl? | string |
Returns
Variables
CASPER_DOMAIN_TYPEHASH
constCASPER_DOMAIN_TYPEHASH:"0xe20dd13933eeb9d6099b53d5ffd59cfd50fe774983038681a378371664fad4fb"
keccak256("EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash)")
CASPER_MAX_NAME_LENGTH
constCASPER_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
constCASPER_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
constCASPER_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
constCASPER_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
constCASPER_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
constCASPER_MAX_SIGNATURE_HEX:132=132
The longest tagged signature lcp reads, in hex digits: a one-byte tag and a 65-byte signature.
exactCasper
constexactCasper: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: readonlyPaymentRequirements[];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
| Parameter | Type |
|---|---|
from | string |
to | string |
value | bigint |
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
| Parameter | Type |
|---|---|
input | RecoverInput<`casper:${string}`, PaymentRequirements | MppChallenge> |
reader | CasperReader |
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
| Parameter | Type |
|---|---|
ref | CasperRefRead |
reader | CasperReader |
query | StatusQuery<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
| Parameter | Type |
|---|---|
a | { asset: string; from: string; name: string; network: `casper:${string}`; nonce: `0x${string}`; to: string; validBefore: bigint; value: string; version: string; } |
a.asset | string |
a.from | string |
a.name | string |
a.network | `casper:${string}` |
a.nonce | `0x${string}` |
a.to | string |
a.validBefore | bigint |
a.value | string |
a.version | string |
Returns
References
Broadcaster
Re-exports Broadcaster
CasperPaymentPayload
Re-exports CasperPaymentPayload
X402Read
Re-exports X402Read
Last updated on
@integraledger/lcp/cardano
Cardano, and its two pairings: `x402/exact/cardano`, x402's address-to-address method, and `x402/exact/cardano/lock`, its two lock methods (`masumi` and `script`). Each carries the ATR hash as a CIP-20 message that the payer's signed body commits to.
@integraledger/lcp/ccd
Concordium and the `x402/exact/ccd` pairing: the ATR hash in LCP's string form, as a CBOR text string, in the memo of the one transfer the sender signs; read back from the signed transaction, and read from the finalized transfer event.