Skip to content

RelayClient

new RelayClient(opts): RelayClient

Parameter Type
opts RelayClientOptions

RelayClient

optional welcome?: Welcome


readonly opts: RelayClientOptions

get maxQuoteTtlMs(): number

number


get relayPublicKey(): string | undefined

The relay key job dispatches are checked against (configured or pinned).

string | undefined


get solverId(): string

string


get network(): string | undefined

The network our quotes and ladders are bound to: ours when configured, else the relay's.

string | undefined

sentQuote(quoteId): SentQuote | undefined

A quote this client sent, by quoteId.

Parameter Type
quoteId string

SentQuote | undefined


sentQuotesFor(requestId): SentQuote[]

The quotes this client sent for a request.

Parameter Type
requestId string | undefined

SentQuote[]


connect(): Promise<Welcome>

Connects and resolves on welcome; keeps reconnecting until close().

Promise<Welcome>


on(type, h): () => void

Parameter Type
type string
h Handler

() => void


off(type, h): void

Parameter Type
type string
h Handler

void


send(frame): void

Parameter Type
frame Record<string, unknown>

void


sendReliably(frame): void

Sends now, or after the next welcome when the socket is down (bounded queue).

Parameter Type
frame Record<string, unknown>

void


request(frame, timeoutMs?): Promise<{ ok: boolean; error?: string; data?: any; }>

Sends a frame with a ref and waits for the relay's ack.

Parameter Type Default value
frame Record<string, unknown> undefined
timeoutMs? number 10_000

Promise<{ ok: boolean; error?: string; data?: any; }>


quote(req, q): boolean

Signs and sends a firm quote (the envelope's Quote, MIP draft §6): the request terms repeated, our price, a signature that binds them to this relay and network. The quote binds at most maxQuoteTtlMs; when the request asks for longer (minDeadlineMs) nothing is sent and the result is false. Nothing is signed either for a request that names another relay or network than the ones we hold.

Parameter Type
req RfqRequestV2
q { wantAmount: bigint; settlement: "solver_offer" | "user_offer"; expiresAt: number; uses?: string[]; quoteId?: string; }
q.wantAmount bigint
q.settlement "solver_offer" | "user_offer"
q.expiresAt number
q.uses? string[]
q.quoteId? string

boolean


pushLadder(pair, points, validUntil, seq): Promise<{ ok: boolean; error?: string; }>

Signs and pushes a ladder (the envelope's Ladder, MIP draft §7) for this relay and network.

Parameter Type
pair TokenPair
points [bigint, bigint][]
validUntil number
seq number

Promise<{ ok: boolean; error?: string; }>


jobResult(jobId, state, extra?): void

Parameter Type
jobId string
state "finalized" | "failed" | "submitted" | "claimed" | "proving" | "submit-failed"
extra? { txId?: string; tx?: string; openings?: unknown[]; dustFee?: string; bytes?: number; error?: FillError; }
extra.txId? string
extra.tx? string
extra.openings? unknown[]
extra.dustFee? string
extra.bytes? number
extra.error? FillError

void


getJob(jobId): Promise<{ jobId: string; kind: string; state: string; fillId: string; dispatch: JobDispatch; } | null>

GET /jobs/:id: a job's durable record (recovery after a reconnect or restart).

Parameter Type
jobId string

Promise<{ jobId: string; kind: string; state: string; fillId: string; dispatch: JobDispatch; } | null>


close(): void

void