Skip to content

cartoonitunes/honestdice-verification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HonestDice Contract Verification

Byte-for-byte verified creation bytecode for the HonestDice contract deployed on Ethereum mainnet.

Contract

  • Address: 0xc4c51de1abf5d60dbd329ec0f999fd8f021ae9fc
  • Deployed: August 12, 2015 (block 74,817) - 13 days after Ethereum Frontier launch
  • Deployer: 0x87c5b5874a18b4306df8a752a6c8cc3e82dafc19
  • ETH locked: 122 ETH (unreachable - owner key lost)
  • Creation bytecode: 1,992 bytes

Compiler

  • Version: soljson v0.1.1+commit.6ff4cd6
  • Optimizer: ON

Verification

curl -o soljson-v0.1.1.js https://binaries.soliditylang.org/bin/soljson-v0.1.1+commit.6ff4cd6.js
npm install
node verify.js

How to Reproduce

const soljson = require("./soljson-v0.1.1.js");
const compile = soljson.cwrap("compileJSON", "string", ["string", "number"]);
const result = JSON.parse(compile(source, 1)); // 1 = optimizer ON
const bytecode = result.contracts["HonestDice"].bytecode;

Compare against on-chain creation bytecode at 0xc4c51de1abf5d60dbd329ec0f999fd8f021ae9fc.

Contract Behavior

A commit-reveal dice game deployed 13 days after Ethereum's Frontier launch. Players submit a bet with a secret hash; the server provides a random seed; the player reveals their secret to claim winnings if they beat their chosen odds.

  • Minimum bet: 10 ETH (hardcoded in minimumBet state variable)
  • Max payout: 5% of bankroll per roll
  • House edge: 2% (implicit in odds calculation)
  • Timeout: 20 blocks for server to provide seed before refund

Key Findings

Function order matters: Moving setMinimumBet() before setFeed() in the source is required to match the on-chain bytecode. Early Solidity optimizer output depends on function declaration order.

10 ETH minimum, not 1: The published HonestDice source on GitHub shows minimumBet = 1 ether. The deployed contract uses minimumBet = 10 ether. This is the as-deployed version.

Local variable shadowing bug: Both lockBetsForWithdraw() and unlockBets() declare a local uint betsLocked variable instead of modifying the betsLocked state variable. Both functions are no-ops on-chain - the owner cannot actually lock or unlock bets.

122 ETH remains locked in the contract, extractable only by the owner (key appears to be lost).

Links

About

Byte-for-byte verification of the HonestDice contract (Aug 12, 2015)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors