Skip to main content

Permissions

Functionality available for contracts that inherit the Permissions extension.

Allows you to manage the roles and permissions of the smart contract.

Roles include admin, transfer, minter, pauser, lister, asset, unwrap, factory, or any other custom roles you have created.

get

Get a list of wallet addresses that are members of a given role.

from thirdweb.constants.role import Role

# Select any role to filter by
role = Role.ADMIN

role_members = contract.roles.get(role)
print(role_members)
Configuration

role

The name of the role.

Must be a Role.

role_members = contract.roles.get(
role,
)

Return Value

A list of strings representing the wallet addresses associated with the given role.

List[str]

get_all

Retrieve all of the roles and associated wallets.

all_role_members = contract.roles.get_all()
print(all_role_members)
Configuration

Return Value

A dictionary containing role names as keys and an array of wallet addresses as the value.

Dict[Role, List[str]]

grant

Make a wallet a member of a given role.

from thirdweb.constants.role import Role

address = "0x7fDae677aA6f94Edff9872C4b91D26407709c790" # Address to grant a role
role = Role.ADMIN # Select a role to grant

receipt = contract.roles.grant(role, address)
Configuration

role

The name of the role to grant.

Must be a Role.

receipt = contract.roles.grant(
role,
"{{wallet_address}}",
)

wallet

The wallet address to assign the role to.

Must be a string.

receipt = contract.roles.grant(
role,
"{{wallet_address}}",
)

revoke

Revoke a given role from a wallet.

from thirdweb.constants.role import Role

address = "0x7fDae677aA6f94Edff9872C4b91D26407709c790" # Address to revoke role
role = Role.ADMIN # Select a role to revoke

receipt = contract.roles.revoke(
role,
"{{wallet_address}}",
)
Configuration

role

The name of the role to revoke.

Must be a Role.

receipt = contract.roles.revoke(
role,
"{{wallet_address}}",
)

wallet

The wallet address to remove the role from.

Must be a string.

receipt = contract.roles.revoke(
role,
"{{wallet_address}}",
)