TicketIntent
EIP-712 typed data for ticket intent signatures.
import { TicketIntent } from '@sceneinfrastructure/sdk'Overview
Ticket intents are signed messages that cryptographically prove a user owns a specific ticket. The ticket holder signs an EIP-712 message containing their token ID, quantity, and an expiry deadline. This signature can then be verified to confirm ownership without requiring a transaction.
Common use cases:
- Generating QR codes for event check-in
- Proving ticket ownership to third parties
- Time-limited verification of ticket holdings
Types
IntentMessage
The message payload for ticket intent signatures.
import { TicketIntent } from '@sceneinfrastructure/sdk'
const message: TicketIntent.IntentMessage = {
tokenId: 1n,
quantity: 2n,
deadline: BigInt(Math.floor(Date.now() / 1000) + 3600), // 1 hour
}| Field | Type | Description |
|---|---|---|
tokenId | bigint | The token tier ID |
quantity | bigint | Number of tickets |
deadline | bigint | Unix timestamp expiry |
Functions
Signing a Ticket Intent
Use the exported constants with viem's signTypedData:
import { TicketIntent } from '@sceneinfrastructure/sdk'
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { base } from 'viem/chains'
const account = privateKeyToAccount('0x...')
const walletClient = createWalletClient({
account,
chain: base,
transport: http(),
})
const message: TicketIntent.IntentMessage = {
tokenId: 1n,
quantity: 2n,
deadline: BigInt(Math.floor(Date.now() / 1000) + 3600),
}
const signature = await walletClient.signTypedData({
domain: {
...TicketIntent.domain,
chainId: 8453n, // Base
verifyingContract: '0x1234567890123456789012345678901234567890',
},
types: TicketIntent.types,
primaryType: TicketIntent.primaryType,
message,
})Constants
types
EIP-712 type definitions for TicketIntent signatures.
import { TicketIntent } from '@sceneinfrastructure/sdk'
// TicketIntent.types includes:
// - EIP712Domain type
// - TicketIntent struct typedomain
Base domain separator for TicketIntent signatures. Add chainId and verifyingContract at runtime.
import { TicketIntent } from '@sceneinfrastructure/sdk'
const contractAddress = '0x1234567890123456789012345678901234567890' as const
const fullDomain = {
...TicketIntent.domain,
chainId: 8453n,
verifyingContract: contractAddress,
}| Field | Value |
|---|---|
name | 'TicketIntent' |
version | '1.0.0' |
primaryType
The primary type identifier for TicketIntent signatures.
import { TicketIntent } from '@sceneinfrastructure/sdk'
console.log(TicketIntent.primaryType) // 'TicketIntent'Schemas
messageSchema
Zod schema for validating TicketIntent messages. Coerces string/number inputs to bigint.
import { TicketIntent } from '@sceneinfrastructure/sdk'
const message = TicketIntent.messageSchema.parse({
tokenId: '1',
quantity: 2,
deadline: Date.now() + 3600000,
})