LogoLogo
  • Welcome
  • XRPL Basics
    • Getting Started
    • Payments
    • Reading and subscribing to Transactions
    • Writing and reading memos
    • Non Fungible Tokens
    • PathFinding
    • Escrow
    • Price Oracles
    • Tickets
    • Multi-Signature
  • Token Issuance and Liquidity
    • Creating Accounts
    • Issuing Tokens
    • Creating an AMM Pool
  • Cyphered Chat on XRPL
    • Set up
    • Set up Keys
    • Cypher the message
    • Set up the memo & send the tx
    • Get the message and decypher it
  • EVM Sidechain
    • Connecting Metamask
    • Bridging Assets
    • Remix
    • Banking App
    • Banking Contract Key Concepts
  • Tools
    • Xaman Setup
    • Metamask Setup
Powered by GitBook
On this page
  • Introduction
  • Tickets Explained
  • What Are Tickets?
  • Why Use Tickets?
  • How Tickets Work
  • Advantages of Tickets
  • Ticket Setup
  • Prerequisites
  • Create Wallet
  • Retrieve Tickets
  • Using Tickets in Transactions
  • Optional Remove a Ticket
  • Explanation of the Script
  • Key Considerations
Export as PDF
  1. XRPL Basics

Tickets

Ticket Feature on XRPL

Introduction

Tickets on the XRPL allow you to reserve sequence numbers for transactions, enabling asynchronous transaction submission. This feature is particularly useful in multi-signature setups, where sequence management can become challenging due to independent signers.


Tickets Explained

What Are Tickets?

Tickets are a feature on the XRP Ledger that allow you to preallocate sequence numbers for future transactions. This helps avoid sequence number conflicts, especially in scenarios where multiple parties (like signers in a MultiSignature setup) need to sign a transaction.

Why Use Tickets?

In standard transactions, the Sequence field determines the order of execution. When signers asynchronously sign transactions, the sequence number may become outdated. Tickets provide a solution by reserving sequence numbers in advance, ensuring transactions can proceed without conflict.

How Tickets Work

Tickets are created using the TicketCreate transaction. Once created, these tickets can be used in place of the Sequence field in any subsequent transaction.


Advantages of Tickets

  1. Avoiding Sequence Conflicts

    Tickets prevent sequence number mismatches in multi-signature transactions, where signers may not act in a synchronized manner.

  2. Streamlining MultiSignature

    By reserving sequence numbers, Tickets simplify the signing and submission process in MultiSignature environments.

  3. Flexibility for Transaction Management

    Tickets can be used to prioritize certain transactions or reserve future transaction slots, offering better control over transaction flow.

Ticket Setup

Prerequisites

Create Wallet

import { Client, Wallet } from "xrpl";

const client = new Client("wss://s.altnet.rippletest.net:51233");
await client.connect();

const wallet = Wallet.fromSeed("s...");

Retrieve Tickets

You can query your account to retrieve active tickets.

const accountObjects = await client.request({
   command: "account_objects",
   account: wallet.classicAddress,
   type: "ticket"
});

console.log('Active Tickets:', accountObjects.result.account_objects);
// tickets [
//   {
//     Account: 'rHH6GByFtaKXXAEeue4myzFuq4ftAZW9un',
//     TicketSequence: 2856829
//   }
// ]

Using Tickets in Transactions

Once you have created tickets, you can use them in subsequent transactions by specifying the TicketSequence field instead of Sequence.

const ticketSequence = accountObjects.result.account_objects[0].TicketSequence;

const transaction = {
   TransactionType: "Payment",
   Account: wallet.classicAddress,
   Destination: "rrrrrrrrrrrrrrrrrNAMEtxvNvQ",
   Amount: '1000000', // 1 XRP in drops
   Sequence: 0,
   TicketSequence: ticketSequence // Use the ticket's sequence number
};

try {
   const result = await client.submit(transaction, { autofill: true, failHard: true, wallet });
   console.log('Transaction Submit Result:', result);
} catch (error) {
   console.error('Failed to submit transaction:', error);
}

Optional Remove a Ticket

Deleting a Ticket is sometimes required. To free up the associated Account Object. The way to do this is generate a no-op transaction

const ticketToDelete = accountObjects.result.account_objects[0].TicketSequence;

const noopTransaction = {
   TransactionType: "AccountSet",
   Account: wallet.classicAddress,
   TicketSequence: ticketToDelete
};

try {
   const result = await client.submit(noopTransaction, { autofill: true, failHard: true, wallet });
   console.log('No-Op Transaction Result:', result);
} catch (error) {
   console.error('Failed to delete ticket:', error);
}

Explanation of the Script

  1. Ticket Creation

    • The TicketCreate transaction reserves sequence numbers for future transactions.

    • Specify the number of tickets you want to create using the TicketCount field.

  2. Querying Tickets

    • Use the account_objects command to fetch active tickets linked to your account.

  3. Using Tickets

    • Include the TicketSequence field in your transaction to use a ticket instead of a regular sequence number.

Key Considerations

Cost of Tickets

Each ticket costs 2 XRP to reserve. Ensure you have sufficient XRP balance in your account before creating tickets.

Ticket Expiry

Tickets remain valid until used or until the account’s Sequence surpasses the ticket’s TicketSequence.

Managing Tickets

Efficiently manage tickets to avoid unnecessary fees and ensure smooth transaction workflows.

Combining Tickets with MultiSign

Tickets are particularly effective in MultiSignature setups, preventing sequence mismatches and allowing independent signers to collaborate seamlessly.

With the Ticket feature, XRPL provides a powerful mechanism to manage transaction order and avoid sequence conflicts, especially in asynchronous environments like MultiSignature. By leveraging Tickets, you can ensure smooth and conflict-free transaction workflows.

PreviousPrice OraclesNextMulti-Signature

Last updated 2 months ago

To create a Ticket on the XRPL, your account must hold sufficient XRP to meet the reserve requirements for the associated account object.

https://xrpl.org/docs/concepts/accounts/reserves#owner-reserves