The Solidity Compiler, ABI and Bytecode
Compilation produces the two artifacts that every later step depends on. This lesson explains what solc does, how Remix and Hardhat run it, and what the ABI, creation bytecode, runtime bytecode and metadata contain.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the outputs of the Solidity compiler.
- Distinguish creation bytecode from runtime bytecode.
- Describe how Remix and Hardhat compile contracts.
- Identify which output each task needs.
What compilation produces
The Solidity compiler, solc, turns source files into EVM bytecode and a set of descriptions of that bytecode. It is distributed as a native binary for each platform and as solc-js, a WebAssembly build used from JavaScript; Remix and Hardhat download the version a project asks for automatically. Developers rarely call solc directly, but its standard JSON input and output format is what every tool uses underneath.
The following terms describe the main outputs of a compilation.
- ABI Application Binary Interface
- A JSON array describing each public and external function, event, error and the constructor, with names, parameter types and state mutability.
- Creation bytecode
- The code sent in the deployment transaction. It runs the constructor and returns the runtime code.
- Runtime bytecode
- The code stored at the contract address and executed by every later call.
- Metadata
- A JSON document with the compiler version, settings and source hashes; its hash is appended to the bytecode and used for source verification.
- Opcodes and source maps
- A readable listing of the bytecode and a mapping back to source lines, used by debuggers.
The following diagram shows the compiler's outputs and who uses each.

Compiler outputs
Compiling in Remix
In Remix, the Solidity Compiler panel selects the compiler version, the EVM version and optimizer settings, and compiles the open file (or compiles automatically on save). A green tick shows success; warnings and errors appear in the panel with links to the source line. The Compilation Details view and the ABI and Bytecode copy buttons expose the outputs, which is useful when another tool needs a contract's ABI.
Compiling in Hardhat
In a Hardhat project, the compiler version and settings are in the configuration file, and the following command compiles every file under contracts/ (Hardhat also compiles automatically before tests, scripts and deployments).
npx hardhat build
# Compiled 1 Solidity file with solc 0.8.34 (evm target: osaka)For each contract, Hardhat writes an artifact file such as artifacts/contracts/Counter.sol/Counter.json, containing abi, bytecode (creation) and deployedBytecode (runtime). Libraries such as web3.js and ethers.js read these files to deploy and call contracts. Compilation is incremental: unchanged files are not recompiled, and npx hardhat clean deletes the cache and artifacts.
Hardhat build output
What each consumer needs
Different tasks need different outputs. The following table shows which output each common consumer uses.
| Task | Needs |
|---|---|
| Deploy a contract | Creation bytecode (plus the ABI to encode constructor arguments) |
| Call a deployed contract from web3.js or a front end | ABI and address |
| Call a deployed contract from another contract | An interface (equivalent to part of the ABI) and address |
| Verify source on Etherscan or Sourcify | Source, compiler version, settings and constructor arguments |
| Debug a transaction | Source maps and the source |
A missing ABI
A front-end developer has a deployed contract's address and the runtime bytecode copied from a block explorer, but no ABI. Can they call its functions with web3.js?
Not conveniently. Without the ABI, the library cannot know function names, parameter types or return types, so it cannot encode calls or decode results. The developer should get the ABI from the project's compiler output or, if the contract is verified, from the block explorer. For standard functions such as ERC-20's, a standard ABI (for example from OpenZeppelin's IERC20) works, because the encoding depends only on the signatures.
Creation code versus runtime code
A developer compares the bytecode and deployedBytecode fields of an artifact and finds the first is longer. They then read the code at the deployed address with eth_getCode. Which field will it match, and why is the other longer?
It matches deployedBytecode, the runtime code, with immutable values filled in. The creation bytecode is longer because it also contains the constructor logic and the code that copies the runtime code into place; it runs once during deployment and is never stored.
Which compiler output does a front end need to call a deployed contract, besides its address?
Show answer
The ABI. It describes function names, parameter and return types, events and errors, so the library can encode calls and decode results. The bytecode is needed only for deployment.
Exam Tips
Remember for the exam
- solc outputs the ABI, creation bytecode, runtime bytecode and metadata.
- Calling a deployed contract needs the ABI and address; deploying needs the creation bytecode.
- eth_getCode returns runtime bytecode; constructor code is never stored.
- Hardhat writes artifacts under artifacts/; Remix shows the outputs in the compiler panel.