I am new to Solidity and Ethereum. I am at the stage where I have worked with basic HelloWorld and similar examples.
I have created a contract to generate a random number as follows
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
contract RandomNumber {
function generateRandomNumber(uint range) public view returns(uint) {
// As of 1-1-22 this contract is working okay at https://remix.ethereum.org/
// However I am having issues in running it through the Visual Studio Code IDE
return uint(keccak256(abi.encodePacked(block.timestamp,block.difficulty, msg.sender))) % range;
}
}
This contract is working when I deploy and run it at https://remix.ethereum.org/
However, If I try to deploy & run it within Visual Studio Code I get the following error
BN { negative: 0, words: [ 3, <1 empty item> ], length: 1, red: null }
Why should this happen? Any inputs are appreciated. I know I might be missing something basic here
Thanks in advance