> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/rome-academy/04-how-rome-runs-your-code.md).

# 4. How Rome runs your code

How a Rome transaction becomes Solana transactions, why most calls run atomically, and what changes when a call is too big.

Your Solidity runs unchanged. What changes is where it runs: inside a Solana program, under Solana's limits. This lesson gives you the picture you need to predict what a call will cost and when it will fail.

## What you'll learn

* The path a transaction takes from your wallet to a Solana validator and back to an EVM receipt.
* The difference between atomic and iterative execution, and why you want atomic.
* Which Solana limits reach your Solidity: compute, size, account count, locks.
* How to measure what a call really costs.

## Before you start

* Finish [3. Your first contract on Hadrian](https://docs.rome.builders/rome-academy/03-first-contract-on-hadrian.md). You need a deployed contract and one transaction you sent to it.
* Keep that transaction hash at hand. You will open it on the explorer at the end of this lesson.

## The path of one transaction

You sign an ordinary EVM transaction and send it to the Rome proxy with `eth_sendRawTransaction`. The proxy does not forward it yet. It first runs the call off-chain in an emulator that executes the same EVM logic as the on-chain program. The emulation tells it three things: how much gas the call needs, which Solana accounts the call touches, and whether the call fits in one Solana transaction.

The proxy then wraps your call as Solana instructions and sends them. The Rome EVM program, which is a normal Solana program, interprets your bytecode. State changes land in Solana accounts. An indexer reads the result and produces the EVM block and receipt your tools expect.

Every EVM address maps to a Solana account owned by the Rome program. Your contract's balance, nonce, code and storage are all Solana accounts. That is why the proxy must know the account list before it sends: Solana requires every account to be named up front.

Read the full lifecycle in [Execution model](https://docs.rome.builders/core-concepts/execution-model.md).

## Atomic first

Most calls run in one Solana transaction. Rome calls this atomic execution (VmAt). It is all-or-nothing: if any step fails, the whole call reverts. A transfer, a swap and most DeFi calls fit. Some do not: an Aave borrow on Hadrian needed more than one Solana transaction.

One atomic call has a budget of about 1.4M compute units. These limits shape every call:

| Limit         | What it means for you                                                                                                                           |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| Compute       | About 1.4M CU shared by the EVM work and every program you call                                                                                 |
| Accounts      | 64 addresses, counting Rome's own accounts and everything your CPIs touch                                                                       |
| Size          | 4 KB per Solana transaction; larger EVM payloads, such as big deployments, are staged through a holder account and the SDK handles this for you |
| Contract size | 24 KB, as on Ethereum                                                                                                                           |

The full list, with the values, is in [Constraints](https://docs.rome.builders/core-concepts/constraints.md).

## Iterative when a call is too big

If the emulator finds that a call does not fit, Rome runs it iteratively (VmIt). The call is cut into legs. Each leg is its own Solana transaction and runs as many opcodes as its compute budget allows. Between legs the VM state is saved in a holder account and the next leg picks it up.

Iterative execution works, but it has a cost:

* A session ends after 160 legs. Past that, it releases its locks and commits nothing.
* The session locks its balance and storage accounts for a few seconds, renewed each leg. An atomic write to a locked account is refused with `AccountLocked`, and the client resends.
* Calls that make Solana CPIs on the legacy track (the `CpiProgram` and `HelperProgram` calls of lesson 5) cannot run iteratively at all. They have to fit atomic.
* On the Solana lane, a wallet that signs its own legs prompts the user once per leg.

The design rule follows: shape each user action to fit one atomic transaction. If a flow is bigger, split it into two user actions rather than lean on iterative mode. Lesson 5 returns to this when you call Solana programs.

## What you pay

Rome counts the cost of a call in Solana lamports: signature fees, a fixed toll, rent for any account the call creates. One gas unit stands for one lamport of cost. The gas price converts that to the chain's gas token, which is USDC on Hadrian and Rubicon.

Rent is the part that surprises people. The first transfer to an address that has never been used creates accounts, so it costs far more than a repeat transfer. Expect high gas on a first touch and ordinary gas afterwards. The worked numbers are in [How Solana and the EVM meet on Rome](https://docs.rome.builders/core-concepts/how-solana-and-evm-meet.md#gas-and-rent).

## Measure, don't guess

EVM `gasUsed` is not a faithful stand-in for Solana compute. On Rome one gas unit is one lamport of cost, so `eth_estimateGas` sizes your gas limit but tells you nothing about compute units. Read compute from the Solana side. Via links the Solana transaction from its "Settled in" row, and the Solana explorer shows its compute units. In code, get the Solana signatures behind an EVM hash with `rome_solanaTxForEvmTx`, fetch each with Solana's `getTransaction` and `maxSupportedTransactionVersion: 1`, and read `computeUnitsConsumed`. An iterative call has one transaction per leg. [Compute budget](https://docs.rome.builders/core-concepts/compute-budget.md) has typical costs per operation and the cheap habits that cut them: constants for program IDs, cached PDA derivations, fewer accounts.

Two behaviors differ from Ethereum and are worth knowing now:

* Rome has no per-opcode gas meter. The gas you pass to a `CALL` is not enforced and there is no 2300-gas stipend. Guard against reentrancy explicitly.
* `block.number` is the Solana slot and `block.timestamp` is the Solana clock.

## Check yourself

Open your transaction from lesson 3 on the Hadrian explorer. Find the network link in [Hadrian](https://docs.rome.builders/networks/hadrian.md) and the explorer notes in [Via explorer](https://docs.rome.builders/apps-on-rome/via.md).

Observe two things:

1. The Solana transaction that settled your call, from the "Settled in" row.
2. The compute units it consumed, on the Solana explorer.

Compare that number with the 1.4M budget. A simple call uses a small share of it.

Then answer:

<details>

<summary>1. Why does the proxy emulate a call before it sends it?</summary>

Solana needs every account named up front, and the proxy has to know whether the call fits one transaction. Emulation finds the touched accounts, estimates gas and decides atomic or iterative.

</details>

<details>

<summary>2. A call makes a legacy-track CPI (the `CpiProgram` and `HelperProgram` calls of lesson 5) and needs more than 1.4M CU. What happens?</summary>

It cannot run. Legacy-track CPIs are refused inside an iterative transaction, so the call must fit one atomic transaction. Split the work into smaller user actions.

</details>

<details>

<summary>3. Why is the first transfer to a new address expensive?</summary>

Rome creates Solana accounts for it, and the rent for those accounts is billed to the sender as gas.

</details>

## Next

[5. Call Solana from Solidity](https://docs.rome.builders/rome-academy/05-call-solana-from-solidity.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rome.builders/rome-academy/04-how-rome-runs-your-code.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
