Skip to content

ZoneRpcAuthentication

Zone RPC authentication token utilities for private zone RPC access.

Zone RPC authentication tokens are short-lived, read-only credentials used in the X-Authorization-Token header when talking to private zone RPC endpoints. They reuse Tempo's multi-signature model, so secp256k1, P256, WebAuthn, and keychain access-key signatures all share the same wire format as Tempo transaction signatures.

Zone RPC Specification

Examples

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

Functions

NameDescription
ZoneRpcAuthentication.deserializeParses a serialized Zone RPC authentication token.
ZoneRpcAuthentication.fromInstantiates a typed Zone RPC authentication token.
ZoneRpcAuthentication.getFieldsReturns the 29-byte fixed field suffix for a Zone RPC authentication token.
ZoneRpcAuthentication.getSignPayloadComputes the sign payload for a Zone RPC authentication token.
ZoneRpcAuthentication.hashComputes the raw authorization hash for a Zone RPC authentication token.
ZoneRpcAuthentication.serializeSerializes a Zone RPC authentication token to hex.

Errors

NameDescription
ZoneRpcAuthentication.InvalidSerializedErrorError thrown when a serialized authentication token cannot be deserialized.
ZoneRpcAuthentication.MissingSignatureErrorError thrown when serializing an authentication token without a signature.

Types

NameDescription
ZoneRpcAuthentication.Fields29-byte fixed Zone RPC authentication field suffix.
ZoneRpcAuthentication.InputInput type for a Zone RPC authentication token.
ZoneRpcAuthentication.SerializedHex-encoded serialized Zone RPC authentication token.
ZoneRpcAuthentication.SignedSigned Zone RPC authentication token.
ZoneRpcAuthentication.VersionCurrent Zone RPC authentication version.
ZoneRpcAuthentication.ZoneRpcAuthenticationRoot type for a Tempo Zone RPC authentication token.