Skip to content
Integra Protocol
API

@integraledger/lcp/starknet

The exports of @integraledger/lcp/starknet.

Interfaces

Field

Properties

PropertyType
namestring
typestring

OutsideExecutionTypedData

SNIP-12 revision 1, SNIP-9 v2, as x402's Starknet scheme prints it.

Properties

PropertyType
domainobject
domain.chainId`0x${string}`
domain.name"Account.execute_from_outside"
domain.revision1
domain.version2
messageobject
message.Caller`0x${string}`
message.Calls[{ Calldata: [`0x${string}`, `0x${string}`, `0x${string}`]; Selector: "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"; To: `0x${string}`; }]
message.Execute After"1"
message.Execute Beforestring
message.Nonce`0x${string}`
primaryType"OutsideExecution"
typesobject
types.CallField[]
types.OutsideExecutionField[]
types.StarknetDomainField[]

StarknetInvocation

Properties

PropertyType
calldatareadonly `0x${string}`[]
callsreadonly StarknetInvocation[]
contract`0x${string}`
revertedboolean
selector`0x${string}`

StarknetReader

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

Properties

PropertyModifierType
networkreadonlyStarknetNetwork

Methods

receipt()

receipt(tx): Promise<StarknetReceipt | null>

starknet_getTransactionReceipt; null: unknown hash.

Parameters
ParameterType
tx`0x${string}`
Returns

Promise<StarknetReceipt | null>

trace()

trace(tx): Promise<StarknetInvocation | null>

starknet_traceTransaction's execute_invocation; null: none.

Parameters
ParameterType
tx`0x${string}`
Returns

Promise<StarknetInvocation | null>


StarknetReceipt

Properties

PropertyType
blockNumberbigint | null
execution"SUCCEEDED" | "REVERTED"
finality"PRE_CONFIRMED" | "ACCEPTED_ON_L2" | "ACCEPTED_ON_L1"

StarknetRef

The read keys recorded at claim; transaction is added when the facilitator names it.

Properties

PropertyTypeDescription
asset`0x${string}`-
from`0x${string}`The payer's account: the contract whose outside-execution nonce is nonce.
idDigest`0x${string}`-
networkStarknetNetwork-
nonce`0x${string}`-
settleBynumber-
transaction?`0x${string}`-

StarknetUnsigned

Properties

PropertyTypeDescription
requestobjectThe typed data the account's key signs; SNIP-12 hashes the account in.
request.account`0x${string}`-
request.kind"starknet-snip12"-
request.typedDataOutsideExecutionTypedData-

Methods

complete()

complete(signature): Refusal | StarknetPayment

Takes the signature as 1 to 32 felts.

Parameters
ParameterType
signaturereadonly `0x${string}`[]
Returns

Refusal | StarknetPayment

Type Aliases

Felt

Felt = `0x${string}`

Lowercase 0x hex with no leading zero digit, below FELT_P.


StarknetNetwork

StarknetNetwork = "starknet:SN_MAIN" | "starknet:SN_SEPOLIA"


StarknetPayment

StarknetPayment = X402Payment<{ from: Felt; outsideExecution: { signature: readonly Felt[]; typedData: OutsideExecutionTypedData; }; }>


StarknetStatus

StarknetStatus = { blockNumber: bigint; finality: "ACCEPTED_ON_L2" | "ACCEPTED_ON_L1"; state: "settled"; } | { state: "pending"; why: "not-found" | "pre-confirmed" | "unreadable"; } | { state: "failed"; why: "reverted" | "not-this-instrument"; }

Variables

ANY_CALLER

const ANY_CALLER: "0x414e595f43414c4c4552" = "0x414e595f43414c4c4552"

The SNIP-9 any-caller sentinel, the short string ANY_CALLER.


exactStarknet

const exactStarknet: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (c, h) => Promise<Refusal | StarknetUnsigned>; claims: boolean; id: "x402/exact/starknet"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; reference: (presented) => Promise<Refusal | StarknetRef>; status: (ref, reader) => Promise<StarknetStatus>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>


FELT_P

const FELT_P: bigint


MASK_250

const MASK_250: bigint


SELECTOR_EXECUTE_FROM_OUTSIDE_V2

const SELECTOR_EXECUTE_FROM_OUTSIDE_V2: "0x34cc13b274446654ca3233ed2c1620d4c5d1d32fd20b47146a3371064bdc57d" = "0x34cc13b274446654ca3233ed2c1620d4c5d1d32fd20b47146a3371064bdc57d"

sn_keccak("execute_from_outside_v2")


SELECTOR_TRANSFER

const SELECTOR_TRANSFER: "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e" = "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"

sn_keccak("transfer")

Functions

chainIdFelt()

chainIdFelt(n): `0x${string}`

The network's reference as a short-string felt.

Parameters

ParameterType
nStarknetNetwork

Returns

`0x${string}`


outsideExecution()

outsideExecution(a): Refusal | OutsideExecutionTypedData

x402's OutsideExecution for one transfer(payTo, amount) on asset, with the fee payer as Caller.

Parameters

ParameterType
a{ amount: bigint; asset: `0x${string}`; executeBefore: number; feePayer: `0x${string}`; network: StarknetNetwork; nonce: `0x${string}`; payTo: `0x${string}`; }
a.amountbigint
a.asset`0x${string}`
a.executeBeforenumber
a.feePayer`0x${string}`
a.networkStarknetNetwork
a.nonce`0x${string}`
a.payTo`0x${string}`

Returns

Refusal | OutsideExecutionTypedData


pairingOf()

pairingOf(option): "x402/exact/starknet" | undefined

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

Parameters

ParameterType
optionPaymentRequirements

Returns

"x402/exact/starknet" | undefined


snNonce()

snNonce(h): `0x${string}` | Refusal

The hash's low 250 bits as a felt: the way Starknet fits a 256-bit hash into a felt. A value that is not a 32-byte hash is x402/payload-malformed.

Parameters

ParameterType
h`0x${string}`

Returns

`0x${string}` | Refusal


starknetIdDigest()

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

the core's hash over from, to and amount as three 32-byte big-endian words: the identity of one transfer.

Parameters

ParameterType
from`0x${string}`
to`0x${string}`
amountbigint

Returns

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


starknetLandedNonce()

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

The nonce that landed in the named transaction for this transfer, for a party holding the ATR to compare with the hash's low 250 bits. It is found by the transfer's identity on ref.asset, not by the recorded nonce.

Parameters

ParameterType
refStarknetRef & object
readerStarknetReader

Returns

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


starknetStatus()

starknetStatus(ref, reader): Promise<StarknetStatus>

Reads the named transaction's receipt, then walks its trace for exactly one non-reverted execute_from_outside_v2 whose calldata carries this nonce and whose direct, non-reverted call is transfer on ref.asset with this transfer's identity. A failed read, or a reader for another network, is pending. Two calls.

Parameters

ParameterType
refStarknetRef & object
readerStarknetReader

Returns

Promise<StarknetStatus>

Last updated on

On this page