samedi 8 janvier 2022

Solidity random number with server

I know that in blockchain we can't create a truly random number, but what if create a random number with Javascript on server and then just paste it to the function call. Something like this: JS:

await contract.random(Math.random() * 10**16);

Solidity:

function random(uint256 _randomNum) public view returns(uint256) {
        return uint256(keccak256(abi.encodePacked(block.timestamp, _randomNum)));
        //use in a contract
}

Will it be secure?




Aucun commentaire:

Enregistrer un commentaire