Skip to content
Integra Protocol
API

@integraledger/lcp/aptos

The exports of @integraledger/lcp/aptos.

Interfaces

AptosCommitted

A committed user transaction as the REST API returns it.

Properties

PropertyType
expiration_timestamp_secsstring
hashstring
payloadobject
payload.argumentsunknown[]
payload.functionstring
payload.typestring
payload.type_argumentsstring[]
senderstring
sequence_numberstring
successboolean
type"user_transaction"
versionstring

AptosInstrument

The transfer the payer signed, in one normal form shared by the signed bytes and the chain's REST answer.

Properties

PropertyType
argumentsreadonly string[]
chainIdnumber
expiresAtbigint
functionstring
sender`0x${string}`
sequenceNumberbigint
typeArgumentsreadonly string[]

AptosPaymentPayload

Properties

PropertyType
acceptedPaymentRequirements
extensions?object
payloadobject
payload.transactionstring
resource?object
resource.urlstring
x402Version2

AptosReader

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

Properties

PropertyModifierType
networkreadonly`aptos:${number}`

Methods

byHash()

byHash(hash): Promise<AptosCommitted | { type: "pending_transaction"; } | null>

GET /v1/transactions/by_hash/{hash}; null on 404.

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

Promise<AptosCommitted | { type: "pending_transaction"; } | null>

bySequence()

bySequence(sender, n): Promise<AptosCommitted | null>

GET /v1/accounts/{sender}/transactions?start=n&limit=1, kept only when its sequence_number is n.

Parameters
ParameterType
sender`0x${string}`
nbigint
Returns

Promise<AptosCommitted | null>

ledger()

ledger(): Promise<{ chainId: number; timestampUsecs: bigint; }>

GET /v1.

Returns

Promise<{ chainId: number; timestampUsecs: bigint; }>


AptosRef

Properties

PropertyTypeDescription
expiresAtstring-
idDigest`0x${string}`-
network`aptos:${number}`-
sender`0x${string}`-
sequenceNumberstringDecimal strings.
transaction?`0x${string}`The facilitator's transaction hash, once named.

AptosUnsigned

Properties

PropertyType
requestobject
request.acceptedPaymentRequirements
request.kind"aptos-transaction"

Methods

complete()

complete(signed): Refusal | AptosPaymentPayload

Parameters
ParameterType
signed{ transaction: string; }
signed.transactionstring
Returns

Refusal | AptosPaymentPayload

Type Aliases

AptosNetwork

AptosNetwork = `aptos:${number}`

CAIP-2: aptos: and the numeric chain id.


AptosStatus

AptosStatus = { state: "settled"; transaction: Hex; version: bigint; } | { state: "pending"; why: "not-found" | "in-mempool" | "unreadable"; } | { state: "failed"; why: "aborted" | "superseded" | "expired"; }

Variables

exactAptos

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

Functions

aptosIdDigest()

aptosIdDigest(i): Promise<`0x${string}` | Refusal>

SHA-256 over the RFC 8785 form of {sender, sequenceNumber, function, typeArguments, arguments}.

Parameters

ParameterType
iAptosInstrument

Returns

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


aptosOptionCheck()

aptosOptionCheck(option): Refusal | undefined

The pairing's filter: undefined for an option this pairing can pay, or the refusal naming why not.

Parameters

ParameterType
optionunknown

Returns

Refusal | undefined


aptosPairingOf()

aptosPairingOf(option): "x402/exact/aptos" | undefined

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

Parameters

ParameterType
optionPaymentRequirements

Returns

"x402/exact/aptos" | undefined


aptosStatus()

aptosStatus(ref, reader): Promise<AptosStatus>

Finds the payer's transaction by the facilitator's hash when named, else by sender and sequence number, and identifies it by the transfer's digest. Only success decides a committed, matching transaction. A failed read, or a reader for another network, is pending. At most three calls.

Parameters

ParameterType
refAptosRef
readerAptosReader

Returns

Promise<AptosStatus>


committedInstrument()

committedInstrument(t, chainId): Refusal | AptosInstrument

The REST answer in the normal form: every address as 0x and 64 lowercase hex, {"inner": a} as a, and the amount as its decimal string. The REST answer carries no chain id, so the caller supplies the ledger's.

Parameters

ParameterType
tAptosCommitted
chainIdnumber

Returns

Refusal | AptosInstrument


decodeAptosTx()

decodeAptosTx(transaction): Refusal | AptosInstrument

Reads the RawTransaction prefix of a base64 transaction, in either wire form: the scheme's BCS bytes, or x402's reference form, base64 of the JSON {"transaction": [bytes], "senderAuthenticator": [bytes]}. Only an entry function call to a framework fungible-asset transfer is accepted.

Parameters

ParameterType
transactionstring

Returns

Refusal | AptosInstrument

Last updated on

On this page