mirror of
https://github.com/status-im/EIPs.git
synced 2025-01-27 07:05:47 +00:00
'EXTCODEHASH' opcode (#1052)
* Create eip-x-codehash.md * Update and rename eip-x-codehash.md to eip-1052.md
This commit is contained in:
parent
f66674e758
commit
8f362abc37
36
EIPS/eip-1052.md
Normal file
36
EIPS/eip-1052.md
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
eip: 1052
|
||||
title: EXTCODEHASH opcode
|
||||
author: Nick Johnson <arachnid@notdot.net>
|
||||
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/).
|
Loading…
x
Reference in New Issue
Block a user