DeclarationError: Identifier already declared near function

pragma solidity ^0.5.1;
contract Timestamp{
   uint start;
   uint end;
   function start() public{
      start = block.timestamp;
   function end() public {
      end = block.timestamp;
   function getTimeDif() view public returns(uint) {
      return end - start;

You can not declare function name same as variables name because solidity automatic create the getter function of public variables.

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.