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)
}| Field | Type | Description |
|---|---|---|
contractAddress | Address | The Gatekeeper1155 contract address |
tokenId | bigint | The token tier ID |
tokenURI | string | Metadata URI for the token |
maxSupply | bigint | Maximum supply (0 = unlimited) |
totalMinted | bigint | Number 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
| Parameter | Type | Description |
|---|---|---|
contractAddress | Address | The contract address |
tokenId | bigint | The 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
| Parameter | Type | Default | Description |
|---|---|---|---|
contractAddress | Address | required | The contract address |
limit | number | 50 | Maximum results to return |
offset | number | 0 | Number of results to skip |
orderBy | 'createdAt' | 'tokenId' | 'createdAt' | Sort field |
order | 'asc' | 'desc' | 'desc' | Sort direction |
Returns
Token[] - Array of token records.