Back to Home

BeerCoin

Token
0x74c1e4b8cae5...24396048f4ac
DAO ForkContract #21KDecompiledEdit this contract
Deployed July 29, 2016 (9 years ago)Block 1,975,020

ERC20-style 'I owe you a beer' IOU ledger by Nick Johnson (ENS). Each transfer creates a personal beer debt; obligations are tracked and transferable.

DAO Fork Era

Historical Significance

An early example of a peer-to-peer credit/IOU primitive on Ethereum, predating Compound by two years and DeFi lending generally by three. Notable as one of Nick Johnson's pre-ENS contracts: ENS launched in May 2017, and BeerCoin (July 2016) is part of the body of small experimental tokens Nick was building while still at Google before joining the Ethereum Foundation. The novel transferOther function (reassigning someone else's debt to you onto a third party) is functionally a primitive debt-secondary-market mechanism, expressed in 11 KB of Solidity.

Context

Deployed 29 July 2016, nine days after the DAO hard fork (block 1,920,000, 20 July 2016). Solidity 0.3.5 was the current release; OpenZeppelin would not exist until later that year. ERC20 was still being formalized as EIP-20 (draft published 19 November 2015 by Fabian Vogelsteller). BeerCoin matches the EIP-20 ABI but stores balance per-account-pair rather than a single mapping, which is why some wallets (Mist) misinterpret it. Iterable mappings via the Itmap helper library were a common Solidity 0.3 pattern since dynamic-array enumeration of map keys was not built into the language.

Token Information
Token Name
BeerCoin
Key Facts
Deployment Block
1,975,020
Deployment Date
Jul 29, 2016, 09:13 PM
Code Size
3.0 KB
Gas at Deploy
907,978

Description

BeerCoin is an ERC20-shaped IOU token by Nick Johnson (arachnid, later founder of ENS). Unlike a normal ERC20, BeerCoin has no preminted supply and no central issuer: anyone can issue BeerCoin simply by calling transfer(to, value), which creates a debt from the sender to the recipient. The recipient holds an obligation against the sender, redeemable for a beer if the two ever meet.

State is tracked per-account in a UserAccount struct: a debtors map (people who owe you beers), allowances (for the ERC20 transferFrom path), a maxCredit cap (the most beers any single party may owe you, default set at deployment, modifiable per-account up to 655,360), beersOwed (total you owe), and beersOwing (total owed to you). The standard ERC20 balanceOf(owner) returns beersOwing.

Extensions beyond ERC20: balanceOf(owner, debtor) returns just the debt of a specific debtor; transferOther(to, debtor, value) lets you reassign a beer that someone else owes you onto a new creditor; transferOtherFrom is the allowance version; numDebtors / debtor(idx) / debtors() enumerate your debtors via an Itmap iterable mapping; totalDebt(owner) returns beersOwed. The fallback function throws so the contract refuses ETH.

The contract holds 0.003 ETH, sent at construction by Nick himself to seed the deployment. The author wrote in the header comment: 'If you feel obliged to me for creating this, send me a beer at 0x5fC8A61e097c118cE43D200b3c4dcf726Cf783a9.' Compiled with Solidity v0.3.5 (21 July 2016, commit 6610add), CC-BY-SA license.

Source Verified

SolidityEtherscan verified
Compiler: v0.3.5+

Author-published source by Nick Johnson, verified on Etherscan. License: CC-BY-SA.

Heuristic Analysis

The following characteristics were detected through bytecode analysis and may not be accurate.

Detected Type: Token
Has ERC-20-like patterns

Bytecode Overview

Opcodes3,123
Unique Opcodes170
Jump Instructions158
Storage Operations88

External Links