2022 Developer Survey is open! Take survey.
34 votes
Accepted

What is the difference between bytecode, init code, deployed bytedcode, creation bytecode, and runtime bytecode?

I wrote an article that goes over this information in depth. I will summarize it here. tl;dr - There are only two types of bytecode on Ethereum but five different names to describe them. Creation ...
user avatar
23 votes
Accepted

How to find solidity code for a contract address

Mainly due to optimizations carried out when the source code is compiled it's not feasible to get the source code from the bytecode/opcode itself. Refer this question. Compilation back to the ...
user avatar
20 votes
Accepted

What's the difference between solc's bin bytecode versus bin runtime?

TL;DR bin-runtime is the code that is actually placed on the blockchain. The regular bin output is the code placed on the blockchain plus the code needed to get this code placed on the blockchain, ...
user avatar
17 votes
Accepted

Why does changing comments in the smart contract change its bytecode?

The Solidity compiler appends the metadata file hash at the end of the bytecode http://solidity.readthedocs.io/en/develop/metadata.html Metadata file is a json file that contains hashes of source ...
user avatar
  • 10.2k
15 votes
Accepted

Why do `throw` and `revert()` create different bytecodes?

I'll leave the precise interpretation of the OpCodes to someone else and just point out that they are different instructions so different implementations are to be expected. According to this: http:/...
user avatar
  • 50.7k
12 votes
Accepted

How is an ABI stored in bytecode?

It's the job of the compiler to produce the correct EVM bytecode so that as you say the MethodID "piece of data will end up jumping to the appropriate address for that function in the bytecode of ...
user avatar
  • 78k
12 votes

Difference between bytecode and runtime bytecode

Runtime bytecode is what's actually stored at the contract address. It doesn't include the constructor function or initialization code (which the bytecode does). https://www.reddit.com/r/ethereum/...
user avatar
10 votes
Accepted

Understanding how a simple contract breaks into bytecode

What you've got in bytecode here is the contract's constructor / construction bytecode. When you create a contract, the constructor runs, handles any initial arguments or statements you make, and also ...
user avatar
9 votes
Accepted

Deploy pre compiled bytecode using truffle migrations deployer api

One solution appears to be to install @truffle/contract package like so: npm install @truffle/contract Then in the migration file you will need to grab the full contract JSON (not just the bytecode ...
user avatar
8 votes

How do i get Bytecode of the contract to deploy?

Go to Remix and paste your code there. In the "Compile" tab, select the contract you want and click on "Details" and you can copy ABI, Bytecode, etc... That being said, I find it way easier to deploy ...
user avatar
8 votes
Accepted

Deploying a smart contract with just bytecode

You don't need the source code, but in your contract creation transaction, you need to specify the initialization code: bytecode that returns the bytecode that you want deployed. For example, if you ...
user avatar
  • 78k
7 votes
Accepted

Is there a way to detect which compiler version produced a contract binary?

No, as there is no difference in the output of the bytecode from the simple contract Test {} plugged into Browser-solidity when using different recent versions of the Solidity compiler. There is ...
user avatar
5 votes

Why do `throw` and `revert()` create different bytecodes?

The revert is often referred to as cheap throw as it refunds unused gas to the sender. If you are interested in the detailed design of this feature please look at the original EIP-140 discussion.
user avatar
5 votes
Accepted

How does Etherscan.io figure out constructor arguments without contract verification

This was already answered in the comments to your own previous question To summarize: The transaction that created the contract is visible on Etherscan (example here) The input data to that ...
user avatar
5 votes

What is the shortest bytecode that will publish a contract with non-zero bytecode?

6 bytes (code: 6 bytes, payload: 0 bytes); 3 distinct opcodes. Same idea just 2 gas cheaper than previous 6-byter. Bytecode: Assembly: Works as follows: Sample transaction: on etherscan Gas ...
user avatar
5 votes
Accepted

web3.eth.getCode doesn't return the data shown on etherscan

That's because they are not the same thing. When you execute the getCode(...) function, you get the deployed bytecode of a specific address, as the docs says. The bytecode on the blockchain is the ...
user avatar
  • 2,903
4 votes

Where to download GASPER

You could try emailing the authors of the publication and authors of the code. The publication contains the contact details for the author of the code and paper. Email: brokendragon@uestc.edu.cn, {...
user avatar
  • 1,245
4 votes

Run EVM Code outside the Blockchain

Truffle and Ganache seem to be an excellent combo: Ganache is a standalone, in-memory node, designed for development. It can auto-mine, meaning it immediately creates and mine a block each time a ...
user avatar
4 votes
Accepted

First instructions in bytecode (606060405)

Answering my own question: This is the free memory pointer. The first 0x40 bytes are reserved for internal calculations. Then 0x40 - 0x60 (one word) stores a pointer to free memory (available for ...
user avatar
4 votes
Accepted

How to get byte code from deployed contract in

According to the docs, you can use this method: web3.eth.getCode(addressHexString [, defaultBlock] [, callback]) Where addressHexString is the address your contract was deployed at.
user avatar
4 votes
Accepted

What is the purpose of extcodecopy?

It is used to check and compare a contract's bytecode, similar to comparing a known hash of a download file to confirm its legitimacy. The best description of why it is useful (and suggestions as to ...
user avatar
4 votes
Accepted

When did the Ethereum "free memory pointer" change? (6060... -> 6080...)

The contract prologue instructions changed to provide an additional slot at 0x60, which should always hold the value 0. The documentation states that: The zero slot is used as initial value for ...
user avatar
4 votes

Deploying contract using byteCode

Actually the data of deployed contract transaction is bytecode concatenate with abi encoded of constructor parameters. Here is example: Token.sol pragma solidity 0.5.1; contract Token { ...
user avatar
  • 197
4 votes

How to construct deployable bytecode from runtime bytecode?

Sure. To deploy smart contract one needs to publish a transaction with empty to address and with data containing contract initialization code concatenated with values of constructor parameters. ...
user avatar
4 votes
Accepted

ABI and Bytecode stored inside Contract

Unfortunately, you cannot store the deploying contract's bytecode as a variable in the contract directly, as that creates a circular reference. From the docs: This property can not be accessed in ...
user avatar
4 votes
Accepted

Function to execute raw bytecode in EVM

Surely, you may do this. Here are high-level steps: To the end of your bytecode append a few additional opcodes that copy stack and storage content into memory and return them together with memory ...
user avatar
4 votes
Accepted

How to deploy a bytecode-only contract without an ABI

You don't need ABI to deploy a smart contract, it is usually used by the abstraction layer of libraries to create dynamic objects that help developers with further calls, but it is not used in the ...
user avatar
3 votes
Accepted

Why doesn't bytecode match the opcodes on Etherscan?

There's a difference between the "Contract Creation Code" (which includes the constructor at the front) and the deployed bytecode. The "Bytecodes view" is showing you the full contract creation code ...
user avatar
  • 8,622
3 votes

Could a contract, or parts of a contract, be reverse engineered from bytecode if the ABI was available?

The ABI gives you a list of all members functions and events in the contract (parameter types, parameter names, return types, etc.). You can revert these members, but this is useless, as you already ...
user avatar
3 votes
Accepted

What is the shortest bytecode that will publish a contract with non-zero bytecode?

Since Noel got close, time to release my 6-byter: Bytecode: Works as follows:
user avatar
  • 8,622

Only top scored, non community-wiki answers of a minimum length are eligible