Skip to content
Integra Protocol
API

@integraledger/lcp/near

The exports of @integraledger/lcp/near.

Interfaces

NearChoice

Properties

PropertyTypeDescription
acceptedPaymentRequirements-
accessKeyNoncebigintview_access_key's nonce for the key.
finalHeightbigintblock at finality "final": its height.
payerstring-
publicKeystringed25519:… or secp256k1:….
requiredPaymentRequired-

NearOutcome

Properties

PropertyTypeDescription
delegate{ argsBase64: string; nonce: bigint; publicKey: string; senderId: string; } | null-
receiptsreadonly object[]-
statusstringfinal_execution_status.

NearReader

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

Properties

PropertyModifierTypeDescription
networkreadonlyNearNetwork-
relayersreadonlyreadonly 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
ParameterType
accountstring
publicKeystring
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
ParameterType
txHashstring
senderstring
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

PropertyType
assetstring
maxBlockHeightstring
networkNearNetwork
noncestring
payerstring
publicKeystring
transaction?string

NearUnsigned

Properties

PropertyTypeDescription
requestobjectSHA-256 of the NEP-461-prefixed delegate action: what the key signs.
request.hashUint8Array-
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
ParameterType
signature{ bytes: Uint8Array; keyType: 0 | 1; }
signature.bytesUint8Array
signature.keyType0 | 1
Returns

Refusal | NearPayment

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

const exactNear: 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: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>


FT_TRANSFER_GAS

const FT_TRANSFER_GAS: 30000000000000n = 30_000_000_000_000n


NEP461_DELEGATE

const NEP461_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

ParameterType
payTostring
amountstring
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

ParameterType
signedDelegateActionstring

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

ParameterType
refNearRef
readerNearReader

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

ParameterType
ref{ network: NearNetwork; transaction: string; }
ref.networkNearNetwork
ref.transactionstring
readerNearReader

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

ParameterType
refNearRef & object
readerNearReader

Returns

Promise<NearStatus>


pairingOf()

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

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

Parameters

ParameterType
optionPaymentRequirements

Returns

"x402/exact/near" | undefined

Last updated on

On this page