# Smart contracts

## What are the tools necessary to start developing smart contracts with Ontology？

Please refer to the [Resources](/support/faq/smart-contracts.md) section for more details on this topic.

## What is the difference between execution and pre-execution?

**Executing**, or **running** a smart contract basically transmits the compiled `AVM` bytecode to the engine to be processed and executed. Pre-executing a contract involves the exact same process, except for the following key differences:

* Any transaction that updates the on-chain data will not be able to do so, i.e. the **changes will not be reflected**.
* The transaction will not be transmitted to **consensus nodes**

**Pre-execution** can be used to determine whether or not the contract runs as intended, and can also be used a way to find out the gas fee to run a particular contract.

## What are native contracts and how to invoke them?

Contract protocols such as **ONT** and **ONG**, and other governing contracts are referred to as native contracts. All the methods that are available can found by following [this](https://github.com/ontio/ontology/tree/master/smartcontract/service/native) link. For more information on smart contracts and a more detailed distinction, please refer to the [Smart contract](/guides-and-tutorials/development-guides/smart-contract-dev/neovm-contract/deploy-test.md) documentation.

## Is a contract hash linked to an account? Does it have a private key associated to it?

Yes, the contract hash also corresponds to an account. The way this is implemented is by treating the contract hash as a big endian address of an account that is commonly used for funds management with `dApps`.

The private key to this particular account does exist, but **remains unknown** and **cannot be used** in any manner.

## How to fetch values such as `msg.sender` or `msg.value` within the scope of a contract, much like Ethereum?

Every account that invokes a smart contract needs to pass its account address and the size of the asset that is being transferred parameters when invoking a smart contract.

Within the scope of the contract, the `CheckWitness` method is used to carry out signature verification and to judge the valid asset limit.

## Is there an inbuilt timer or clock in the contract system?

No, there is no timing mechanism in the contract system. However, the `GetTime()` method from [`ontology.interop.System.Runtime API`](https://github.com/ontio/ontology-python-compiler/blob/master/ontology/interop/System/Runtime.py) can be used to fetch the current **timestamp**. The value returned is in **seconds**. The timestamp may be needed considering external contract invocations.

{% hint style="warning" %}
It is advised that the system's timestamp be used within the methods that do not perform any external calls in order to prevent any potential misoperations.
{% endhint %}


---

# 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.ont.io/support/faq/smart-contracts.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.
