Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
createSignerClient – ERC-8128
Skip to content

createSignerClient

Create a client with a bound signer for convenient repeated use.

The client provides signRequest, signedFetch, and fetch methods that automatically use the configured signer and default options.

Usage

Create a client by passing a signer and optional default configuration. The returned client exposes signRequest, signedFetch, and fetch methods.

import { createSignerClient } from '@slicekit/erc8128'
 
const client = createSignerClient(signer, {
  ttlSeconds: 120,
  replay: 'non-replayable',
})
 
// Use client.fetch (alias for signedFetch)
const response = await client.fetch('https://api.example.com/orders', {
  method: 'POST',
  body: JSON.stringify({ amount: '100' }),
})
 
// Override options per-call
const response = await client.fetch(
  'https://api.example.com/status',
  { method: 'GET' },
  { replay: 'replayable' }
)
 
// Sign without sending
const signedRequest = await client.signRequest('https://api.example.com/orders')

Returns

Client

An object with bound methods:

  • signRequest — Sign a request
  • signedFetch — Sign and send a request
  • fetch — Alias for signedFetch

Parameters

signer

The signer to use for all requests.

defaults (optional)

Default options for all requests. Can be overridden per-call.

const client = createSignerClient(signer, {
  ttlSeconds: 300,
  replay: 'non-replayable',
  fetch: customFetch,
})