Blockchain 是否有可能创建具有稳定度的不可预测随机数?

Blockchain 是否有可能创建具有稳定度的不可预测随机数?,blockchain,ethereum,solidity,Blockchain,Ethereum,Solidity,我最近一直在研究这个话题,大多数资源都说不可能在链上生成随机数。然而,我遇到一篇帖子说,这个函数可以生成一个不可预测的数字。有没有办法预测这个函数 function rand() public view returns(uint256) { uint256 seed = uint256(keccak256(abi.encodePacked( block.timestamp + block.difficulty + ((uint256(keccak256(a

我最近一直在研究这个话题,大多数资源都说不可能在链上生成随机数。然而,我遇到一篇帖子说,这个函数可以生成一个不可预测的数字。有没有办法预测这个函数

function rand() public view returns(uint256) {
    uint256 seed = uint256(keccak256(abi.encodePacked(
        block.timestamp + block.difficulty +
        ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)) +
        block.gaslimit + 
        ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)) +
        block.number
    )));

    return (seed - ((seed / 1000) * 1000));
}
有没有办法预测这个函数

function rand() public view returns(uint256) {
    uint256 seed = uint256(keccak256(abi.encodePacked(
        block.timestamp + block.difficulty +
        ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)) +
        block.gaslimit + 
        ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)) +
        block.number
    )));

    return (seed - ((seed / 1000) * 1000));
}
矿工可以使用符合其他条件的
时间戳
发布其区块
编号

  • 难度
    给出了一段时间
  • coinbase
    提供的时间更长
  • msg.sender
    (真正的交易发送者和签名者)可以是矿工的地址之一

并没有办法在链上产生真正不确定的随机数。但您可以使用oracle返回链外生成的“随机”数字。

创建不可预测的数字本身是不可能的。在创建骰子游戏方面,如果我们使用future block来确定中奖数字会怎么样。玩家将在当前区块下注并锁定,我们将根据第二份合同确定赢家。这样可能吗?如果可能的赢款足够大,玩家可以继续使用他们将要挖掘的下一个区块的参数下注(直到他们实际使用预期参数挖掘)。需要猜测正确的
block.timestamp
,他们将以1秒的精度进行挖掘,这大大降低了几率,并且对于大多数实际用例来说是合理的。但要回答最初的问题——它仍然是可确定的(而不是真正随机的)。。。编辑:不诚实的矿工也可以在一个街区的多个地址下多个赌注,以增加他们的机会。谢谢你的回答。我真的很感激。