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) {
console.log(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) {
App.markReadytoStart(reqId);
}).catch(function(err) {
console.error(err.message);
});
},
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.
Best Answer
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:
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.