I've been trying to create a crowd sale contract but it does not compile and comes with the error "unused local variable". Really not sure what to do as the code came directly from the ethereum crowd sale guide.
-
You usually get a warning for that. Try to remove that token contract or add some code to the transfer function – BalaChandra Jul 20 '17 at 10:15
-
Hi there. Where have you copied this code from? – Richard Horrocks Jul 20 '17 at 13:22
-
This question seems to be the same as one that was previously asked, so flagging as duplicate... – Richard Horrocks Aug 13 '17 at 11:41
-
1Possible duplicate of Error trying to create a crowdfunding contract? – Richard Horrocks Aug 13 '17 at 11:41
Try this instead:
interface ERC20I {
function transfer(address _recipient, uint256 _amount) public returns (bool);
}
contract Crowdsale {
ERC20I public tokenInterface;
function Crowdsale(address _tokenAddress) {
tokenInterface = ERC20I(_tokenAddress);
}
}
Then whenever you want to transfer funds use this code:
require(tokenInterface.transfer(recipient, amount));
you can just ignore this warning or if you want to get rid of it you could use the following declaration:
contract token { function transfer(address , uint ){ } }
instead of
function transfer(address receiver, uint amount){ }
Perhaps you are not using amount field when trying to send token rewards? Can you paste full code of the contract here, or share it through ethfiddle.io?
I have done some basic crowd funding contract development within Blockgeek's course. Maybe you can use the template I have picked up from there: https://ethfiddle.com/TN9MtiBVKq
In general, Ethfiddle is a good place to compile your code, and see errors popping up. Mist is really not the best place to check your code.
The warning is there because you are not using the two variables which is being passed in transfer function.
You are passing two variables address receiver and uint amount to transfer function and the function is empty.
contract token {
function transfer(address receiver, uint amount) {
//...
//use the parameters here to avoid the warning.
}
}