Convert PCZTs to and from bytes for transmission
function parse_pczt(bytes: Uint8Array): WasmPczt // Or from hex const pczt = WasmPczt.from_hex(hexString);
function serialize_pczt(pczt: WasmPczt): Uint8Array // Or to hex const hex = pczt.to_hex();
// 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);
// Save to storage localStorage.setItem('pczt', pczt.to_hex()); // Later, resume const pczt = WasmPczt.from_hex(localStorage.getItem('pczt'));
Was this page helpful?