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. enter image description here


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){  }
  • i think you need to share your code with us – Badr Bellaj Apr 19 '18 at 22:12

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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