I'm writing a smart contract to distribute the created tokens to multiple address. Looking around on the web I may found what I was looking for but I don't know how to insert the addresses in the field; I tried in different ways but none worked. This is the function to distribute token:

function distributeToken(address[] addresses, uint256 _value) onlyOwner {
     for (uint i = 0; i < addresses.length; i++) {
         balances[owner] -= _value;
         balances[addresses[i]] += _value;
         Transfer(owner, addresses[i], _value);

and this is the function in the contract:

enter image description here

I tried to insert the addresses in these ways:

0x0000000000000000000000000000000000000001 0x0000000000000000000000000000000000000002 0x0000000000000000000000000000000000000003

['0x0000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000002', '0x0000000000000000000000000000000000000003']

0x0000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000002, 0x0000000000000000000000000000000000000003

but no one worked. How can I solve this? Thank you

  • did it get execute for you? now, if enclosed with double-quote, the warning shows the transaction may fail & all gas will be consumed. And the transaction is passing with single-quote, and not quote, but unable to check the token transfer on the destination accounts. – Rajesh Nov 21 '17 at 6:03
  • Yes, I managed to execute it with double quote. Single quote pass the transaction but don't transfer tokens – user19489 Nov 21 '17 at 9:47
  • You mean, the above function is added to your token contract itself, or in a separate contract? – Rajesh Nov 21 '17 at 9:56
  • The function is in the token contract – user19489 Nov 21 '17 at 13:42
  • it could trigger the gas limitation problem when users try to send to too many addresses – Chris Phan Aug 21 '18 at 6:16

The addresses should be in "s and not 's:

["0x0000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000002", "0x0000000000000000000000000000000000000003"]

I tested this on Remix and it worked fine.

| improve this answer | |