# Smart contracts

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

Please refer to the [Resources](https://docs.ont.io/support/faq/smart-contracts) 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](https://docs.ont.io/guides-and-tutorials/development-guides/smart-contract-dev/neovm-contract/deploy-test) 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 %}
