> For the complete documentation index, see [llms.txt](https://docs.blockdagnetwork.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockdagnetwork.io/get-started/introductory-concepts/evm.md).

# EVM

The Ethereum Virtual Machine *(EVM)* is a decentralized virtual environment that executes code consistently and securely across all Ethereum nodes. Nodes run the EVM to execute smart contracts, using ***"gas"*** to measure the computational effort required for operations, ensuring efficient resource allocation and network security.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Some basic familiarity with common terminology in computer science, such as bytes, memory, and a stack, is necessary to understand the EVM. It would also be helpful to be comfortable with cryptography/blockchain concepts like hash functions and the Merkle tree.&#x20;

### From ledger to state machine <a href="#from-ledger-to-state-machine" id="from-ledger-to-state-machine"></a>

The analogy of a ***'distributed ledger'*** is often used to describe blockchains like Bitcoin, which enable a decentralized currency using fundamental tools of cryptography. The ledger maintains a record of activity, which must adhere to a set of rules that govern what someone can and cannot do to modify the ledger. \
For example, a Bitcoin address cannot spend more Bitcoin than it has previously received. These rules underpin all transactions on Bitcoin and many other blockchains.

While Ethereum has its native cryptocurrency *(ETH)* that follows almost the same intuitive rules, it also enables a much more powerful function of smart contracts For this more complex feature, a more sophisticated analogy is required. Instead of a distributed ledger, Ethereum is a distributed state machine. Ethereum's state is a large data structure that holds not only all accounts and balances but also a *machine state*, which can change from block to block according to a pre-defined set of rules and which can execute arbitrary machine code. The specific rules of changing state from block to block are defined by the EVM.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.blockdagnetwork.io/get-started/introductory-concepts/evm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
