0

I launched a wallet and created a safe on the safe website with 3 owners and 2/3 threshold. Now i have an erc20 token contract which is ownable. I have some functions in erc20 token contract which are onlyOwner access controlled.

Now i want to make the safe contract as the owner and for onlyOwner function i want to have the threshold required to run it i.e i would need threshold signatures to call mint and burn functions .

How do i do that? Is it even possible? Since safe is implemented using proxy , do i make the proxy address as the owner or the implementation ?

2 Answers 2

1

What you want is possible. First, you must use the proxy address of your multisig wallet.
Use the grantRole function of your erc-20 token with this address.
Next, just make a propos from one of the owners of the wallet for a mint, confirm the action from 2 owners and complete it.
I can give detailed advice in a personal.
Write to:[email protected]

0

I suppose you could do something like this. Most likely a cleaner way to do it, but I think this would do the job if I am understanding correctly.


    contract MultiSigExample {
        struct Signers {
            address[] signers;
        }

        Signers public signers;

        //Minimum number of signatures to authorize a multisig authorized function.
        uint public constant multiSigThreshold = 2;
        
        //Mapping of signer -> function signature -> signed.
        mapping(address => mapping(bytes4 => bool)) multiSig;
        mapping(address => bool) isSigner;
        
        //Ensures msg.sig has two signatures from authorized signers.
        modifier onlyMultiSig() {
           bytes4 memory fSig = msg.sig;
           address[] memory signers = Signers.signers;
           uint signatures = 0;
           for (uint i=0; i<signers.length()-1;){
               if (multiSig[signers[i][fSig]){
                  signatures++;
                  
                  if signatures >= multiSigThreshold {
                      break;
                  }
               }
               unchecked {
                   ++i;
               }
           }
           require(signatures >= multiSigThreshold, "Unauthorized function call"); 
           //Reset the signature status to false for reusability.
           for(uint i=0; i<=signatures;){
               multiSig[signers[i]][fSig] = false;
               unchecked {
                   ++i;
               }
           }
           
           _;
        }

        //Require msg.sender is an authorized signer.
        modifier onlySigner() {
            require(isSigner[msg.sender], "Unauthorized Signer");
            _;
        }
        
        constructor(address[] memory _signers) {
             signers = Signers({signers: _signers});
             for signer in _signers {
                 isSigner[_signer] = true;
             }
        }
        
        //Function to authorize fSig from a specific account.
        function sign(bytes4 memory fSig) public onlySigner {
            multiSig[msg.sender][fSig] = true;
        }
        
        //Only callable after two signatures from the signers.
        function mint() external onlySigner onlyMultiSig {
            
        }

        //Only callable after two signatures from the signers.
        function burn() external onlySigner onlyMultiSig {

        }
    
    }

Your Answer

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

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