Permissions
Functionality available for contracts that inherit the Permissions contract.
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.
const members = await contract.roles.get("{{role_name}}");
Configuration
getAll
Retrieve all of the roles and associated wallets.
const allRoles = await contract.roles.getAll();
Configuration
Return Value
An object containing role names as keys and an array of wallet addresses as the value.
<Record<any, string[]>>
grant
Make a wallet a member of a given role.
const txResult = await contract.roles.grant(
"{{role_name}}",
"{{wallet_address}}",
);
Configuration
revoke
Revoke a given role from a wallet.
const txResult = await contract.roles.revoke(
"{{role_name}}",
"{{wallet_address}}",
);
Configuration
setAll
Overwrite all roles with new members.
This overwrites all members, INCLUDING YOUR OWN WALLET ADDRESS!
This means you can permanently remove yourself as an admin, which is non-reversible.
Please use this method with caution.
const txResult = await contract.roles.setAll({
admin: ["0x12", "0x123"],
minter: ["0x1234"],
});
Configuration
roles
An object containing role names as keys and an array of wallet addresses as the value.
const txResult = await contract.roles.setAll(
{
admin: ["0x12", "0x123"], // Grant these two wallets the admin role
minter: ["0x1234"], // Grant this wallet the minter role
},
);
verify
Check to see if a wallet has a set of roles.
Throws an error if the wallet does not have any of the given roles.
const verifyRole = await contract.roles.verify(
["admin", "minter"],
"{{wallet_address}}",
);