Private
contractGrant a role to a specific address
Rest
...args: [role: TRole, address: string]The transaction receipt
Make sure you are sure you want to grant the role to the address.
await contract.roles.grant("minter", "{{wallet_address}}");
If you are trying to grant does not exist on the contract this will throw an error.
Permissions
Rest
...args: [role: TRole, address: string]Revoke a role from a specific address
Rest
...args: [role: TRole, address: string]The transaction receipt
-- Caution --
This will let you remove yourself from the role, too. If you remove yourself from the admin role, you will no longer be able to administer the contract. There is no way to recover from this.
await contract.roles.revoke("minter", "{{wallet_address}}");
If you are trying to revoke does not exist on the module this will throw an error.
Permissions
Rest
...args: [role: TRole, address: string]Overwrite the list of members for specific roles
Rest
...args: [rolesWithAddresses: {Every role in the list will be overwritten with the new list of addresses provided with them. If you want to add or remove addresses for a single address use ContractRoles.grant and ContractRoles.revoke respectively instead.
If you are requesting a role that does not exist on the contract this will throw an error.
Say you want to overwrite the list of addresses that are members of the minter role.
const minterAddresses = await contract.roles.get("minter");
await contract.roles.setAll({
minter: []
});
console.log(await contract.roles.get("minter")); // No matter what members had the role before, the new list will be set to []
Permissions
Rest
...args: [rolesWithAddresses: {Get all members of a specific role
The Role to to get a memberlist for.
The list of addresses that are members of the specific role.
See ContractRoles.getAll to get get a list of addresses for all supported roles on the contract.
If you are requesting a role that does not exist on the contract this will throw an error.
Say you want to get the list of addresses that are members of the minter role.
const minterAddresses = await contract.roles.get("minter");
Permissions
Get all members of all roles
A record of Roles to lists of addresses that are members of the given role.
See ContractRoles.get to get a list of addresses that are members of a specific role.
const rolesAndMembers = await contract.roles.getAll();
If the contract does not support roles this will throw an error.
PermissionsEnumerable
Private
getGenerated using TypeDoc
Handle contract permissions
Remarks
Configure roles and permissions for a contract, to restrict certain actions.
Example