# Emulate Transaction

Emulate transaction execution locally to understand why it fails

## When you may need it?

If you want to test your contract locally and find out will your operation work on the real network or not, you can emulate it locally.

## Lets debug!

Core SDK provides [run\_executor](/ever-sdk/reference/types-and-methods/mod_tvm.md#run_executor) method of `tvm` module for it.

[AppKit](https://github.com/everx-labs/ever-appkit-js) provides `localDeploy` and `localRun` functions for it.

### How to emulate contract deploy?

To emulate deploy you need to create a deploy message and execute it locally.

If you plan to emulate local execution afterwards, then retrieve account state (BOC) from deploy emulation result and pass it into the next local execution.

See the JavaScript samples below to understand how to emulate contract deploy.

### How to emulate contract local execution?

To emulate local execution you need to take the current contract state (boc), create a run message and execute it locally on the current account state.

If you emulated deploy before run, then you need to get the account state from the result of the deploy emulation.

For the subsequent call emulations, use account state retrieved from the previous local execution emulation.

See the JavaScript samples below to understand how to emulate contract deploy.

## Sample source code

**Core**

<https://github.com/everx-labs/sdk-samples/tree/master/core-examples/node-js/run_executor>

**AppKit**

<https://github.com/everx-labs/sdk-samples/tree/master/appkit-examples/run_executor>


---

# 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.everos.dev/ever-sdk/guides/work_with_contracts/emulate_transaction.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.
