1

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?

4

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

  • 1
    I was here to check if it's address[] payable or address payable[]. You confirmed it, so thanks. – shad0w_wa1k3r Jun 30 at 20:59

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.