9

I'm trying to write a contract that uses an address[] array which should contain payable addresses. But apparently creating a payable address array doesn't work in solidity 0.5.x.

All I'm trying to do is to run a loop that transfers funds to each address in the array like this:

address[] users;
// set users
...
for (uint i = 0; i < users.length; i++){
  users[i].transfer(<some_value>);
}

My super dumb solution would be to use a proxy mapping to get a payable address. It would look like this and does actually compile.

address[] users;
mapping(address => address payable) proxy;
// set users and proxy
...
for (uint i = 0; i < users.length; i++) {
   address payable u = proxy[users[i]];
   u.transfer(<some_value>);
}

Obviously this is pretty dumb. Is there a way to make an address array payable?

1 Answer 1

27

Oh boy I'm stupid. address payable[] users works. Nevermind people. This question never happened...

2
  • 4
    I was here to check if it's address[] payable or address payable[]. You confirmed it, so thanks. Commented Jun 30, 2019 at 20:59
  • I love these answers where the asker answers himself...and also apparently me in the future lol Commented Nov 11, 2021 at 18:08

Your Answer

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

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