0

I'm using web3js version 0.20.7

The smart contract originally had a function (called whiteListAddress(address _address, bool value) ) that took an address and a boolean value, which was called like this in the js code:

var getData = Coursetro.whiteListAddress.getData(whitelistaddress,1);
        const paymentAddress = '0x...' 

          web3.eth.sendTransaction({
          to: paymentAddress,
          gas: 6000000,
          data: getData,
          value: web3.toWei(0, 'ether')
        }, (err, transactionId) => {
          if  (err) {
            console.log('whitelist failed', err)
            //$('#status').html('Payment failed')
          } else {

         console.log('whitelist successful', transactionId)
            //$('#status').html('Payment successful')

            }
        })

This worked just fine, but i was required to add a function that did this process for a bunch of addresses, so I made a function which takes an array instead, like this bulkWhiteList(address[] _addresses, bool value)

I'm calling it the same way (obviously, wWallet is an array of wallets):

var getData = Coursetro.bulkWhiteList.getData(wWallet,1);
web3.eth.sendTransaction({
          to: paymentAddress,
          gas: 6000000,
          data: getData,
          value: web3.toWei(0, 'ether')
        }, (err, transactionId) => {
          if  (err) {
            console.log('whitelist failed', err);
            console.log(wWallet)
            $('#status').html('Transaction failed');
          } else {

         console.log('whitelist successful', transactionId)
            $('#status').html('Transaction sent')

            }
        })

The function fires and the transaction is confirmed, but when it seems at some point the array is broken and the wallets don't show in the appropiate format, since in etherscan this is what is being passed apparently:

eth network result

but when i print the array in my console this is what i see:

array in console

So, to summarize, what is the problem with the array I am passing? Or is there something else that i'm doing wrong?

-- EDIT --------

Just tried this approach:

Coursetro.bulkWhiteList(wWallet,1,{
          to: paymentAddress,
          gas: 6000000,
          value: web3.toWei(0, 'ether')
        }, (err, transactionId) => {
          if  (err) {
            console.log('whitelist failed', err);
            console.log(wWallet);
            $('#status').html('Transaction failed');
          } else {
              console.log(wWallet);
         console.log('whitelist successful', transactionId);

            $('#status').html('Transaction sent')
            }
        });

got the same result

  • The issue seems to be with wWallet and it is unrelated to Ethereum. How wWallet is created? Do you known how many entries wWallet contains? In Etherscan screenshot there are more than 100. Also web3 v0.20 wasn't very good at validating data (it didn't at all). – Ismael Apr 8 at 14:26
  • 1
    Thank you for replying, but i checked and the function is working now, oddly enough. I will delete the question soon. However, the only reason i'm using this version, is because it is an old project. I got hired recently and took over it, so in order to not re-write everything, i'm just using this version – F_Bass Apr 8 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.