I'm encountering a memory / storage issue (I think) w/ an array of addresses where I want to swap out one address with another.

Here's how I've initialized the array: address[] public maintainers;

Here's the function that performs the replacement:

  function replaceMaintainer(address _maintainer, address _newMaintainer)
    for (uint i = 0; i < maintainers.length; i++) {
      if (1 == 1) {
          maintainers[i] = _newMaintainer;

When I test in terminal here's what steps I take:

truffle(development)> wallet = MultiSigWallet.at('0x22f79daf3ea53041cbc153e15744b06ee5a12b8a')

truffle(development)> wallet.getMaintainers()
[ '0x65be59ed81a9a5f281e14e1c43d8acbd810aefbf',
  '0xe186acfce49f850708a888214345920f32ea0288' ]

I should note, the constructor sets up the initial maintainers.

truffle(development)> wallet.replaceMaintainer(0xe186acfce49f850708a888214345920f32ea0288, 0xee5c3ec339e01de884f65523b8dfe38b35f90d84)

truffle(development)> wallet.getMaintainers()
[ '0xee5c3ec339e021de43c7c49095748ac100000000',
  '0xe186acfce49f850708a888214345920f32ea0288' ]

You'll notice the first handful of characters are the same, but the remaining are changed. Any thoughts what's happening here?

This is very much similar to this MultiSig wallet's replaceOwner function. You'll notice I'm using 1 == 1 in the for loop. This is because the _newMaintainer changes once it's passed to the function.

  • Hi there. Can you show us the function that's adding the address to the array, as well as how you're calling it? (Can you also include how you're confirming what's been added to the array?) – Richard Horrocks Dec 12 '18 at 21:22
  • @dougiebuckets Where is the actual function you are using? I don't see it :) – Jesbus Dec 12 '18 at 21:36
  • @JesseBusman I've updated the inquiry w/ the function and additional info. Thanks! – dougiebuckets Dec 12 '18 at 21:38
  • The odd thing is, the address seems to change when it's passed to the function. I.e., even before I try to replace the existing _maintainer address w/ the _newMaintainer address – dougiebuckets Dec 12 '18 at 21:42
  • 2
    I'm suspecting the problem is that you need quotation marks around the addresses being passed to replaceMaintainer(). – Richard Horrocks Dec 12 '18 at 21:55

Your Answer

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

Browse other questions tagged or ask your own question.