1

solidity code:

function fundIt() public payable returns (bool) {
            require(msg.value > .01 ether);
            address addr = this;
            donors.push(msg.sender);
            amount = addr.balance;

        }

and here is how I am calling it:

const $fundIt = async () =>{

       const fundit = await  mycontract.methods.fundIt({
                                                        from: '0xbf443ed3b73159d5bf427568359c7de4103413c3', 
                                                        value: 3 
                                                       })
                                                .then(res => 
                                                      console.log('Success', res))
                                                .catch(err => console.log(err))                                                             

     }

it is not working!! all I got was:

Uncaught (in promise) Error: Invalid number of parameters for "fundIt". Got 1 expected 0!

Does anyone know why this is happening? thank you!

0

You need to call send() after calling fundIt(). You need to specify from and value in send()

       const fundit = await  mycontract.methods.fundIt().send({
                                                    from: '0xbf443ed3b73159d5bf427568359c7de4103413c3', 
                                                    value: 3 
                                                   })
                                            .then(res => 
                                                  console.log('Success', res))
                                            .catch(err => console.log(err)) 
  • thx! now I have this err popping up: ``` Returned error: VM Exception while processing transaction: revert ``` – Sofiane Apr 25 '18 at 18:02
  • The amount you enter for value is in wei. If you wish to send 3 ether, try setting value: 3*10**18 – Zack McGinnis Apr 25 '18 at 18:08

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.