Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'EXTCODEHASH' opcode #1052

Merged
merged 5 commits into from
May 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions EIPS/eip-1052.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
eip: 1052
title: EXTCODEHASH opcode
author: Nick Johnson <[email protected]>
discussions-to: https://ethereum-magicians.org/t/extcodehash-opcode/262
status: Draft
type: Standards Track
category: Core
created: 2018-05-02
---

## Abstract
This EIP specifies a new opcode, which returns the keccak256 hash of a contract's code.

## Motivation
Many contracts need to perform checks on a contract's bytecode, but do not necessarily need the bytecode itself. For instance, a contract may want to check if another contract's bytecode is one of a set of permitted implementations, or it may perform analyses on code and whitelist any contract with matching bytecode if the analysis passes.

Contracts can presently do this using the `EXTCODECOPY` opcode, but this is expensive, especially for large contracts, in cases where only the hash is required. As a result, we propose a new opcode, `EXTCODEHASH`, which returns the keccak256 hash of a contract's bytecode.

## Specification
A new opcode, `EXTCODEHASH`, is introduced, with number 0x3D. `EXTCODEHASH` takes one argument from the stack, and pushes the keccak256 hash of the code at that address to the stack.

## Rationale
As described in the motivation section, this opcode is widely useful, and saves on wasted gas in many cases.

## Backwards Compatibility
There are no backwards compatibility concerns.

## Test Cases
TBD

## Implementation
TBD

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).