Tinku R

Please help me in solving this compilation error in solidity

Please help me in resolving this code

/home/ubuntu/token_sale/contracts/SandeepDappToken.sol:17:34: DeclarationError: Identifier not found or not unique.
        function  transfer(address _to, unit256  _value) public returns (bool success)
Compilation failed. See below
pragma solidity ^0.4.23;

contract SandeepDappToken{
           // constructor

           // set the v ariable
        uint256  public totalSupply;

        string public name = ‘Dapp’;

        mapping(address => uint256) public balanceOf;
        constructor(uint256 _initialSupply )  public {
                balanceOf[msg.sender] = _initialSupply;
                totalSupply = _initialSupply;
        function  transfer(address _to, unit256  _value) public returns (bool success)
                require(balanceOf[msg.sender] >= _value);



Best answer

Marwan Galal
Hey Tinku, in “function  transfer(address _to, unit256  _value) public returns (bool success)”, you misspelt uint256 as unit256 so it throws a declaration error. Also, I’m assuming this is incomplete code, but if its not, you should use any variables you pass into a function – in this case, you should use the variable “_to”. Hope this helps!


  1. 2
    Tinku R