I made this contract:
pragma solidity ^0.4.25;
contract MyTransfer {
address owner;
uint data;
uint private amount;
string greeting = "Hello World";
constructor() public {
owner = msg.sender;
}
function greet () constant public returns (string) {
return greeting;
}
function deposit() public payable {
amount += msg.value;
}
function withdraw() public {
msg.sender.transfer(amount);
}
function kill () public {
require(owner == msg.sender);
selfdestruct(owner);
}
}
Compile and deploy successfully finished.
Then on truffle develop console.
mt = MyTransfer.at(MyTransfer.address);
>mt.greet();
works
>mt.deposit(1);
Error: Invalid number of arguments to Solidity function
How can I make transfer on truffle console?
It is not working because your deposit() function is not waiting for any params. You need to send some value with your transaction in order for it to work. Try this:
mt.deposit({value: 'the amount of ether you want to send'});