Skip to content
Integra Protocol
API

@integraledger/lcp/casper

The exports of @integraledger/lcp/casper.

Interfaces

CasperCall

One executed contract call, as the reader reports it.

Properties

PropertyType
argsobject
args.from?string
args.nonce?Uint8Array<ArrayBufferLike>
args.to?string
args.value?bigint
blockHeightbigint | null
entryPointstring | null
errorstring | null
executedboolean
packageHashstring | null

CasperChoice

Properties

PropertyType
acceptedPaymentRequirements
fromstring
nownumber
requiredPaymentRequired

CasperReader

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

Properties

PropertyModifierType
networkreadonly`casper:${string}`

Methods

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 recorded at claim.

Properties

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

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.


CasperPaymentPayload

CasperPaymentPayload = object

Properties

PropertyType
acceptedPaymentRequirements
extensions?PaymentRequired["extensions"]
payloadobject
payload.authorizationCasperAuthorization
payload.publicKeystring
payload.signaturestring
resource?PaymentRequired["resource"]
x402Version2

CasperStatus

CasperStatus = { blockHeight: bigint; finality: "finalized"; state: "settled"; } | { state: "pending"; why: "not-found" | "not-executed" | "unreadable"; } | { state: "failed"; why: "reverted" | "not-this-instrument"; }


PackageHash

PackageHash = string

64 hex digits, no prefix.

Variables

CASPER_DOMAIN_TYPEHASH

const CASPER_DOMAIN_TYPEHASH: "0xe20dd13933eeb9d6099b53d5ffd59cfd50fe774983038681a378371664fad4fb"

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


exactCasper

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

Functions

casperIdDigest()

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

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<`0x${string}` | Refusal>


casperOption()

casperOption(o): o is PaymentRequirements

The pairing's filter: an exact option on a casper: network that build can turn into typed data.

Parameters

ParameterType
ounknown

Returns

o is PaymentRequirements


casperRecover()

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

The hash from a settlement transaction alone: the nonce argument of the executed authorization call on asset.

Parameters

ParameterType
ref{ asset: string; network: `casper:${string}`; transaction: string; }
ref.assetstring
ref.network`casper:${string}`
ref.transactionstring
readerCasperReader

Returns

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


casperStatus()

casperStatus(ref, reader): Promise<CasperStatus>

Reads the named transaction. Settled, at the height of its block, when it executed without error as a call to ref.asset's transfer_with_authorization or receive_with_authorization whose nonce argument is h and whose from, to and value hash to ref.idDigest. A failed read, or a reader for another network, is pending.

Parameters

ParameterType
refCasperRef & object
readerCasperReader

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

Last updated on

On this page