Optionaloptions: {OptionalcauseReadonlypaymentTrue when a signed payment had already been sent to the server when the call failed, so the payment may have settled even though no usable response was received. Do not blindly retry.
OptionalstackOptional ReadonlystatusHTTP status of the response to the paid request, when the call failed because that response
was not 2xx (the matching GlassnodeApiError is on .cause). undefined when no such
response was received (a payment-layer or transport failure).
ReadonlytimedTrue when the failure was the per-request timeout (an AbortSignal.timeout() abort) firing
on the paid request. Always false when paymentMayHaveSettled is false.
StaticstackThe Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
StaticcaptureCreates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
OptionalconstructorOpt: FunctionStaticprepare
An x402 paid call failed in the payment layer. Only raised by a fetch built with
createX402Fetch(fromglassnode-api/x402), and never retried by the client. Two cases, told apart by GlassnodePaymentError.paymentMayHaveSettled:false— nothing was paid: the payment layer (@x402/fetch) failed before a paid request was sent, e.g. every payment requirement the server offered was abovemaxPaymentPerCall(or x402's own spend controls), the signer failed, or the server's402carried no usable payment requirements. The same request would fail the same way.true— a request carrying a signed payment was sent, and the call then failed: either the paid request failed in transit (connection reset, or thetimeoutabort), or it was answered with a non-2xx HTTP status other than402(e.g. a gateway502/504, a429, a400). The server (or the origin behind a proxy) may already have received the payment and settled it on-chain, so a retry would sign a new payment and could charge twice. Check the payer's on-chain transfers before retrying. For a transport failure the original error is on.causeand GlassnodePaymentError.timedOut says whether it was the per-requesttimeout; for an HTTP failure GlassnodePaymentError.status is set and.causeis the GlassnodeApiError (withstatus,statusText,detail) the response amounts to.The original error is on
.cause. A transport failure or429/5xxof the unpaid request (before any payment was signed) stays a retryable GlassnodeNetworkError / GlassnodeApiError; a402answer to the paid request (the server refused the payment, e.g. insufficient USDC) stays a GlassnodeApiError withstatus402, which is never retried either.