0

I am using the template code found on the Ethereum website for crowdfunding and when I insert it in the solidity contract source code in the Ethereum wallet, it returns:

Unused local variable

contract token { function transfer(address receiver, uint amount){  } }

What am I supposed to write there so the contract gets properly read in the wallet?

Badr Bellaj
  • 18,780
  • 4
  • 58
  • 75
Nat
  • 1

3 Answers3

1

This function doesn't have any specified worked is done . Either remove the contract transfer or make the function as fallback.

Here is example :

contract token {  
    function (){  

        }   
//any code that you want to implement in here , like any functions , modifiers etc.  

}  
Badr Bellaj
  • 18,780
  • 4
  • 58
  • 75
Gopal ojha
  • 2,259
  • 2
  • 11
  • 21
1

Remove the names of variables and just specify the datatype of the variable.

Instead of contract token { function transfer(address receiver, uint amount){ } } in your code, use contract token { function transfer(address, uint){ } }

Prabhu Vinod
  • 153
  • 6
0

Warning: Unused local variable contract token { function transfer(address receiver, uint amount){ } }

This is a warning. The code will still compile, but it tells you that something looks strange or is using outdated Solidity practices.

The two current answers are both incorrect. This warning is just saying that you do not do anything with the locally scoped variables that you have defined as function arguments. If you do not want your contract to do anything then this is fine.

Whilst here it is worth noting that programming best practices suggest that contract names should have the first letter capitalized.

More information on deploying a token can be found here.

Thomas Clowes
  • 4,385
  • 2
  • 19
  • 43
  • 1
    If it's being compiled in the Ethereum Wallet interface, then the warning will be treated as an "error" (inverted commas, because it's still only labelled as a warning... ), and the contract won't be deployable. This is one of the "official" example contracts on ethereum.org that isn't fully fleshed-out - because it's only example skeleton code - but which people seem to be copying verbatim and expecting to work :-\ – Richard Horrocks Aug 13 '17 at 11:39
  • you couldn't just ignore it, "Could not compile source code." – NineCattoRules Sep 10 '17 at 10:00