Skip to main content
Functions for serializing and deserializing PCZTs, useful for transmitting between systems.

parse_pczt

Parse a PCZT from bytes.
  • TypeScript
  • Go
  • Kotlin
function parse_pczt(bytes: Uint8Array): WasmPczt

// Or from hex
const pczt = WasmPczt.from_hex(hexString);

serialize_pczt

Serialize a PCZT to bytes.
  • TypeScript
  • Go
  • Kotlin
function serialize_pczt(pczt: WasmPczt): Uint8Array

// Or to hex
const hex = pczt.to_hex();

Use Cases

Transmit to External Signer

// Serialize for transmission
const pcztBytes = t2z.serialize_pczt(pczt);
const pcztBase64 = btoa(String.fromCharCode(...pcztBytes));

// Send to signer...
const signedBase64 = await sendToSigner(pcztBase64);

// Parse signed PCZT
const signedBytes = Uint8Array.from(atob(signedBase64), c => c.charCodeAt(0));
const signedPczt = t2z.parse_pczt(signedBytes);

Store and Resume

// Save to storage
localStorage.setItem('pczt', pczt.to_hex());

// Later, resume
const pczt = WasmPczt.from_hex(localStorage.getItem('pczt'));