Skip to main content
Bots can create and manage roles in Towns spaces. Roles control what users can do - from reading messages to banning members. You can also create token-gated roles that require users to hold specific NFTs or tokens.
Role management requires your bot to have admin permissions in the space. All role operations are onchain transactions that require gas.

Creating Roles

CreateRoleParams

ParameterTypeDescription
namestringDisplay name for the role
permissionsPermission[]Array of permissions to grant
usersstring[](Optional) User addresses to assign the role
ruleOperation(Optional) Token-gating rule (see below)

Token-Gated Roles

Create roles that require users to hold specific tokens using the Rules API:
You can apply the role to a channel by calling bot.addRoleToChannel(channelId, roleId). This will gate the channel to only users who hold the required tokens.

Available Rule Types

RuleDescription
Rules.checkErc721({ chainId, contractAddress, threshold })Check ERC721 NFT balance
Rules.checkErc20({ chainId, contractAddress, threshold })Check ERC20 token balance
Rules.checkErc1155({ chainId, contractAddress, tokenId, threshold })Check ERC1155 balance for a specific token ID
Rules.checkEthBalance({ threshold })Check native ETH balance
Rules.checkIsEntitled({ chainId, contractAddress, params? })Check cross-chain entitlement

Combining Rules

Managing Roles

Available Permissions

See Roles & Entitlements for the full list of available permissions.