ContractRoles
Handle contract permissions
Configure roles and permissions for a contract, to restrict certain actions.
const contract = await sdk.getContract("{{contract_address}}");const rolesAndMembers = await contract.roles.getAll();await contract.roles.grantRole("admin", "0x...");
class ContractRoles< TContract extends IPermissions,> implements DetectableFeature {}
function constructor(contractWrapper: ContractWrapper<IPermissions>, roles: readonly Array<TRole>) : ContractRoles<TContract, TRole>
Get all members of a specific role
See ContractRoles.getAll to get get a list of addresses for all supported roles on the contract.
const minterAddresses = await contract.roles.get("minter");
function get(role: TRole): Promise<Array<string>>;
Get all members of all roles
See ContractRoles.get to get a list of addresses that are members of a specific role.
const rolesAndMembers = await contract.roles.getAll();
function getAll(): Promise<Record<TRole, Array<string>>>;
function grant(role: TRole, address: string): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling grant.prepare()
with same arguments. Learn more
function revoke(role: TRole, address: string): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling revoke.prepare()
with same arguments. Learn more
function setAll( rolesWithAddresses: { [key in | "metadata" | "transfer" | "signer" | "minter" | "revoke" | "admin" | "pauser" | "lister" | "asset" | "unwrap" | "factory" | "migration"]: Array<string>; }, actingAddress: string,): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling setAll.prepare()
with same arguments. Learn more
let featureName: "Permissions";