contract LexDAI is LexDAORole, ERC20, ERC20Detailed {
    // $DAI details:
    address private $DAIaddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    ERC20 public $DAI = ERC20($DAIaddress);
    
    // $LXD details:
    string public emoji = "⚖️💵⚔️️";
    string public lexDAOchat = "lexdao.chat || lexdao.club"; // lexDAO portals for governance requests
    uint8 public version = 2;
    
    // lexDAO receives ether (Ξ) payments related to governance requests
    address payable public lexDAO = 0x97103fda00a2b47EaC669568063C00e65866a633; // initial Aragon Agent
    
    event LexDAOPaid(uint256 indexed payment, string indexed details);
    event LexDAOTransferred(address indexed newLexDAO);

    constructor () public ERC20Detailed("lexDAI", "LXD", 18) {} 
    
    function mint$LXD(uint256 amount) public { 
        $DAI.transferFrom(msg.sender, address(this), amount); // deposit $DAI 
        _mint(msg.sender, amount); // mint $LXD in return
    }
    
    function redeem$LXD(uint256 amount) public { 
        $DAI.transfer(msg.sender, amount); // return $DAI 
        _burn(msg.sender, amount); // burn $LXD from caller
    }
    
    // lexDAO functions
    function payLexDAO(string memory details) public payable { 
        lexDAO.transfer(msg.value);
        
        emit LexDAOPaid(msg.value, details);
    }
    
    function resolve$LXD(address from, address to, uint256 amount) public onlyLexDAO {
        _transfer(from, to, amount); // lexDAO Agent resolves $LXD balances 
    }
    
    function transferLexDAO(address payable newLexDAO) public {
        require(msg.sender == lexDAO);
        lexDAO = newLexDAO; // new lexDAI beneficiary account
        
        emit LexDAOTransferred(newLexDAO);
    }
}
function payLexDAO(string memory details) public payable { 
    lexDAO.transfer(msg.value);
        
    emit LexDAOPaid(msg.value, details);
}

// lexDAO functions