# EVM

The Ethereum Virtual Machine (EVM) is the core component of the Ethereum blockchain, responsible for executing smart contracts and managing the state of the network. It acts as a decentralized computer, maintaining a global state and executing program instructions defined in smart contracts. Key features include:

* **State Machine**: Executes transactions and changes the blockchain state.
* **Deterministic Execution**: Given the same input, it will always produce the same output.
* **Isolated Execution**: Executes code in a sandboxed environment.

**References**:

* [Ethereum Yellow Paper](https://ethereum.github.io/yellowpaper/paper.pdf): The authoritative technical document that defines the EVM and its operational mechanisms.

### Learning Resources

#### Tutorials and Guides

* **EVM Playground**: An interactive platform for experimenting with EVM opcodes and bytecode. It provides detailed explanations and visualizations of how EVM executes opcodes.
  * **Accessing Constant Variables**: Learn how to define and use constant variables in EVM. [Link](https://evm.codes/playground?lesson=1)
  * **Function Parameters from Calldata**: Understand how to access function parameters using calldata. [Link](https://evm.codes/playground?lesson=2)
  * **Testing Macros in EVM.codes**: Build and test functions using raw EVM bytecode. [Link](https://evm.codes/playground?lesson=3)
  * **General EVM Playground**: [Link](https://evm.codes)

**EVM Cheatsheet**: A comprehensive guide detailing EVM architecture, functionalities, and operational mechanisms. It covers:

* EVM Architecture: Stack, memory, storage, and instruction set.
* Bytecode and Opcodes: Detailed explanations of EVM bytecode and commonly used opcodes.
* Memory vs. Storage: Differences and use cases.
* Gas and Gas Management: Understanding gas costs and optimization techniques.
* **Link**: [EVM Cheatsheet](https://github.com/pylaugh/evm-cheatsheet)

#### Academic Research

* **Smart Contract Decompilation**: Learn how to decompile EVM bytecode back into high-level languages like Solidity. Tools like Mythril, Ethersplay, or Porosity are used for this purpose.
  * **Mythril**: [Link](https://github.com/ConsenSys/mythril)
  * **Ethersplay**: [Link](https://github.com/ConsenSys/ethersplay)
  * **Porosity**: [Link](https://github.com/gnidan/porosity)
* **EVM Execution Model**: Explore how EVM executes opcodes, manages memory and storage, and handles transactions.
  * **Link**: [Ethereum Yellow Paper](https://ethereum.github.io/yellowpaper/paper.pdf)

### Tools for EVM Development

* **EVM From Scratch**: A project that guides you through implementing your own EVM in various programming languages. It helps in understanding the core mechanics of EVM.
  * **Link**: [EVM From Scratch](https://github.com/w1nt3r-eth/evm-from-scratch)
* **EVM Puzzles**: A collection of interactive puzzles designed to help you practice and understand EVM operations.
  * **Link**: [EVM Puzzles](https://github.com/fvictorio/evm-puzzles)

### Community and Discussion

* **EVM Learning Manual**: A curated list of resources for learning EVM, maintained by the blockchain community.
  * **Link**: [EVM Learning Manual](https://learnblockchain.cn/article/4800)
* **Stack Overflow**: A platform where you can find answers to common EVM-related questions and participate in discussions.
  * **Link**: [Stack Overflow - EVM Tag](https://stackoverflow.com/questions/tagged/evm)

### Practical Examples and Use Cases

* **Contract Address Generation**: Learn how contract addresses are generated using sender address and nonce.
  * **Link**: [Contract Address Generation](https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed)
* **Bytecode Decompilation**: Understand the process of converting bytecode into opcodes and reconstructing high-level code.
  * **Link**: [Mythril Documentation](https://mythril.readthedocs.io/en/latest/)
* **Storage Management**: Explore how EVM handles storage variables, including writing to and reading from storage slots.
  * **Link**: [Solidity Documentation - Storage](https://docs.soliditylang.org/en/v0.8.17/internals/layout_in_storage.html)

### References

* **EVM Playground**: <https://evm.codes>
* **EVM Cheatsheet**: <https://github.com/pylaugh/evm-cheatsheet>
* **EVM From Scratch**: <https://github.com/w1nt3r-eth/evm-from-scratch>
* **EVM Puzzles**: <https://github.com/fvictorio/evm-puzzles>
* **EVM Learning Manual**: <https://learnblockchain.cn/article/4800>
* **Stack Overflow - EVM Tag**: <https://stackoverflow.com/questions/tagged/evm>
* **Contract Address Generation**: <https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed>
* **Mythril Documentation**: <https://mythril.readthedocs.io/en/latest/>
* **Solidity Documentation - Storage**: <https://docs.soliditylang.org/en/v0.8.17/internals/layout_in_storage.html>


---

# Agent Instructions: 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:

```
GET https://docs.pharos.xyz/resources/evm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
