@integraledger/lcp/starknet
The exports of @integraledger/lcp/starknet.
Interfaces
Field
Properties
OutsideExecutionTypedData
SNIP-12 revision 1, SNIP-9 v2, as x402's Starknet scheme prints it.
Properties
| Property | Type |
|---|---|
domain | object |
domain.chainId | `0x${string}` |
domain.name | "Account.execute_from_outside" |
domain.revision | 1 |
domain.version | 2 |
message | object |
message.Caller | `0x${string}` |
message.Calls | [{ Calldata: [`0x${string}`, `0x${string}`, `0x${string}`]; Selector: "0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"; To: `0x${string}`; }] |
message.Execute After | "1" |
message.Execute Before | string |
message.Nonce | `0x${string}` |
primaryType | "OutsideExecution" |
types | object |
types.Call | Field[] |
types.OutsideExecution | Field[] |
types.StarknetDomain | Field[] |
StarknetInvocation
Properties
| Property | Type |
|---|---|
calldata | readonly `0x${string}`[] |
calls | readonly StarknetInvocation[] |
contract | `0x${string}` |
reverted | boolean |
selector | `0x${string}` |
StarknetReader
Bounded, read-only calls against one network's JSON-RPC node. Every failure rejects with ReaderError.
Properties
| Property | Modifier | Type |
|---|---|---|
network | readonly | StarknetNetwork |
Methods
receipt()
receipt(
tx):Promise<StarknetReceipt|null>
starknet_getTransactionReceipt; null: unknown hash.
Parameters
| Parameter | Type |
|---|---|
tx | `0x${string}` |
Returns
Promise<StarknetReceipt | null>
trace()
trace(
tx):Promise<StarknetInvocation|null>
starknet_traceTransaction's execute_invocation; null: none.
Parameters
| Parameter | Type |
|---|---|
tx | `0x${string}` |
Returns
Promise<StarknetInvocation | null>
StarknetReceipt
Properties
| Property | Type |
|---|---|
blockNumber | bigint | 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
| Property | Type | Description |
|---|---|---|
asset | `0x${string}` | - |
from | `0x${string}` | The payer's account: the contract whose outside-execution nonce is nonce. |
idDigest | `0x${string}` | - |
network | StarknetNetwork | - |
nonce | `0x${string}` | - |
settleBy | number | - |
transaction? | `0x${string}` | - |
StarknetUnsigned
Properties
| Property | Type | Description |
|---|---|---|
request | object | The typed data the account's key signs; SNIP-12 hashes the account in. |
request.account | `0x${string}` | - |
request.kind | "starknet-snip12" | - |
request.typedData | OutsideExecutionTypedData | - |
Methods
complete()
complete(
signature):Refusal|StarknetPayment
Takes the signature as 1 to 32 felts.
Parameters
| Parameter | Type |
|---|---|
signature | readonly `0x${string}`[] |
Returns
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: readonlyFelt[];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
constANY_CALLER:"0x414e595f43414c4c4552"="0x414e595f43414c4c4552"
The SNIP-9 any-caller sentinel, the short string ANY_CALLER.
exactStarknet
constexactStarknet: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: readonlyPaymentRequirements[];request:RequestCommitment; }];unplaced: (option) =>PaymentRequirements; }>
FELT_P
constFELT_P:bigint
MASK_250
constMASK_250:bigint
SELECTOR_EXECUTE_FROM_OUTSIDE_V2
constSELECTOR_EXECUTE_FROM_OUTSIDE_V2:"0x34cc13b274446654ca3233ed2c1620d4c5d1d32fd20b47146a3371064bdc57d"="0x34cc13b274446654ca3233ed2c1620d4c5d1d32fd20b47146a3371064bdc57d"
sn_keccak("execute_from_outside_v2")
SELECTOR_TRANSFER
constSELECTOR_TRANSFER:"0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"="0x83afd3f4caedc6eebf44246fe54e38c95e3179a5ec9ea81740eca5b482d12e"
sn_keccak("transfer")
Functions
chainIdFelt()
chainIdFelt(
n):`0x${string}`
The network's reference as a short-string felt.
Parameters
| Parameter | Type |
|---|---|
n | StarknetNetwork |
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
| Parameter | Type |
|---|---|
a | { amount: bigint; asset: `0x${string}`; executeBefore: number; feePayer: `0x${string}`; network: StarknetNetwork; nonce: `0x${string}`; payTo: `0x${string}`; } |
a.amount | bigint |
a.asset | `0x${string}` |
a.executeBefore | number |
a.feePayer | `0x${string}` |
a.network | StarknetNetwork |
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
| Parameter | Type |
|---|---|
option | PaymentRequirements |
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
from | `0x${string}` |
to | `0x${string}` |
amount | bigint |
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
| Parameter | Type |
|---|---|
ref | StarknetRef & object |
reader | StarknetReader |
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
| Parameter | Type |
|---|---|
ref | StarknetRef & object |
reader | StarknetReader |
Returns
Promise<StarknetStatus>
Last updated on