Skip to content

ZoneRpcAuthentication.serialize

Serializes a Zone RPC authentication token to hex.

The serialized format is <signature><29-byte fields>.

Imports

Named
import { ZoneRpcAuthentication } from 'ox/tempo'

Examples

import { Secp256k1 } from 'ox'
import { ZoneRpcAuthentication } from 'ox/tempo'
 
const authentication = ZoneRpcAuthentication.from({
  chainId: 4217000026,
  expiresAt: 1711235160,
  issuedAt: 1711234560,
  zoneId: 26,
})
 
const signature = Secp256k1.sign({
  payload: ZoneRpcAuthentication.getSignPayload(authentication),
  privateKey: '0x...',
})
 
const serialized = ZoneRpcAuthentication.serialize(authentication, {
  signature,
})

Definition

function serialize(
  authentication: PartialBy<ZoneRpcAuthentication, 'version'>,
  options?: serialize.Options,
): Serialized

Source: src/tempo/ZoneRpcAuthentication.ts

Parameters

authentication

  • Type: PartialBy<ZoneRpcAuthentication, 'version'>

The Zone RPC authentication token.

options

  • Type: serialize.Options
  • Optional

Serialization options.

options.signature

  • Type: Value
  • Optional

Signature to attach to the serialized authentication token.

Return Type

The serialized authentication token.

Serialized