Getting Started
Installation
pnpm
pnpm add @sceneinfrastructure/sdkPeer Dependencies
pnpm add ox zod viem @ponder/clientSDK Surface Area
- Onchain helpers:
Factory,Gatekeeper,Gatekeeper1155for deployment, sales, purchases, and ticket ops. - Indexer client:
Clientfor Ponder SQL queries and live subscriptions.
Basic Usage
Import the SDK
import {
Factory,
Gatekeeper,
Approval,
Sale,
SaleKey,
MINTER_ROLE,
gatekeeperAddress,
gatekeeper1155FactoryAddress,
} from '@sceneinfrastructure/sdk'Contract Addresses
The SDK exports deployed contract addresses for supported chains:
import {
gatekeeperAddress,
gatekeeper1155FactoryAddress,
gatekeeper1155Address,
} from '@sceneinfrastructure/sdk'
// Access addresses by chain ID
const gatekeeperOnBase = gatekeeperAddress[8453]
const factoryOnBase = gatekeeper1155FactoryAddress[8453]Role Constants
Common role constants for access control:
import { ADMIN_ROLE, HOST_ROLE, DOOR_ROLE, MINTER_ROLE } from '@sceneinfrastructure/sdk'
// Combine roles with bitwise OR
const combinedRoles = ADMIN_ROLE | MINTER_ROLEOutput Formats
SDK functions support two output formats via the as parameter:
| Format | Returns | Use With |
|---|---|---|
'data' (default) | { to, data } | sendTransaction |
'args' | { to, functionName, args } | writeContract |
import { Gatekeeper } from '@sceneinfrastructure/sdk'
const saleKey = {
token: '0x1234567890123456789012345678901234567890',
vendorFeeBps: 0,
referralFeeBps: 0,
salesTaxBps: 0,
vendor: '0x2345678901234567890123456789012345678901',
nonce: 1n,
currency: '0x3456789012345678901234567890123456789012',
fundsRecipient: '0x4567890123456789012345678901234567890123',
tokenId: 1n,
} as const
// Default: raw calldata
const { to, data } = Gatekeeper.preparePurchase({
gatekeeper: '0x5678901234567890123456789012345678901234',
saleKey,
purchaseParams: {
recipient: '0x6789012345678901234567890123456789012345',
referrer: '0x0000000000000000000000000000000000000000',
quantity: 1,
},
})
// With as: 'args' for viem's writeContract
const { to: addr, functionName, args } = Gatekeeper.preparePurchase({
gatekeeper: '0x5678901234567890123456789012345678901234',
saleKey,
purchaseParams: {
recipient: '0x6789012345678901234567890123456789012345',
referrer: '0x0000000000000000000000000000000000000000',
quantity: 1,
},
as: 'args',
})Querying Indexed Data
import { Client, ADMIN_ROLE } from '@sceneinfrastructure/sdk'
const client = Client.create({
url: 'https://dev.ponder.mesh.ing/sql'
})
// Query contracts
const contract = await client.eventContract.get({
contractAddress: '0x1234567890123456789012345678901234567890'
})
// Check permissions
const isAdmin = await client.permission.hasRole({
contractAddress: '0x1234567890123456789012345678901234567890',
user: '0x2345678901234567890123456789012345678901',
role: ADMIN_ROLE,
})See Querying Guide for live subscriptions and raw queries.
Next Steps
Now that you have the SDK installed, learn how to: