I'm currently using web3.js to use a function on form submit, which is transfer(address _to, uint256 _value)
I'm able to call contract function, but I get Error: Invalid number of arguments to Solidity function trying to use the transfer function, suppling both to address and amount of token.
Here part of my code:
function sendtoken(to, amount){
var to = to;
var amount = amount;
var settx = contract.transfer(to,amount);
return settx;
}
Calling it (don't worry, my contract correctly called in contract var
var formData = getFormObj("tokeform");
console.log(formData.destinationtoke);
console.log(formData.amounttoke);
var tx = sendtoken(destinationtoke, amounttoke);
var tx = JSON.stringify(tx, null, " ");
console.log(tx);
This is where I get the error. Here the contract function:
function transfer(address _to, uint256 _value) {
if (genesisAddress[_to]) throw;
if (balances[msg.sender] < _value) throw;
if (balances[_to] + _value < balances[_to]) throw;
if (genesisAddress[msg.sender]) {
minedBlocks = block.number - initialBlockCount;
if(minedBlocks % 2 != 0){
minedBlocks = minedBlocks - 1;
}
if (minedBlocks < 23652000) {
availableAmount = rewardPerBlockPerAddress*minedBlocks;
totalMaxAvailableAmount = initialSupplyPerAddress - availableAmount;
availableBalance = balances[msg.sender] - totalMaxAvailableAmount;
if (_value > availableBalance) throw;
}
}
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
}
Can someone tell me how to solve this?