Skip to main content
Share Your Experience: Take the 2024 Developer Survey
57 votes
Accepted

What is the difference between bytecode, init code, deployed bytecode, 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 ...
Shane Fontaine's user avatar
25 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 ...
Achala Dissanayake's user avatar
23 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, ...
Thorkil Værge's user avatar
18 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 ...
medvedev1088's user avatar
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:/...
Rob Hitchens's user avatar
  • 55.3k
14 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/...
will_durant's user avatar
  • 1,154
13 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 ...
eth's user avatar
  • 85.9k
11 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 ...
Alexander Wade's user avatar
9 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 ...
eth's user avatar
  • 85.9k
9 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 ...
yarrumretep's 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 ...
Darren Jensen's 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 ...
nbarraille's user avatar
8 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 ...
BokkyPooBah's user avatar
  • 40.3k
7 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:
benjaminion's user avatar
  • 9,297
7 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 ...
Shane Fontaine's user avatar
7 votes

Is it possible to get the bytecode of an already deployed contract in Solidity?

It is now possible to read the code of another contract using both plain Solidity and assembly (Yul). Plain Solidity As per the docs on Members of Address Types pragma solidity >=0.8.0; contract ...
Paul Razvan Berg's user avatar
6 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 ...
alberto's user avatar
  • 3,343
6 votes
Accepted

Where are the smart contract constants stored?

Constants are not stored anywhere. They are replaced with their constant value in every usage at compilation time. For example, the following code. Notice how when I'm returning a constant from a ...
Jeremy Then's user avatar
  • 4,609
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.
Jakub Wojciechowski's 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 ...
Daniel Hume's user avatar
5 votes
Accepted

How does a contract's constructor work and load input values?

In Solidity, arguments to the constructor are ABI encoded and appended to the compiled bytecode. The arguments are copied to the EVM memory using CODECOPY. In Etherscan, you can see that the last ...
eth's user avatar
  • 85.9k
5 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 { ...
Peter Lai's user avatar
  • 317
5 votes
Accepted

How to verify smart contracts on different solidity versions

The article is fairly old. I'd suggest taking a look at the current docs on Contract Medatata. They contain these notes: The CBOR mapping can also contain other keys, so it is better to fully decode ...
cameel's user avatar
  • 2,241
5 votes
Accepted

Transaction init and 24kb contract size limit

Let's start by saying that you are right, it is quite weird because the "init bytecode" is basically the deployed contract. With that being said, the yellow paper may have amends by the EIPs ...
matank001's user avatar
  • 820
5 votes
Accepted

Is there a way to get solidity code from bytecode

This tool decompiles Ethereum contract bytecode into more readable Solidity-like code: https://ethervm.io/decompile
Yongjian P.'s user avatar
  • 4,210
5 votes
Accepted

How to read private immutable field?

Summary You can examine the bytecode of the contract to find the value, the same applies for constants. This way, you could find any value. You would have to examine the contract bytecode to figure ...
Patrick Collins's user avatar
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: [email protected], {...
Lismore's user avatar
  • 1,303
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 ...
philippe_b's 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 ...
AlexeyKarasev's user avatar
4 votes
Accepted

callvalue opcode, for what?

When a contract call occurs, it receives some parameters on the stack, among these parameters, Value contains the amount of ETH this contract will receive to make some operations with it. The emv....
Nulik's user avatar
  • 4,061

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