Skip to content

cartoonitunes/augur-rep-verification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Augur REP Crowdsale — Bytecode Verification

Contract: 0x48c80F1f4D53D5951e5D5438B54Cba84f29F32a5
Deployed: October 4, 2016 (block 2,378,196)
Language: Serpent
Compiler: ethereum/serpent develop branch @ commit bc4ce59 (June 17, 2016)
Source: augur-core commit d4c095c3b (Oct 5, 2016)
Result: Exact bytecode match — 2,037 bytes
EthereumHistory: Contract page


What This Is

Augur's REP (Reputation) token distribution contract, deployed in October 2016. This contract handled the initial distribution of 11,000,000 REP tokens to early backers. Augur was Ethereum's first major prediction market protocol — REP gave holders the right to report on event outcomes.

The contract is written in Serpent, a now-defunct Python-like smart contract language created by Vitalik Buterin that predated Solidity's dominance. It implements a full ERC20 token with batch distribution, a stillCreating() time-lock, and a getRidOfDustForLaunch() cleanup function callable only from a hardcoded Augur DAO address.

Key Finding

The exact bytecode was reproduced using Serpent develop branch at commit bc4ce59 (June 17, 2016) — three days before commit a33ef61 which changed send(to, value) gas from 5000 to 0. The deployed bytecode uses PUSH2(0x1388) = 5000 gas for the send() call in the refund() macro, confirming Augur compiled with an older cached Serpent install.

Reproduce

# Build the Serpent compiler image
docker build -f Dockerfile -t serpent-bc4ce59 .

# Compile
docker run --rm -v $(pwd)/repContract.se:/src/repContract.se \
  serpent-bc4ce59 serpent compile /src/repContract.se > compiled_full.hex

# Extract runtime bytecode (offset 199 bytes, length 2037 bytes)
node -e "
const hex = require('fs').readFileSync('compiled_full.hex', 'utf8').trim();
// Find CODECOPY pattern to locate runtime
for(let i = 0; i < hex.length - 20; i += 2) {
    if(hex.slice(i,i+2)==='61' && hex.slice(i+6,i+8)==='80' && hex.slice(i+8,i+10)==='61' && hex.slice(i+14,i+18)==='6000' && hex.slice(i+18,i+20)==='39') {
        const len = parseInt(hex.slice(i+2,i+6),16);
        const off = parseInt(hex.slice(i+10,i+14),16);
        process.stdout.write(hex.slice(off*2, off*2+len*2));
        break;
    }
}
" > runtime.hex

# Compare against on-chain bytecode
cast code 0x48c80F1f4D53D5951e5D5438B54Cba84f29F32a5 --rpc-url https://eth.meowrpc.com | \
  sed 's/^0x//' > target.hex

diff runtime.hex target.hex && echo "EXACT MATCH" || echo "MISMATCH"

Compiler Notes

Serpent was installed from the develop branch tarball. Augur's requirements.txt at the time of deployment specified serpent from the develop branch without pinning a commit, so they used whatever was HEAD when they last ran pip install.

The critical difference between compiler versions:

Commit send(to, value) gas Date
Before a33ef61 (incl. bc4ce59) 5000 Jun 17, 2016
a33ef61 and after 0 Jun 20, 2016

The deployed contract uses 5000, placing the compilation date at or before June 20, 2016 — months before the October 4, 2016 deployment.

Dockerfile

FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python2.7 python-pip git gcc g++ make libssl-dev \
    && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/ethereum/serpent.git /serpent && \
    cd /serpent && git checkout bc4ce59 && python setup.py install
WORKDIR /src

Contract Functions

Function Selector Description
transfer(address,uint256) a9059cbb ERC20 transfer
transferFrom(address,address,uint256) 23b872dd ERC20 transferFrom
approve(address,uint256) 095ea7b3 ERC20 approve
setSaleDistribution(address[],uint256[]) d39d0847 Batch REP distribution (creator only, during creation window)
getRidOfDustForLaunch() 943f401b Remove dust from address(0) (Augur DAO only)
allowance(address,address) dd62ed3e ERC20 allowance
totalSupply() 18160ddd Total REP supply
balanceOf(address) 70a08231 Balance lookup
name() 06fdde03 Token name ("Reputation")
decimals() 313ce567 Decimals (18)
symbol() 95d89b41 Token symbol ("REP")
getSeeded() e44b11a2 Whether distribution is complete

Links

About

Exact bytecode verification for Augur REP Crowdsale contract (0x48c80F1f4D53D5951e5D5438B54Cba84f29F32a5) — Serpent, October 2016

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors