Have a ticket? Try pasting it into the iroh ticket explorer to break it down! Here’s an example
What is a ticket?
Here’s an example ticket:When to use tickets
Use tickets when:- Bootstrapping peer connections without a central coordination server
- Building apps where users manually share connection info (QR codes, copy/paste)
- You want a single token that contains both content identifiers and connection details
- Short-lived sessions where both peers are online simultaneously
- You have a central server or database to coordinate connections
- You’re building long-lived connections where dialing details change frequently
- You can cache
EndpointIDs and let iroh resolve dialing details at runtime
EndpointIDs directly instead of tickets. Let iroh handle the discovery and connection details transparently.
Creating tickets
Theiroh-tickets crate provides utilities for creating and parsing tickets. Here’s how to create a basic endpoint ticket:
Ticket patterns
Tickets typically follow this pattern:- An ASCII prefix indicating the ticket type (e.g.,
endpoint,blob,doc) - A base32-lowercase-encoded payload containing postcard-encoded data
Security considerations
Tickets contain IP addresses: When you create a ticket, it embeds the IP addresses you’re currently reachable at. Sharing a ticket means sharing your IP address with whoever receives it. This is intentional - it enables direct connections without a central server. This is actually better than many P2P systems that broadcast your IP to all peers. With tickets, you form a “cozy network” between peers you explicitly choose to connect with. Tickets are reusable: Unlike what the name might imply, tickets are not single-use tokens. Once created, a ticket can be used multiple times by anyone who has it. Application-specific tickets may contain secrets: Depending on what your application includes in a ticket (like write capabilities for a document), tickets can grant ongoing access. Treat them accordingly. Tickets can go stale: The dialing information in a ticket (especially IP addresses) can become outdated as network conditions change. For long-lived connections, prefer cachingEndpointIDs and letting iroh resolve current dialing details.
Building your own ticket types
Theiroh-tickets crate is designed to be extended. You can create custom ticket types for your application that bundle your own data alongside endpoint addresses. See the crate documentation for details.