Skip to content

cartoonitunes/avsa-erc777-verification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

avsa ERC777 ReferenceToken — Near-Exact Bytecode Match

Source reconstruction for 0x04f3e35cba2bd70d2c37455c410e39826e7c8039 — a stripped-down ERC777 ReferenceToken deployed by avsa (Jordi Baylina co-author and ERC777 co-author Jacques Dafflon's collaborator) on April 5, 2018.

Field Value
Contract 0x04f3e35cba2bd70d2c37455c410e39826e7c8039
Network Ethereum Mainnet
Block 5,385,661
Deployed 2018-04-05
Deployer avsa.eth (0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb)
Tx 0x7b58f648972d3a8a4d7c384fb9ab2b3747bd9e04f66bc508f5ecac1a93a62533
Compiler soljson v0.4.21+commit.dfe3193c, optimizer ON, runs = 200
Constructor args name="My Token", symbol="TOK", initialSupply=0, granularity=0 (defaults to 1)
Runtime match NEAR-EXACT (4029 compiled vs 4028 on-chain — 1 byte difference)

This was avsa's personal test deployment of the ERC777 token standard he co-authored. The source has not been published anywhere; it was reconstructed from on-chain bytecode by re-deriving the storage layout, dispatch table, and selector set, and matching against the jacquesd/eip777 reference implementation that avsa was sponsoring at the time.

Verification

./verify.sh

The script compiles src/ReferenceToken.sol with solc 0.4.21 + optimizer (runs=200) and compares the runtime bytecode against the on-chain code. It reports a 1-byte size delta and structurally near-identical output.

What this contract is

A minimal ERC777 token with no mint, no burn, no Owned, and no ERC20 toggle — just the core ERC20+ERC777 surface. avsa stripped the jacquesd/eip777 ReferenceToken down to the dispatch surface he wanted to test:

Group Selectors
ERC20 reads name, symbol, decimals, totalSupply, balanceOf, allowance
ERC20 writes transfer, transferFrom, approve
ERC777 reads granularity, isOperatorFor
ERC777 writes send(addr,uint), send(addr,uint,bytes), authorizeOperator, revokeOperator, operatorSend

ERC820 registry: 0x991a1bcb077599290d7305493c9A630c20f8b798 (Jordi Baylina's deployment).

Storage layout (verified from constructor init code)

Slot Variable Init
0 string name constructor arg
1 string symbol constructor arg
2 uint8 decimals 18
3 uint256 totalSupply initialSupply * 10^18
4 mapping(address=>uint256) balanceOf
5 mapping(address=>mapping(address=>uint256)) allowance
6 ERC820Registry erc820Registry 0x991a1bcb...b798
7 uint256 granularity 1 (or _granularity if non-zero)
8 mapping(address=>mapping(address=>bool)) isOperatorFor

Why "near-exact" not exact

The compiled runtime is 4029 bytes; on-chain is 4028 bytes. All 16 dispatch selectors line up; storage and event signatures match; control flow is structurally identical.

The remaining 1-byte gap is in the body of one of the helpers — almost certainly a stack-allocation / DUP-position / argument-reuse choice the optimizer makes based on tiny source-structure differences (e.g., whether avsa cached balanceOf[_to] into a local before the assert at the bottom of doSend, vs. re-reading it). Closing this last byte requires guessing the exact local-variable layout in avsa's private source file, which has not surfaced in any public repo.

A surprising finding from disassembly: the dispatch return labels suggest transfer(...) was declared without returns (bool) in the original source (the dispatcher uses the STOP-only return label, not the bool encoder). Removing the bool return shrinks transfer toward target but introduces structural shifts elsewhere that net to a worse match. We left returns (bool success) in this reconstruction because it produces the closer overall match; this is one of several plausible source patterns that produce equivalent semantics.

Files

  • src/ReferenceToken.sol — the reconstructed token contract (multi-file)
  • src/ERC777TokensSender.sol, src/ERC777TokensRecipient.sol — ERC777 callback interfaces (verbatim from jacquesd/eip777)
  • src/SafeMath.sol — verbatim from giveth-common-contracts v0.4.0 (the version pinned by jacquesd/eip777 at this commit window)
  • src/ReferenceToken_flat.sol — single-file flattened source for easy submission to verification UIs
  • verify.sh — reproduces the build and compares against on-chain code

Links

About

Near-exact bytecode reconstruction for avsa's ERC777 ReferenceToken (0x04f3e35c...) deployed 2018-04-05

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors