Creating a Tranche of Event Tickets

To get started, we'll introduce some of the core concepts by building a simple ticket tranche creation web application using the ts-sdk and react.

This tutorial assumes you have Nodejs installed

Step 1: Set Up the React Application

First, set up a new Ract app:

npx create-react-app ticket-tranche-app --template typescript
cd ticket-tranche-app

Step 2: Install Dependencies

npm install react @bsv/sdk big.js

Step 3: Create the Ticket Form Component

// src/components/TicketForm.js
import React, { useState } from 'react';

const TicketForm = ({ onAddTicket }: any) => {
  const [ticketInfo, setTicketInfo] = useState('');

  const handleSubmit = (e: any) => {
    e.preventDefault();
    onAddTicket(ticketInfo);
    setTicketInfo('');
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        value={ticketInfo}
        onChange={(e) => setTicketInfo(e.target.value)}
        placeholder="Enter ticket information"
        required
      />
      <button type="submit">Add Ticket</button>
    </form>
  );
};

export default TicketForm;

Step 4: Create the Main App Component

Step 5: Create Utility Functions for Transactions

Step 6: Run the Application

Last updated