TeachMeBitcoin

What is a Script Atom

From TeachMeBitcoin, the free encyclopedia Reading time: 3 min

9. What is a Script Atom?

Overview

In the context of Bitcoin Script, a "script atom" is the fundamental unit of execution: either a single opcode instruction or a complete data push item. Every Bitcoin script is a sequence of atoms evaluated one at a time by the Script interpreter. Understanding what constitutes an atom is essential to understanding how script execution proceeds and where execution boundaries lie.

Defining a Script Atom

A script atom is the minimal self-contained unit of a Bitcoin script. There are two categories:

Category 1: Data push atoms

A data push atom consists of a push opcode (including the direct push range) plus all the data bytes it encodes. The entire push — opcode(s) + data — is consumed atomically by the interpreter before moving to the next byte.

Data push atom examples:

OP_0 alone:
  Bytes consumed: [0x00]

Result: pushes [] onto stack

Direct push of 3 bytes:
  Bytes consumed: [0x03, 0xAA, 0xBB, 0xCC]

Result: pushes [0xAA, 0xBB, 0xCC] onto stack

OP_PUSHDATA1 with 100 bytes:
  Bytes consumed: [0x4c, 0x64, <100 data bytes>]

Category 2: Operator atoms

An operator atom is a single opcode byte that performs a computation, comparison, or control flow operation without pushing raw data.

Operator atom examples:

OP_DUP (0x76):   Bytes consumed: [0x76]
OP_HASH160 (0xa9): Bytes consumed: [0xa9]
OP_EQUALVERIFY (0x88): Bytes consumed: [0x88]
OP_CHECKSIG (0xac): Bytes consumed: [0xac]

Atom Boundaries in Raw Hex

When reading a raw script hex string, you must track atom boundaries manually to parse it correctly:

P2PKH scriptPubKey in hex:
76 a9 14 <20-byte-hash> 88 ac

Atom breakdown:
  76        --> OP_DUP          (operator atom, 1 byte)
  a9        --> OP_HASH160      (operator atom, 1 byte)
  14 <20B>  --> push 20 bytes   (data push atom, 21 bytes)
  88        --> OP_EQUALVERIFY  (operator atom, 1 byte)
  ac        --> OP_CHECKSIG     (operator atom, 1 byte)

Script Atom vs. Stack Item

It is important to distinguish between a script atom and a stack item:

A data push atom in the script produces a single stack item. An operator atom may consume zero or more stack items and produce zero or more stack items, but the operator itself is not a stack item.

Script:  OP_1 OP_2 OP_ADD
Atoms:   [OP_1] [OP_2] [OP_ADD]

Execution:
  After OP_1:   stack = [[0x01]]
  After OP_2:   stack = [[0x01], [0x02]]
  After OP_ADD: stack = [[0x03]]

Atoms and Script Disassembly

Bitcoin script disassemblers work by iterating over atoms. Tools like bitcoin-cli decodescript parse atom boundaries to produce human-readable output:

$ bitcoin-cli decodescript "76a914<hash>88ac"

Output:
{
  "asm": "OP_DUP OP_HASH160 <20-byte-hash> OP_EQUALVERIFY OP_CHECKSIG",
  "type": "pubkeyhash",
  "p2sh": "3..."
}

Each space-separated token in the asm output corresponds to one script atom.


☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!