@integraledger/lcp/near
The exports of @integraledger/lcp/near.
Interfaces
NearChoice
Properties
| Property | Type | Description |
|---|---|---|
accepted | PaymentRequirements | - |
accessKeyNonce | bigint | view_access_key's nonce for the key. |
finalHeight | bigint | block at finality "final": its height. |
payer | string | - |
publicKey | string | ed25519:… or secp256k1:…. |
required | PaymentRequired | - |
NearOutcome
Properties
| Property | Type | Description |
|---|---|---|
delegate | { argsBase64: string; nonce: bigint; publicKey: string; senderId: string; } | null | - |
receipts | readonly object[] | - |
status | string | final_execution_status. |
NearReader
Bounded, read-only calls against one network's RPC. Every failure rejects with ReaderError.
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
network | readonly | NearNetwork | - |
relayers | readonly | readonly string[] | The facilitator's /supported signers["near:*"]. |
Methods
accessKeyNonce()
accessKeyNonce(
account,publicKey):Promise<bigint|null>
view_access_key at "final": the key's nonce; null: no such key.
Parameters
| Parameter | Type |
|---|---|
account | string |
publicKey | string |
Returns
Promise<bigint | null>
finalHeight()
finalHeight():
Promise<bigint>
block at finality "final": its header's height.
Returns
Promise<bigint>
txStatus()
txStatus(
txHash,sender):Promise<NearOutcome|null>
EXPERIMENTAL_tx_status with wait_until "NONE"; null: unknown.
Parameters
| Parameter | Type |
|---|---|
txHash | string |
sender | string |
Returns
Promise<NearOutcome | null>
NearRef
The read keys recorded at claim, JSON-serialisable: nonce and maxBlockHeight are decimal strings. transaction is
added when the facilitator names it.
Properties
| Property | Type |
|---|---|
asset | string |
maxBlockHeight | string |
network | NearNetwork |
nonce | string |
payer | string |
publicKey | string |
transaction? | string |
NearUnsigned
Properties
| Property | Type | Description |
|---|---|---|
request | object | SHA-256 of the NEP-461-prefixed delegate action: what the key signs. |
request.hash | Uint8Array | - |
request.kind | "near-delegate" | - |
Methods
complete()
complete(
signature):Refusal|NearPayment
Takes the key type (0 Ed25519, 1 secp256k1) and its 64- or 65-byte signature.
Parameters
| Parameter | Type |
|---|---|
signature | { bytes: Uint8Array; keyType: 0 | 1; } |
signature.bytes | Uint8Array |
signature.keyType | 0 | 1 |
Returns
Type Aliases
NearNetwork
NearNetwork =
"near:mainnet"|"near:testnet"
x402's NEAR network identifiers.
NearPayment
NearPayment =
X402Payment<{signedDelegateAction:string; }>
NearStatus
NearStatus = {
finality:"final"|"optimistic";state:"settled"; } | {state:"pending";why:"not-found"|"in-flight"|"unreadable"; } | {state:"failed";why:"not-this-instrument"|"transfer-failed"; }
Variables
exactNear
constexactNear:Readonly<{advertise: (doc,h,link,offer,agreementUrl?) =>Refusal|PaymentRequired;bound: (presented) =>Promise<`0x${string}`|Refusal>;build: (c,h) =>Promise<Refusal|NearUnsigned>;carrier:null;claims:boolean;id:"x402/exact/near";pattern:LcpPattern;read: (doc) =>Refusal|X402Read;recover: (ref,reader) =>Promise<`0x${string}`|Refusal>;reference: (presented) =>Promise<Refusal|NearRef>;status: (ref,reader) =>Promise<NearStatus>;tie: (accepts,request) => ["x402", {accepts: readonlyPaymentRequirements[];request:RequestCommitment; }];unplaced: (option) =>PaymentRequirements; }>
FT_TRANSFER_GAS
constFT_TRANSFER_GAS:30000000000000n=30_000_000_000_000n
NEP461_DELEGATE
constNEP461_DELEGATE:1073742190=1073742190
The NEP-461 prefix for a delegate action: (1 << 30) + 366.
Functions
ftTransferArgs()
ftTransferArgs(
payTo,amount,h):Uint8Array<ArrayBufferLike> |Refusal
ft_transfer's arguments: receiver_id, amount and memo, in that order, as JSON.stringify writes them. A value
that is not a 32-byte hash is x402/payload-malformed.
Parameters
| Parameter | Type |
|---|---|
payTo | string |
amount | string |
h | `0x${string}` |
Returns
Uint8Array<ArrayBufferLike> | Refusal
nearCarrier()
nearCarrier(
signedDelegateAction):Refusal| {asset:string;h:`0x${string}`;maxBlockHeight:bigint;nonce:bigint;payer:string;publicKey:string; }
Reads a base64 SignedDelegateAction whose one action is a FunctionCall of ft_transfer with a JSON object of
arguments whose memo is an LCP string. The bytes must be exactly the borsh encoding of what is read.
Parameters
| Parameter | Type |
|---|---|
signedDelegateAction | string |
Returns
Refusal | { asset: string; h: `0x${string}`; maxBlockHeight: bigint; nonce: bigint; payer: string; publicKey: string; }
nearLapsed()
nearLapsed(
ref,reader):Promise<boolean>
True only when the delegate action can never execute: the final height is past maxBlockHeight and the key's
nonce is below the action's, or the key is gone. Two calls; a failed read is false.
Parameters
| Parameter | Type |
|---|---|
ref | NearRef |
reader | NearReader |
Returns
Promise<boolean>
nearRecover()
nearRecover(
ref,reader):Promise<`0x${string}`|Refusal>
Recovers the hash from the settlement transaction: the memo in its delegated ft_transfer arguments.
Parameters
| Parameter | Type |
|---|---|
ref | { network: NearNetwork; transaction: string; } |
ref.network | NearNetwork |
ref.transaction | string |
reader | NearReader |
Returns
Promise<`0x${string}` | Refusal>
nearStatus()
nearStatus(
ref,reader):Promise<NearStatus>
Finds the relayed transaction under each published relayer (at most four), then requires its delegate to be this instrument and reads the receipts the token contract executed: a failure is failed, a success is settled. A failed read, an empty relayer list, or a reader for another network is pending.
Parameters
| Parameter | Type |
|---|---|
ref | NearRef & object |
reader | NearReader |
Returns
Promise<NearStatus>
pairingOf()
pairingOf(
option):"x402/exact/near"|undefined
This pairing's id for an option it can pay, or undefined.
Parameters
| Parameter | Type |
|---|---|
option | PaymentRequirements |
Returns
"x402/exact/near" | undefined
Last updated on