0

As a smart contract developer, it's important to make sure that only authorized users are able to perform certain actions within the contract, while also maintaining the security of the contract and protecting it from malicious attacks.

Apart from openzplin any other best solution for this

2 Answers 2

0

I normally use the Access Contract Library from Open Zeppelin, here you can find the info: https://docs.openzeppelin.com/contracts/4.x/api/access

Hope it helps!

0

AccessControl.sol from Open Zeppelin is awesome way to do this

I normally use DEFAULT_ADMIN_ROLE ONLY for role management, leaving any other action under tight control.

Example Usage:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/AccessControl.sol";

contract MyContract is AccessControl {
    bytes32 public constant NEW_ROLE = keccak256("NEW_ROLE");
    bytes32 public constant ONE_MORE_ROLE = keccak256("ONE_MORE_ROLE");

    constructor() {
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(NEW_ROLE, msg.sender);
        _grantRole(ONE_MORE_ROLE, msg.sender);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.