This library implements The Ticketto Protocol, based on an in-memory (design goal, use dedicated storage, like the IndexedDB API).
First, make sure your client supports IndexedDB.
Then, before starting the application (at the entrypoint), import reflect-metadata:
import 'reflect-metadata';
WebStub consumerAccountProvider must return the actual AccountId associated to the
account logged-in on your application. Also, the signer must receive a Uint8Array, and return a Promise<Uint8Array>
that contains the signed transaction. For local testing purposes, we can use this demo:// src/config.ts
import { ClientConfig } from '@ticketto/protocol';
export const defaultConfig: ClientConfig<Uint8Array> = {
accountProvider: {
getAccountId: () => "5DD8bv4RnTDuJt47SAjpWMT78N7gfBQNF2YiZpVUgbXkizMG",
sign: (payload: Uint8Array) => Promise.resolve(payload),
},
};
TickettoWebStubConsumer as well as the config.// src/index.ts
import { TickettoClientBuilder } from '@ticketto/protocol';
import { TickettoWebStubConsumer } from '@ticketto/web-stub';
import { defaultConfig } from './config.ts'
const client = await new TickettoClientBuilder()
.withConsumer(TickettoWebStubConsumer)
.withConfig(defaultConfig)
.build();
// Example of the client validating and submitting the contents of an attendance QR (let's call it `input`).
/** In our example, the QR payload is a base-64 encoded input representing the call */
const qr = await readQrCode();
const input: Uint8Array = fromBase64();
await client.tickets.calls.submitAttendanceCall(input);