🔮
Ethereum
  • General
    • What is Ethereum
      • Ethereum & Bitcoin General Comparison
      • Singleton State
      • The Ethereum Virtual Machine (EVM)
      • Opcodes (operation codes) EVM
      • Ethereum Client
      • Forks
      • Gas (wei)
        • EIP-1559
        • Table Conversion (wei)
      • Proof of Stake (PoS)
      • Proof of Authority (PoA)
      • The Beacon Chain
      • Networks
        • Ethereum mainnet
        • Goerli
      • Account-based model & UTXO-based model
      • Externally Owned Account (EOA)
      • Node Clients
        • Geth
        • Nethermind
      • Contract Account
      • Smart Contract Upgradeability
      • Ultrasound Money
      • Merkle Trees
        • Patricia Merkle Tree
      • Tries
        • State Trie
        • Storage Trie
        • Transactions Trie
        • Receipts Trie
      • Transactions
        • Ethereum Transaction Architecture
      • World State
        • Chain of States
        • Chain of Blocks
        • Stack of Transactions / Mempool
      • Contract Creation
      • Message Call Transaction
      • P2P Network
      • Web3.js
      • Ether.js
        • Smart Contract Interaction Example
      • Web3.js vs Ether.js
      • Node Providers
      • ENS (Ethereum Name Service)
      • Web3 dapp
      • Escrow
      • Multi-signature
      • ERC-20 tokens
        • Send ERC20s to Contracts
      • NFTs
        • ERC-721 and ERC-1155
      • Solidity
        • State Variables
        • Data Location
        • Numbers
        • Modifiers
        • View & Pure Modifiers
        • Data Types
          • Modifiers
          • Modifiers (Functions)
          • Address & Address Payable
        • Hardhat
        • Payable Functions
        • Receive Function
        • Fallback Function
        • Global Variables
        • Self Destruct
        • Create2 Function
        • Revert function
        • Require function
        • Assert Function
        • Calldata
        • Interface
        • Mapping
        • Array
        • Struct
        • Inheritance
          • Virtual & Overwrite
          • Multiple inheritance
          • Hierarchical Inheritance
        • Events
          • Indexed (keyword)
          • LOG0 - LOG4
        • Multi-signature Example
        • Smart Contracts
          • Context
      • Application Binary Interface (ABI )
  • Extras
    • Terminology
      • Bytecode
      • Keccak-256
      • Turing complete
Powered by GitBook
On this page
  1. Extras
  2. Terminology

Bytecode

Bytecode (also called portable code or p-code[citation needed]) is a form of instruction set designed for efficient execution by a software interpreter.

PreviousTerminologyNextKeccak-256

Last updated 2 years ago

Bytecode is the compiled code that can be executed by a virtual machine, such as the Ethereum Virtual Machine (EVM). Bytecode is typically generated by compiling source code written in a high-level programming language, such as Solidity, into machine-readable instructions that can be executed by the EVM.

Example

// Solidity code
pragma solidity ^0.8.0;

contract SimpleContract {
  uint256 public value;

  function setValue(uint256 newValue) public {
    value = newValue;
  }
}

// Bytecode (in hexadecimal)
608060405234801561001057600080fd5b5061019b806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806360fe47b11460375780638e7b8d7814605c575b600080fd5b603d606d565b005b604760c2565b6040518082815260200191505060405180910390f35b60008090505b600081359050606081565b9291505056fea265627a7a72315820631d6a7a6a60cf6f6959c1d3f526b3d31db41678a70c8b75da3d7a1362e2eb1964736f6c634300050c0032

In this example, we have a simple Solidity contract called "SimpleContract" that includes a public variable called "value" and a function called "setValue" that can be used to update the value of "value".

The Solidity code is compiled into bytecode, which is a hexadecimal string that represents the machine-readable instructions that can be executed by the EVM. The bytecode is much longer and more complex than the original Solidity code, and includes a set of low-level instructions that can be executed by the EVM to update the state of the blockchain and execute the smart contract.

BytecodeWikipedia
Logo