Search code examples
ethereumsoliditysmartcontracts

DeclarationError : undeclared identifier


I am writing the smart contract for lottery project. and this is the function in which one line causing error!

function WinnerOfLottery() public view returns(address){
        require(msg.sender==manager);
        require(participants.length >=3);
        **uint r=random();**
        address payable winner;
        uint randIndex = r % participants.length;
        winner= participants[randIndex];
        return winner;
    }

Solution

  • The error was in the decleration of the function and i made the function for generating random winners