I have this smart contract to send tokens to multiple addresses:

pragma solidity ^0.4.18;

contract ERC20 {
  function transfer(address _recipient, uint256 _value) public returns (bool success);

contract Airdrop {
  function drop(ERC20 token, address[] recipients, uint256[] values) public {
    for (uint256 i = 0; i < recipients.length; i++) {
      token.transfer(recipients[i], values[i]);

enter image description here

When I access the function "Drop" via MyEtherWallet, I don't know how to insert the addresses in the field "recipients".

I've tried this but none of them work:

0x0000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000002, 0x0000000000000000000000000000000000000003

0x0000000000000000000000000000000000000001 0x0000000000000000000000000000000000000002 0x0000000000000000000000000000000000000003

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

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

I can only execute the first one, but it says "Bad Instruction" or "Fail". In the other options I press the button "Write" but nothing happens

  • 2
    Both recipients and values have to be arrays of the same size. Try recipients = ["0x1234..", "0x1234..", "0x1234.."], values = [667, 668, 669] – Ismael Feb 26 '18 at 14:53
  • Thank you!! I didn't know that about values... It worked with recipients = 0x1234, 0x1234, 0x1234..... and values = 100, 101, 102.... Without "[]" and without " "" " – eduinvestor Feb 26 '18 at 15:15

Both recipients and values have to be arrays of the same size. Try recipients = 0x1234.., 0x1234.., 0x1234.., values = 667, 668, 669. Thanks to Ismael for the answer

| improve this answer | |

This is not an answer to your question but just a heads up, it is not recommended to iterate over transfers but to create a withdraw method. I recommend that you also look at re-entrancy attacks while you're at it and maybe implement some modifiers for safety.

| improve this answer | |

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.