A 2017 conceptual token by Constantine Nicholas using block.difficulty as the price variable; bricked post-merge by prevrandao.
Historical Significance
A 2017 conceptual on-chain art piece that became unintentionally bricked by The Merge. Paired with BHI (block.number variant) which still works.
Context
Deployed Feb 20, 2017 — five years before The Merge. The author had no way to predict that block.difficulty would later return a 250-bit random number, but the buy() math depends on block.difficulty being a small uint, so the contract effectively died on Sept 15, 2022.
Token Information
Key Facts
Description
Block Difficulty Index (BDI) is the sister contract to BHI, deployed Feb 20, 2017 by Constantine Nicholas. It uses block.difficulty in place of block.number as the price-determining variable. The bytecode differs from BHI by exactly 4 bytes (two NUMBER opcodes replaced by DIFFICULTY) inside buy().
A fixed Fee fraction (default 1/100) of every buy, sell, transfer, and transferFrom is skimmed to the contract owner. The Transfer event has six fields (from, to, amount, fee_amount, lastBuyPrice, lastSellPrice), not the standard three.
Bricked post-merge: after The Merge (Sept 2022), block.difficulty returns prevrandao (~2^250). The buy formula amount = msg.value * 10^18 / block.difficulty / Fee evaluates to 0 for any sane msg.value, triggering the if (amount == 0) throw guard. buy() reverts with "invalid jump destination" for every call.
Source Verified
Bespoke template; ~13b longer due to solc helper-block placement. Optimizer: ON (200 runs)
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Spurious Dragon Era
Continued DoS protection. State trie clearing.
Bytecode Overview
Verified Source Available
This contract has verified source code.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
pragma solidity ^0.4.0;
contract owned {
address public owner;
function owned() {
owner = msg.sender;
}
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
owner = newOwner;
}
}
contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); }
contract BlockDifficultyIndex is owned {
string public name = "Constantine Nicholas: Block Difficulty Index";
string public symbol = "BDI";
uint8 public decimals = 18;
uint256 public totalSupply;
uint256 public Fee = 100;
uint256 public lastBuyPrice;
uint256 public lastSellPrice;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address from, address to, uint256 a, uint256 b, uint256 c, uint256 d);
event Buy(address from, address to, uint256 a, uint256 b, uint256 c, uint256 d);
event Sell(address from, address to, uint256 a, uint256 b, uint256 c, uint256 d);
function BlockDifficultyIndex(uint256 initialSupply) {
balanceOf[msg.sender] = initialSupply;
totalSupply = initialSupply;
}
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) throw;
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
uint feeAmount = _value / Fee;
if (feeAmount == 0) throw;
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value - feeAmount;
balanceOf[owner] += feeAmount;
Transfer(msg.sender, _to, _value, feeAmount, lastBuyPrice, lastSellPrice);
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
returns (bool success) {
allowance[msg.sender][_spender] = _value;
tokenRecipient(_spender).receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balanceOf[_from] < _value) throw;
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
if (_value > allowance[_from][msg.sender]) throw;
uint feeAmount = _value / Fee;
if (feeAmount == 0) throw;
balanceOf[_from] -= _value;
balanceOf[_to] += _value - feeAmount;
balanceOf[owner] += feeAmount;
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value, feeAmount, lastBuyPrice, lastSellPrice);
return true;
}
function changeFee(uint256 _newFee) onlyOwner {
if (_newFee < 100) throw;
Fee = _newFee;
}
function buy() payable {
uint amount = 10**18 * msg.value / block.difficulty;
uint feeAmount = amount / Fee;
if (feeAmount == 0) throw;
balanceOf[msg.sender] += amount - feeAmount;
balanceOf[owner] += feeAmount;
totalSupply += amount;
lastBuyPrice = block.difficulty;
Buy(this, msg.sender, amount, feeAmount, block.difficulty, lastSellPrice);
}
function sell(uint256 amount) payable {
if (msg.value > 0) throw;
if (balanceOf[msg.sender] < amount) throw;
uint feeAmount = amount / Fee;
if (feeAmount == 0) throw;
balanceOf[msg.sender] -= amount;
balanceOf[owner] += feeAmount;
totalSupply = totalSupply - amount + feeAmount;
lastSellPrice = this.balance * 10**18 / totalSupply;
if (!msg.sender.send((amount - feeAmount) * lastSellPrice / 10**18)) throw;
Sell(this, msg.sender, amount, feeAmount, lastBuyPrice, lastSellPrice);
}
function () {
throw;
}
}External Links
Related contracts
Constantine Nicholas: Block Height Index
Same deployerA 2017 conceptual token by Constantine Nicholas using block.number as the price variable; non-standard 6-field Transfer event.
0x3b0ffc...aec1aeFebruary 20, 2017VegasCoin
Same eraA 2017 ConsenSys MyAdvancedToken — 777,777,777 VEGAS sold via buy() at 1 wei/token, standard "VegasCoin 2.1".
0x616f02...7050b3January 26, 2017EtherDelta
Same eraThe first major decentralized exchange on Ethereum, deployed February 9, 2017. Used off-chain signed orders with on-chain settlement to enable trustless ERC-20
0x8d12a1...cc6819February 10, 2017Contract 0x0000ae...74d6eb
Same eraERC-20 token sweeper for exchange deposit addresses. Owner-only sweep of any token balance. Compiled with Solidity 0.4.9.
0x0000ae...74d6ebMarch 17, 2017CMEP - Cloud Mining Ethereum Project
Same eraCMEP is a 2017 ConsenSys MyAdvancedToken-family token. Source reconstructed to 2 bytes shy of exact bytecode match.
0x9f677f...19ad1bApril 7, 2017www.minex3d.com shares
Same eraMinex3D is a 2017 ConsenSys MyAdvancedToken-style mining shares token. Source reconstructed to 2 bytes shy of exact.
0x0370dd...568b0aApril 22, 2017