Permission Controls
Read All Members of All Roles
Get all roles and all the members of each role.
- React
- Javascript
- Python
- Go
- Unity
This feature is missing a code snippet or might not be supported yet.
Check the React SDK documentation for more information.
Reach out on Discord for further assistance!
View React SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Javascript SDK documentation for more information.
Reach out on Discord for further assistance!
View Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation
Read Members of a Role
Get the wallet addresses of a specific role.
- React
- Javascript
- Python
- Go
- Unity
const minterAddresses = await contract.roles.get("minter");
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationconst minterAddresses = await contract.roles.get("minter");
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation
Grant Role
- React
- Javascript
- Python
- Go
- Unity
const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: grantRole,
isLoading,
error,
} = useGrantRole(contract);
if (error) {
console.error("failed to grant role", error);
}
return (
<button
disabled={isLoading}
onClick={() => grantRole({ role: "admin", address: {{wallet_address}} })}
>
Grant Role
</button>
);
};
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationawait contract.roles.grant("minter", "{{wallet_address}}");
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation
Revoke Role
- React
- Javascript
- Python
- Go
- Unity
const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: revokeRole,
isLoading,
error,
} = useRevokeRole(contract);
if (error) {
console.error("failed to revoke role", error);
}
return (
<button
disabled={isLoading}
onClick={() => revokeRole({ role: "admin", address: {{wallet_address}} })}
>
Revoke Role
</button>
);
};
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationawait contract.roles.revoke("minter", "{{wallet_address}}");
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation
Set All Roles (Overwrite)
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.
- React
- Javascript
- Python
- Go
- Unity
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 []
This snippet is for v3 of the SDK. Learn how to upgrade.
View in React SDK Documentationconst 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 []
This snippet is for v3 of the SDK. Learn how to upgrade.
View in Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation
Update Roles
- Read the current roles from the
get
function. - Modify the array for the role you want to update.
- 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);