Giveth / minime

Minimi Token. ERC20 compatible clonable token
GNU General Public License v3.0
669 stars 290 forks source link

How to take back ownership of MiniMeToken after a Campaign? #50

Closed d416 closed 6 years ago

d416 commented 6 years ago

If I understand the README.md correctly, the steps to launch a Token + Campaign are:

  1. Create MiniMeTokenFactory

  2. Create the MineMeToken contract using address of contract created in step 1 - controller will default to address of contract owner/deployer

  3. Create the Campaign contract

  4. Using the MineMeToken changeController function, set the controller to be the the Campaign's address created in step 3.

This works great in testing, but we've essentially lost ownership of the MiniMeToken when the controller was changed in step 4. So when the Campaign timeline is finished the Controller of the MiniMeToken cannot be reverted back to the original owner since we've now lost ownership, which now belongs to the dead Campaign.

Retaining ownership of the Token contract would be essential in launching another Campaign and assigning the Controller to that Campaign... Am I missing a step here?

Great first step in this framework. It has great potential for contract use!!!

jbaylina commented 6 years ago

The idea of the smart contracts is to do programs that no body controls, even the creator of the contract. Loosing the ownership of a contract is part of the magic of the decentralisation.

Said that, you can always add a method in the controller that transfer back the ownership.

d416 commented 6 years ago

I see the rationale now... in fact it appears this is what Aragon did for their token launch - ie. auto-reassign control to a placeholder contract after a sale.

That said, if it's a once-and-done campaign, I'm not seeing a lot of value in keeping the controller in a separate contract.. it may even save gas to integrate it?

I would propose an alternative Controlled.sol which takes into account the Owner of the Controlled contract, so only the Owner can set the Controller. The Owner can do this for as many times as there are Campaigns - eg. Seed Round, Pre-sale, Final Sale - then on the last and final Campaign, the Campaign contract can set both the Owner and Controller to a neutral Contract or even the Token itself to keep things 'decentralized'. This might be a better option for smaller DACs who need something to work out of the box.

Here is an example (unaudited) of how this might be achieved in Controlled.sol in case anyone is looking to support the use case above... it uses the Owned contract code from the sample campaign so that only the Owner can change the controller, change owners, or step down as Owner...

pragma solidity ^0.4.18;

contract Owned {
    /// @dev `owner` is the only address that can call a function with this
    /// modifier
    modifier onlyOwner { require (msg.sender == owner); _; }

    address public owner;

    /// @notice The Constructor assigns the message sender to be `owner`
    function Owned() { owner = msg.sender;}

    /// @notice `owner` can step down and assign some other address to this role
    /// @param _newOwner The address of the new owner. 0x0 can be used to create
    ///  an unowned neutral vault, however that cannot be undone
    function changeOwner(address _newOwner) onlyOwner {
        owner = _newOwner;
    }
}

contract Controlled is Owned {
    /// @notice The address of the controller is the only address that can call
    ///  a function with this modifier
    modifier onlyController { require(msg.sender == controller); _; }

    address public controller;

    function Controlled() public { controller = msg.sender;}

    /// @notice Changes the controller of the contract - ony the Owner can execute this operation
    /// @param _newController The new controller of the contract
    function changeController(address _newController) public onlyOwner {
        controller = _newController;
    }
}