I am trying to call a function in my Solidity file (Coder.sol), while passing through a parameter from my App.js file. My function in my App.js file looks like this:

handleStartRequirement: function(reqId, payment_amount) {

  var coderInstance;
  App.web3.eth.getAccounts(function(error, accounts){
    if (error) {
    // Set client address equal to a testrpc account
    let client = accounts[0];
    App.contracts.Coder.deployed().then(function(instance) {
      coderInstance = instance;
      const thing =  coderInstance.startRequirement.call().then(res => {
        return coderInstance.startRequirement(payment_amount, {from: client, value: web3.toWei(1, "ether")});
      }).catch(err => console.error(err));
    }).then(function(success) {
    }).catch(function(err) {

The startRequirement function in my Solidity file looks like this:

function startRequirement(address _client, uint256 _contract_amount) returns (bool) { client = _client; return true; }

I'm not sure what I'm doing wrong but I am getting the following error every time:

Error: Invalid number of arguments to Solidity function

I am declaring the following variables in my Solidity file:

address public client; //ETH wallet address for the client

int contract_amount;

The parameters would be getting transferred via the click of a button.

3 Answers 3


So in the end, the issue was that my .sol file was not able to take in an integer parameter from my App.js file. The way I solved this was to simply remigrate with the command:

truffle migrate --reset

The previous block that my contract was sitting on may have just been corrupt with code, so migrating all my .sol files to a new block solved the issue.


you have this error because you provide only one argument instead two(as declared in the contract) in this line:

coderInstance.startRequirement(payment_amount,{from: client, value: web3.toWei(1, "ether")});
      }).catch(err => console.error(err));

you need to provide an address try

coderInstance.startRequirement(payment_amount,eth.acccounts[0],{from: client, value: web3.toWei(1, "ether")});
      }).catch(err => console.error(err));

You are calling startRequirement twice from Javascript. In each case you have to give it the 2 parameters it expects:

//                                                !!Here!!
const thing = coderInstance.startRequirement.call(to_whom, payment_amount).then(res => {
//                                        !!And here!!
    return coderInstance.startRequirement(to_whom, payment_amount, {from: client, value: web3.toWei(1, "ether")});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.