Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
TRC: Code hash instructions #30
This TIP specifies a new opcode, which returns the keccak256 hash of a contract's code.
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
A new opcode,
In case the account does not exist
In case the account does not have code the keccak256 hash of empty data (i.e.
The energy cost of the
As described in the motivation section, this opcode is widely useful, and saves on wasted energy in many cases.
Only the 20 last bytes of the argument are significant (the first 12 bytes are ignored) similarly to the semantics of the
There are no backwards compatibility concerns.