Getting Started

Quick overview

Installation

npm install @qlink/sdk

Usage

import { Qlink } from "@qlink/sdk";
 
const qlink = new Qlink({
  signer, // optional signer
});
 
// or connect signer later
qlink.connect(signer);

Creating a queue

const queueAddress = await qlink.create({
  // Identifier used to query many queues (optional)
  appId: "qlink",
  // Pointer to metadata ipfs cid or url (optional)
  metadata: "Qm...", // { title: "My Queue", external_url: "https://..." }
  // Ticket conductors allowed to push queue (creator address is always added)
  conductors: [],
  // Limit how many can be in the queue at the same time (defaults to 0 - no limit)
  capacity: 10,
  // Limit how many tickets can be minted in total (defaults to 0 - no limit)
  maxTickets: 100,
  // Amount and token to pay for ticket with (optional)
  price: 0,
  token: 0,
});

Minting tickets

A user can mint a new ticket for the queue.

TODO: Metadata can be provided with additional data such as ticket or seat number? Where is this stored?

const ticketId = await qlink.queue(address).mint(to);

Pushing the queue

Only owners and conductors

Queue owners and conductors can push the queue forward and a Next event will be emitted to notify the ticket holder.

Data can be passed to the next function. You can even encrypt the data so only the ticket owner can read it (for sensitive data or secret links).

const ticketId = await qlink.queue(address).next(data);
 
// Push several tickets notifying all of them
const ticketId = await qlink.queue(address).next(untilIndex, data);

Signing tickets

A ticket holder can sign the ticket which can later be used to verify its authenticity.

A signature is returned that can be embedded in a QR code. For example: https://qlink.xyz/queue/<address>/ticket/<ticketId>/verify?signature=<signature>

const signature = await qlink.queue(address).ticket(ticketId).sign();

Verifying tickets

A ticket can be verified by checking the signature has in fact been created by the ticket holder.

const proof = await qlink
  .queue(address)
  .ticket(ticketId)
  .verify(signature.address, signature.signature);

Reviewing

Only ticket holder

Must be called by the ticket holder and the ticket must already have been handled in a Next event.

Creates an EAS Attestation.

 

Offers

under development

Owners of queues can create offers such as vouchers or coupons for loyal customers.

Creating offers

Only queue owner

Creates an EAS Attestation.

 

Redeeming offers

Only ticket holder

Must be called by the ticket holder and the ticket must already have been handled in a Next event.

Creates an EAS Attestation.

 

Complete flow

// 1. Set up SDK
const qlink = new Qlink({ signer });
 
// 2. Owner creates a new queue
const queue = await qlink.create(config); // or qlink.get(queueAddress);
 
// 3. Customer mints a ticket
const account = "0x..."; // receiver of ticket
const ticketId = await queue.mint(account);
 
const tickets = await queue.query(filter);
 
// 4. Owner or conductor pushes the queue forward
await queue.next();
 
// 5. Ticket holder signs the ticket
const signature = await queue.ticket(ticketId).sign();
 
// 6. Owner verifies the ticket
const isValid = await queue.ticket(ticketId).verify(signature, account);
 
// Ticket holder creates a review
const review = await queue.review.create("loved it!");
 
const reviews = await queue.review.query();
 
const coupon = await queue.offer.create(ticketId, {});
const coupons = await queue.offer.list();
 
await queue.offer.redeem(ticketId);