0

When calling from Remix IDE, it executes successfully. But when calling from web3 v1.2.9, it gives the above error.

Here is the contract : https://ropsten.etherscan.io/address/0x8ec0ca8b2fb402ff86cee42ade5e9072a6156b63#code

sol code:

/**
 *Submitted for verification at Etherscan.io on 2020-07-16
*/

pragma solidity 0.5.1;

contract SendEther {
    
    event Transferred(uint256 value , address sender);
    
    function() external payable{}
    
    function SendEtherToAddresses(address payable[] memory _addresses, uint256[] memory _amounts) public payable {
        
        for (uint256 i=0; i < _amounts.length; i++) {
            _addresses[i].transfer(_amounts[i]);
        }
        
    emit Transferred(msg.value, msg.sender);
    }
}

js code:

window.web3 = new Web3(ethereum);
ethereum.enable();
eth_Contract = new web3.eth.Contract(abi, contractAddress);

var addresses = '0xB0Dc12Ef30D707A52a079d915435Ee0B5C03e8CC';
var amounts = '0.0005'

const address = web3.utils.toChecksumAddress(ethAddress); // metamask address

  Eth_Add_Arr = addresses.split(",");
  Eth_Amt_Arr = amounts.split(",");

                        var Eth_Amt_Arr_1=new Array();
                        TotalAmount = 0;

                        for (var i = 0; i < Eth_Amt_Arr.length; i++) {

                            var x = parseInt(web3.utils.toWei(Eth_Amt_Arr[i], "ether"));
                            Eth_Amt_Arr_1[i] = x.toString();
                            TotalAmount += x;
                        };

                        eth_Contract.methods.SendEtherToAddresses(Eth_Add_Arr, Eth_Amt_Arr_1).send({
                            from: address,
                            to: contractAddress,
                            value: TotalAmount,
                            gasPrice: web3.utils.toWei("1", "Gwei"),
                            gas: 40000
                        },
                            (error, transactionHash) => {
                                if (!error) {
                                    console.log(transactionHash);
                                    SaveRegistration(address, sponsorId, transactionHash);
                                }
                                else {
                                    swal(e);
                                }
                        })

Please help!

0

Check last transaction: https://ropsten.etherscan.io/tx/0xd45d32f88b6f8fc88c1a5984bf9d85aea50d6e50df0c22f461e39557d1296b6c

#   Name        Type        Data
0   _addresses  address[]   b3f17500e86c3cce3ecb47aba1073c4ffa940ec5
1   _amounts    uint256[]   500000000000000

You try send ETH to another contract 0xb3f17500E86c3Cce3Ecb47ABa1073c4FFA940eC5which cannot accept ETH because it has no fallback function like sender contract:

function() external payable{}

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.