0

I need to pay 50+ addresses each with different amounts of ether. Right now im doing it by looping through an array on my front end and calling the contract function each time with the address and its corresponding amount which leads to around 50 metamask popups. Is it at all possible to pass an array with the addresses and amounts to the contract and let it all happen in 1 transaction.

1

EDIT if the contract is not already deployed.

Yeah you can totally do that. Just keep that in mind it will cost more gas

function bulkAddress(uint256[] _amount, address[] _acct) public {
        for(uint i = 0; i< _acct.length; i++){
            ...your logic
        }
    }

and can call this function using web3

contractInstance.methods.bulkAddress(amountsArr, accountArr).send()

for more details

  • From the description, it sounds to me like the contract is already deployed. And since this dude cannot just add a function to an already deployed contract, it means that the answer to his question is no. – goodvibration Jun 26 '19 at 8:30
  • its not deployed. sorry if it sounded like that :D – Sundeep Kumar Jun 26 '19 at 9:02
  • i wanted to do it this way coz 5 out of 20 transactions kept failing in metamask when i was doing it manually and it was getting hard to keep track of which ones failed and an even greater hassle when the number of addresses to be paid went up. – Sundeep Kumar Jun 26 '19 at 9:16

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.