Source Code
Overview
MATIC Balance
0.0000000000002 MATIC
More Info
ContractCreator:
Multichain Info
N/A
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x43521728...B76d54d10 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
Casino
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; contract Casino { struct ProposedBet { address sideA; uint value; uint placedAt; bool accepted; } // struct ProposedBet struct AcceptedBet { address sideB; uint acceptedAt; uint randomB; } // struct AcceptedBet // Proposed bets, keyed by the commitment value mapping(uint => ProposedBet) public proposedBet; // Accepted bets, also keyed by commitment value mapping(uint => AcceptedBet) public acceptedBet; event BetProposed ( uint indexed _commitment, uint value ); event BetAccepted ( uint indexed _commitment, address indexed _sideA ); event BetSettled ( uint indexed _commitment, address winner, address loser, uint value ); // Called by sideA to start the process function proposeBet(uint _commitment) external payable { require(proposedBet[_commitment].value == 0, "there is already a bet on that commitment"); require(msg.value > 0, "you need to actually bet something"); proposedBet[_commitment].sideA = msg.sender; proposedBet[_commitment].value = msg.value; proposedBet[_commitment].placedAt = block.timestamp; // accepted is false by default emit BetProposed(_commitment, msg.value); } // function proposeBet // Called by sideB to continue function acceptBet(uint _commitment, uint _random) external payable { require(!proposedBet[_commitment].accepted, "Bet has already been accepted"); require(proposedBet[_commitment].sideA != address(0), "Nobody made that bet"); require(msg.value == proposedBet[_commitment].value, "Need to bet the same amount as sideA"); acceptedBet[_commitment].sideB = msg.sender; acceptedBet[_commitment].acceptedAt = block.timestamp; acceptedBet[_commitment].randomB = _random; proposedBet[_commitment].accepted = true; emit BetAccepted(_commitment, proposedBet[_commitment].sideA); } // function acceptBet // Called by sideA to reveal their random value and conclude the bet function reveal(uint _random) external { uint _commitment = uint256(keccak256(abi.encodePacked(_random))); address payable _sideA = payable(msg.sender); address payable _sideB = payable(acceptedBet[_commitment].sideB); uint _agreedRandom = _random ^ acceptedBet[_commitment].randomB; uint _value = proposedBet[_commitment].value; require(proposedBet[_commitment].sideA == msg.sender, "Not a bet you placed or wrong value"); require(proposedBet[_commitment].accepted, "Bet has not been accepted yet"); // Pay and emit an event if (_agreedRandom % 2 == 0) { // sideA wins _sideA.transfer(2*_value); emit BetSettled(_commitment, _sideA, _sideB, _value); } else { // sideB wins _sideB.transfer(2*_value); emit BetSettled(_commitment, _sideB, _sideA, _value); } // Cleanup delete proposedBet[_commitment]; delete acceptedBet[_commitment]; } // function reveal } // contract Casino
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_commitment","type":"uint256"},{"indexed":true,"internalType":"address","name":"_sideA","type":"address"}],"name":"BetAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_commitment","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BetProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_commitment","type":"uint256"},{"indexed":false,"internalType":"address","name":"winner","type":"address"},{"indexed":false,"internalType":"address","name":"loser","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BetSettled","type":"event"},{"inputs":[{"internalType":"uint256","name":"_commitment","type":"uint256"},{"internalType":"uint256","name":"_random","type":"uint256"}],"name":"acceptBet","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"acceptedBet","outputs":[{"internalType":"address","name":"sideB","type":"address"},{"internalType":"uint256","name":"acceptedAt","type":"uint256"},{"internalType":"uint256","name":"randomB","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_commitment","type":"uint256"}],"name":"proposeBet","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposedBet","outputs":[{"internalType":"address","name":"sideA","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"placedAt","type":"uint256"},{"internalType":"bool","name":"accepted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_random","type":"uint256"}],"name":"reveal","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x60806040526004361061004a5760003560e01c80630a3f297a1461004f578063427051c81461008f57806386e30f2e146100ce578063c2ca0ac5146100ea578063d43faafd14610113575b600080fd5b34801561005b57600080fd5b5061007660048036038101906100719190610976565b61012f565b6040516100869493929190610bac565b60405180910390f35b34801561009b57600080fd5b506100b660048036038101906100b19190610976565b61018c565b6040516100c593929190610b75565b60405180910390f35b6100e860048036038101906100e3919061099f565b6101d6565b005b3480156100f657600080fd5b50610111600480360381019061010c9190610976565b61046b565b005b61012d60048036038101906101289190610976565b610803565b005b60006020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030160009054906101000a900460ff16905084565b60016020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154905083565b60008083815260200190815260200160002060030160009054906101000a900460ff1615610239576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023090610c71565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008084815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156102de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d590610cb1565b60405180910390fd5b600080838152602001908152602001600020600101543414610335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161032c90610bf1565b60405180910390fd5b336001600084815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426001600084815260200190815260200160002060010181905550806001600084815260200190815260200160002060020181905550600160008084815260200190815260200160002060030160006101000a81548160ff02191690831515021790555060008083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16827fb727a22534e43d337addefe6245e691859b29f7bf356bc7e6d77ff92070fe12460405160405180910390a35050565b60008160405160200161047e9190610b23565b6040516020818303038152906040528051906020012060001c9050600033905060006001600084815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600060016000858152602001908152602001600020600201548518905060008060008681526020019081526020016000206001015490503373ffffffffffffffffffffffffffffffffffffffff1660008087815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105aa90610c11565b60405180910390fd5b60008086815260200190815260200160002060030160009054906101000a900460ff16610615576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161060c90610c31565b60405180910390fd5b60006002836106249190610ddf565b14156106be578373ffffffffffffffffffffffffffffffffffffffff166108fc8260026106519190610cfd565b9081150290604051600060405180830381858888f1935050505015801561067c573d6000803e3d6000fd5b50847f0de94fe793c61cadb0d5993f7621dc7abda95f3f6e7eac8044a5a9b17ba099d08585846040516106b193929190610b3e565b60405180910390a261074e565b8273ffffffffffffffffffffffffffffffffffffffff166108fc8260026106e59190610cfd565b9081150290604051600060405180830381858888f19350505050158015610710573d6000803e3d6000fd5b50847f0de94fe793c61cadb0d5993f7621dc7abda95f3f6e7eac8044a5a9b17ba099d084868460405161074593929190610b3e565b60405180910390a25b600080868152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000905560028201600090556003820160006101000a81549060ff0219169055505060016000868152602001908152602001600020600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000905560028201600090555050505050505050565b6000806000838152602001908152602001600020600101541461085b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085290610c91565b60405180910390fd5b6000341161089e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161089590610c51565b60405180910390fd5b3360008083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034600080838152602001908152602001600020600101819055504260008083815260200190815260200160002060020181905550807fbe20caab9fd377d44064d0b07b3f918ac14a5649351da4e9e27f29989d96a8e8346040516109569190610cd1565b60405180910390a250565b60008135905061097081611025565b92915050565b60006020828403121561098857600080fd5b600061099684828501610961565b91505092915050565b600080604083850312156109b257600080fd5b60006109c085828601610961565b92505060206109d185828601610961565b9150509250929050565b6109e481610d9f565b82525050565b6109f381610d57565b82525050565b610a0281610d69565b82525050565b6000610a15602483610cec565b9150610a2082610e6e565b604082019050919050565b6000610a38602383610cec565b9150610a4382610ebd565b604082019050919050565b6000610a5b601d83610cec565b9150610a6682610f0c565b602082019050919050565b6000610a7e602283610cec565b9150610a8982610f35565b604082019050919050565b6000610aa1601d83610cec565b9150610aac82610f84565b602082019050919050565b6000610ac4602983610cec565b9150610acf82610fad565b604082019050919050565b6000610ae7601483610cec565b9150610af282610ffc565b602082019050919050565b610b0681610d95565b82525050565b610b1d610b1882610d95565b610dd5565b82525050565b6000610b2f8284610b0c565b60208201915081905092915050565b6000606082019050610b5360008301866109db565b610b6060208301856109db565b610b6d6040830184610afd565b949350505050565b6000606082019050610b8a60008301866109ea565b610b976020830185610afd565b610ba46040830184610afd565b949350505050565b6000608082019050610bc160008301876109ea565b610bce6020830186610afd565b610bdb6040830185610afd565b610be860608301846109f9565b95945050505050565b60006020820190508181036000830152610c0a81610a08565b9050919050565b60006020820190508181036000830152610c2a81610a2b565b9050919050565b60006020820190508181036000830152610c4a81610a4e565b9050919050565b60006020820190508181036000830152610c6a81610a71565b9050919050565b60006020820190508181036000830152610c8a81610a94565b9050919050565b60006020820190508181036000830152610caa81610ab7565b9050919050565b60006020820190508181036000830152610cca81610ada565b9050919050565b6000602082019050610ce66000830184610afd565b92915050565b600082825260208201905092915050565b6000610d0882610d95565b9150610d1383610d95565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d4c57610d4b610e10565b5b828202905092915050565b6000610d6282610d75565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610daa82610db1565b9050919050565b6000610dbc82610dc3565b9050919050565b6000610dce82610d75565b9050919050565b6000819050919050565b6000610dea82610d95565b9150610df583610d95565b925082610e0557610e04610e3f565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e65656420746f20626574207468652073616d6520616d6f756e74206173207360008201527f6964654100000000000000000000000000000000000000000000000000000000602082015250565b7f4e6f7420612062657420796f7520706c61636564206f722077726f6e6720766160008201527f6c75650000000000000000000000000000000000000000000000000000000000602082015250565b7f42657420686173206e6f74206265656e20616363657074656420796574000000600082015250565b7f796f75206e65656420746f2061637475616c6c792062657420736f6d6574686960008201527f6e67000000000000000000000000000000000000000000000000000000000000602082015250565b7f4265742068617320616c7265616479206265656e206163636570746564000000600082015250565b7f746865726520697320616c7265616479206120626574206f6e2074686174206360008201527f6f6d6d69746d656e740000000000000000000000000000000000000000000000602082015250565b7f4e6f626f6479206d616465207468617420626574000000000000000000000000600082015250565b61102e81610d95565b811461103957600080fd5b5056fea2646970667358221220811d305a00e3b2156fb57e17ba6efeee73b1d25955023e873066e164c907fc6764736f6c63430008040033
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.