1

I am doing a criptoCoin and I am using Solidity. I have an issue when create a crowdsale on function transfer(address receiver, uint amount); } the compile said No visibility specified. Defaulting to "public". function transfer(address receiver, uint amount); ^-----------------------------------------------^\

Hassan Abbas
  • 467
  • 2
  • 8
  • 28

1 Answers1

1

There's nothing necessarily wrong with your code - the compiler is just warning you that you didn't specify a visibility scope, and that it'll be defaulting it to public.

Something like this is probably what you want:

function transfer(address receiver, uint amount) external {}

The external keyword just means that the function can only be called from outside the contract - i.e. by other contracts/addresses on the Ethereum network. Other options include public, private, and internal. You can read more about these visibility keywords here.

elsyr
  • 736
  • 3
  • 9
  • pragma solidity ^0.4.16; interface token { function transfer(address receiver, uint amount); }contract Crowdsale { address public beneficiary; uint public fundingGoal; uint public amountRaised; uint public deadline; uint public price; token public tokenReward; mapping(address => uint256) public balanceOf; bool fundingGoalReached = false; bool crowdsaleClosed = false; event GoalReached(address recipient, uint totalAmountRaised); event FundTransfer(address backer, uint amount, bool isContribution); – Hassan Abbas Dec 24 '17 at 11:42
  • Again, not sure what your question is - all you've done is paste code (unformatted!) into the comments section. – elsyr Dec 24 '17 at 11:56
  • And? What is your question? – elsyr Dec 24 '17 at 12:05
  • I m using this codeine ether wallet but can't able to compile.and received this errir No visibility specified. Defaulting to "public". function transfer(address receiver, uint amount); ^-----------------------------------------------^ , – Hassan Abbas Dec 24 '17 at 12:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/161896/discussion-between-hassan-abbas-and-elsyr). – Hassan Abbas Dec 24 '17 at 12:15