Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Token

ERC1155 Token types and utilities.

import { Token } from '@sceneinfrastructure/sdk'

Try It

Token Namespace Demo
Query ERC1155 token data including supply information and metadata.
List all tokens for a contract.
await client.token.listByContract({
  contractAddress,
  limit: 10,
  orderBy: 'tokenId',
  order: 'asc',
})
Browser requests require CORS to be enabled.

Types

Token

Represents the state of a token tier in a Gatekeeper1155 contract.

import { Client } from '@sceneinfrastructure/sdk'
 
const client = Client.create({ url: '...' })
 
// Token objects are returned from indexer queries
const token = await client.token.get({
  contractAddress: '0x1234567890123456789012345678901234567890',
  tokenId: 1n,
})
 
if (token) {
  console.log('Token URI:', token.tokenURI)
  console.log('Max supply:', token.maxSupply)
  console.log('Total minted:', token.totalMinted)
}
FieldTypeDescription
contractAddressAddressThe Gatekeeper1155 contract address
tokenIdbigintThe token tier ID
tokenURIstringMetadata URI for the token
maxSupplybigintMaximum supply (0 = unlimited)
totalMintedbigintNumber of tokens minted

Schemas

schema

Zod schema for validating and parsing Token data.

import { Token } from '@sceneinfrastructure/sdk'
 
const data = {} // Data from API
 
// Parse token data from API
const result = Token.schema.safeParse(data)
 
if (result.success) {
  const available = result.data.maxSupply - result.data.totalMinted
  console.log('Available tickets:', available)
}

Example: Calculate Availability

import { Token } from '@sceneinfrastructure/sdk'
 
function getAvailability(token: Token.Token): bigint {
  if (token.maxSupply === 0n) {
    return BigInt(Number.MAX_SAFE_INTEGER) // Unlimited
  }
  return token.maxSupply - token.totalMinted
}
 
function isSoldOut(token: Token.Token): boolean {
  if (token.maxSupply === 0n) return false
  return token.totalMinted >= token.maxSupply
}

Read Operations

Query token data from the indexer.

import { Client } from '@sceneinfrastructure/sdk'
 
const client = Client.create({ url: '...' })

get

Get a token by contract address and token ID.

import { Client } from '@sceneinfrastructure/sdk'
 
const client = Client.create({ url: '...' })
 
const token = await client.token.get({
  contractAddress: '0x1234567890123456789012345678901234567890',
  tokenId: 1n
})
 
if (token) {
  console.log('Token URI:', token.tokenURI)
  console.log('Max supply:', token.maxSupply)
  console.log('Total minted:', token.totalMinted)
}

Parameters

ParameterTypeDescription
contractAddressAddressThe contract address
tokenIdbigintThe token ID

Returns

Token | null - The token data or null if not found.


listByContract

List all tokens for a contract.

import { Client } from '@sceneinfrastructure/sdk'
 
const client = Client.create({ url: '...' })
 
const tokens = await client.token.listByContract({
  contractAddress: '0x1234567890123456789012345678901234567890',
  limit: 50
})
 
for (const token of tokens) {
  console.log(`Token ${token.tokenId}: ${token.tokenURI}`)
  console.log(`  Supply: ${token.totalMinted}/${token.maxSupply || 'unlimited'}`)
}

Parameters

ParameterTypeDefaultDescription
contractAddressAddressrequiredThe contract address
limitnumber50Maximum results to return
offsetnumber0Number of results to skip
orderBy'createdAt' | 'tokenId''createdAt'Sort field
order'asc' | 'desc''desc'Sort direction

Returns

Token[] - Array of token records.