本文所有智能合约源码来自网络。
1.lottery01.sol
特点:限定人数,随机数与合约拥有者无关;
合约编译通过:
pragma solidity ^0.4.23;
contract Lottery10Users {
address[10] participants; //限制为10个用户
uint8 participantsCount = 0; //本轮已参与用户数
uint randNonce = 0;
function join() public payable {
//用户必须支付 0.1 ETH 才能加入游戏
require(msg.value == 0.1 ether, "Must send 0.1 ether");
require(participantsCount < 10, "User limit reached");
require(joinedAlready(msg.sender) == false, "User already joined");
participants[participantsCount] = msg.sender;
//第10个用户进入后,选择获胜者
participantsCount++;
if (particip