Member-only story

Solidity Tutorial: All About Code

Understanding the structure and behaviour of a smart contract’s bytecode

Jean Cvllr
Better Programming
18 min readJan 29, 2023

Photo by Eva Gorobets on Unsplash

Part 5 of the “All About Data Locations” subseries.

This article focuses on the last data locations of the EVM that are accessible in Solidity: the bytecode of a smart contract.

We will look at most aspects of a contract’s bytecode at the architecture level. This includes some detailed explanations of “where the bytecode of a smart contract is stored” and the difference between creation and runtime code.

We will also demystify the bytecode that runs when we deploy a smart contract to understand how that works when we deploy a smart contract with no constructor. This will help us understand how (and why) the EVM returns the runtime code of a smart contract to save it in Ethereum’s world state under the smart contract’s address.

We will finally look at some security caveats around the isContract() function from the OpenZeppelin library that directly relate to the EXTCODESIZE opcode.

Table of Contents

Basics of Code

Layout of Code

Where Is the Code of a Smart Contract Stored?

Creation vs Runtime Code

How Contract (Runtime) Code Is Generated

The Caveats of isContract() and EXTCODESIZE

Accessing Contract Code in Solidity

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jean Cvllr
Jean Cvllr

Written by Jean Cvllr

Smart Contract engineer at @LUKSO. Full Stack Developer. https://github.com/CJ42

Responses (3)

Write a response