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

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

RoleValueCapabilities
ADMIN_ROLE1nFull control: setup tiers, mint, stub, void, update metadata, manage roles, call gatekeeper
HOST_ROLE2nEvent management: mint tickets, stub tickets (check-in), void tickets
DOOR_ROLE4nCheck-in only: stub tickets
MINTER_ROLE8nIssuance: mint tickets, void tickets

Permission Matrix

FunctionADMINHOSTDOORMINTEROwner
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:

AddressRolesPurpose
Gatekeeper ContractMINTER_ROLEEnable ticket purchases through sales
Event OwnerADMIN_ROLEFull contract control
Event StaffHOST_ROLE | DOOR_ROLEManage 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