Skip to main content

Permission Controls

Permissions outline which wallet addresses can perform which actions on your smart contract.

To define which wallets have these permissions, you must add them to the required role.

Each contract has a different set of configurable roles, you can find the full list in the ALL_ROLES variable.

Role NameDescriptionRelevant Contracts
adminGrant or revoke roles and modify settings on this contract.All contracts
minterCreate new tokens on this contract.NFTs, Tokens
transferTransfer tokens on this contract.NFTs, Tokens
unwrapCan unwrap tokens on this contract.Multiwrap, Pack
listerCan create new listings on this marketplace contract.Marketplace
pauserCan pause (and unpause) all external calls made to this contract's contract.Custom
assetWhich assets can be listed on this marketplace contract.Marketplace

Read All Members of All Roles

Get all roles and all the members of each role.

const rolesAndMembers = await contract.roles.getAll();
View in Javascript SDK Documentation

Read Members of a Role

Get the wallet addresses of a specific role.

const minterAddresses = await contract.roles.get("minter");
View in Javascript SDK Documentation

Grant Role

await contract.roles.grant("minter", "0x1234567890123456789012345678901234567890");
View in Javascript SDK Documentation

Revoke Role

await contract.roles.revoke("minter", "0x1234567890123456789012345678901234567890");
View in Javascript SDK Documentation

Set All Roles (Overwrite)

Dangerous Operation

This will overwrite all existing permissions on this contract.

THIS INCLUDES YOUR OWN WALLET ADDRESS.

If you revoke your admin permissions, you will not be able to get them back.

Only proceed if you know what you are doing.

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 []
View in Javascript SDK Documentation

Update Roles

  1. Read the current roles from the get function.
  2. Modify the array for the role you want to update.
  3. Call the setAll function with the modified array.
const rolesAndMembers = await contract.roles.getAll();

const updatedRoles = {
...rolesAndMembers,
admin: [...rolesAndMembers.admin, "0x-new-address-here"],
};

await contract.roles.setAll(updatedRoles);