Role Management
Available Roles
import {
ADMIN_ROLE,
HOST_ROLE,
DOOR_ROLE,
MINTER_ROLE,
} from '@sceneinfrastructure/sdk'
// Role values (bitmask)
console.log(ADMIN_ROLE) // 1n (1 << 0)
console.log(HOST_ROLE) // 2n (1 << 1)
console.log(DOOR_ROLE) // 4n (1 << 2)
console.log(MINTER_ROLE) // 8n (1 << 3)Role Capabilities
| Role | Value | Capabilities |
|---|---|---|
ADMIN_ROLE | 1n | Full control: setup tiers, mint, stub, void, update metadata, manage roles, call gatekeeper |
HOST_ROLE | 2n | Event management: mint tickets, stub tickets (check-in), void tickets |
DOOR_ROLE | 4n | Check-in only: stub tickets |
MINTER_ROLE | 8n | Issuance: mint tickets, void tickets |
Permission Matrix
| Function | ADMIN | HOST | DOOR | MINTER | Owner |
|---|---|---|---|---|---|
setupNewTier | ✓ | ✓ | |||
adminMint | ✓ | ✓ | ✓ | ✓ | |
adminStubTickets | ✓ | ✓ | ✓ | ✓ | |
voidTickets | ✓ | ✓ | ✓ | ✓ | |
updateToken | ✓ | ✓ | |||
callGatekeeper | ✓ | ✓ | |||
grantRoles | ✓ | ✓ | |||
revokeRoles | ✓ | ✓ |
Granting Roles
Grant roles to addresses. Requires ADMIN_ROLE (the owner is also permitted).
Single Role
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { base } from 'viem/chains'
import { Gatekeeper1155, MINTER_ROLE, gatekeeperAddress } from '@sceneinfrastructure/sdk'
const account = privateKeyToAccount('0x...' as `0x${string}`)
const walletClient = createWalletClient({
account,
chain: base,
transport: http(),
})
const chainId = 8453 // Base
// Grant MINTER to Gatekeeper contract (required for sales)
const { to, data } = Gatekeeper1155.prepareGrantRoles({
contract: '0x1234567890123456789012345678901234567890',
user: gatekeeperAddress[chainId],
roles: MINTER_ROLE,
})
// await walletClient.sendTransaction({ to, data })Multiple Roles
Combine roles with bitwise OR:
import { Gatekeeper1155, ADMIN_ROLE, HOST_ROLE, DOOR_ROLE } from '@sceneinfrastructure/sdk'
// Grant multiple roles to an operator
const { to, data } = Gatekeeper1155.prepareGrantRoles({
contract: '0x1234567890123456789012345678901234567890',
user: '0x2345678901234567890123456789012345678901',
roles: HOST_ROLE | DOOR_ROLE, // Combine with |
})Revoking Roles
Remove roles from addresses. Requires ADMIN_ROLE (the owner is also permitted).
import { createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { base } from 'viem/chains'
import { Gatekeeper1155, MINTER_ROLE } from '@sceneinfrastructure/sdk'
const account = privateKeyToAccount('0x...' as `0x${string}`)
const walletClient = createWalletClient({
account,
chain: base,
transport: http(),
})
const { to, data } = Gatekeeper1155.prepareRevokeRoles({
contract: '0x1234567890123456789012345678901234567890',
user: '0x2345678901234567890123456789012345678901',
roles: MINTER_ROLE,
})
// await walletClient.sendTransaction({ to, data })Roles During Deployment
Grant roles as part of contract deployment:
import {
Factory,
MINTER_ROLE,
HOST_ROLE,
DOOR_ROLE,
gatekeeperAddress,
gatekeeper1155FactoryAddress,
gatekeeper1155Address,
} from '@sceneinfrastructure/sdk'
const chainId = 8453 // Base
const walletAddress = '0x3456789012345678901234567890123456789012'
const operatorAddress = '0x4567890123456789012345678901234567890123'
const setupCalls = [
// Grant MINTER to Gatekeeper (required for sales)
Factory.encodeGrantRoles({
user: gatekeeperAddress[chainId],
roles: MINTER_ROLE,
}),
// Grant HOST + DOOR to operator
Factory.encodeGrantRoles({
user: operatorAddress,
roles: HOST_ROLE | DOOR_ROLE,
}),
]
const { to, data, predictedAddress } = Factory.prepareDeploy({
factory: gatekeeper1155FactoryAddress[chainId],
implementation: gatekeeper1155Address[chainId],
nonce: BigInt(Date.now()),
creator: walletAddress,
owner: walletAddress,
contractURI: 'ipfs://...',
calls: setupCalls,
})Typical Role Assignments
Event Setup
For a typical event, assign roles as follows:
| Address | Roles | Purpose |
|---|---|---|
| Gatekeeper Contract | MINTER_ROLE | Enable ticket purchases through sales |
| Event Owner | ADMIN_ROLE | Full contract control |
| Event Staff | HOST_ROLE | DOOR_ROLE | Manage event and check-in attendees |
Checking Roles
Read role assignments using viem directly:
import { gatekeeper1155Abi } from '@sceneinfrastructure/sdk'
// Check if address has role
// const hasRole = await publicClient.readContract({
// address: contractAddress,
// abi: gatekeeper1155Abi,
// functionName: 'hasAllRoles',
// args: [userAddress, DOOR_ROLE],
// })Next Steps
- Deploying Contracts with role setup
- Ticket Management for operations requiring roles
- Reference: Constants for role values