1
function multiowned(address[] _owners, uint _required) {
    m_numOwners = _owners.length + 1;
    m_owners[1] = uint(msg.sender);
    m_ownerIndex[uint(msg.sender)] = 1;
    for (uint i = 0; i < _owners.length; ++i)
    {
        m_owners[2 + i] = uint(_owners[i]);
        m_ownerIndex[uint(_owners[i])] = 2 + i;
    }
    m_required = _required;
}

Can anyone help me understand the above solidity code and use of m_owners[1] = uint(msg.sender); ?

Source code here https://github.com/ConsenSys/MultiSigWallet/blob/master/MultiSigWalletWithDailyLimit.sol

4
  • 1
    This code is not complete, we don't see the declarations of m_numOwners m_owners, m_ownerIndex and m_required
    – Jesbus
    Mar 11, 2019 at 18:23
  • 1
    I have added link to the full source code. I am sorry Mar 11, 2019 at 18:37
  • I believe what it's doing is making a fresh list of _owners with msg.sender being added to the first index of this new map and all of the other address of _owners being pushed to +1 index in m_owners Mar 11, 2019 at 19:04
  • @SaitejaKuruva The full source you linked to doesn't seem to relate to the code you shared. What am I missing?
    – user19510
    Mar 11, 2019 at 22:39

1 Answer 1

1

The line in question:

m_owners[1] = uint(msg.sender);

stores msg.sender at index 1 of the array m_owners. Presumably the type of m_owners is an array (or mapping) of uints rather than addresses, so msg.sender is first cast to a uint.

msg.sender is the account that called the function multiowned.

3
  • But it's showing me the error when I am trying to run this code on remix. It says undeclared identifier m_numOwners = _owners.length + 1; Mar 12, 2019 at 10:48
  • You'd have to share the rest of the code. My guess would be that you didn't declare a variable called m_numOwners anywhere.
    – user19510
    Mar 12, 2019 at 14:15
  • (The code you linked to in your question seems unrelated.)
    – user19510
    Mar 12, 2019 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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