---
# System prepended metadata

title: SmartContract Layer

---

# SmartContract Layer

## Inroduction

SmartContract Layer is the direct embodiment of democratic ideas. It includes a focus on flexibility, efficiency, reliability, security. This layer is an integral part of the DAG Chain and is tightly integrated into it.

Democratic values ​​embodied through flexibility, security, a wide range of capabilities, and the possibility of implementation in many programming languages ​​is great distinguishes this approach from alternatives in the form of BitCoin Scripts Etherium SmartContracts (EVM Solidity) etc. Instead of integrating the custom Virtual Machine, the advanced and well-established WebAssembly (Wasm) approach has been chosen. This allows to use an existing technology stack for a wide range of programming languages: Rust, C / C ++, Go, JS / TS, Python etc. Remind that the WebAssembly is actively used on the side of Web Browsers as a new step in Web-applications. This allows to implement truly complex, required resources, complex applications in an area where it could only dream about it before. For example, full-fledged 3D games in Web Browsers, using 3D graphics and have-large computation requirements.

However, the use of WebAssembly is not limited to Web Brawsers. WebAssembly is ideal for creating SmartContracts and Smart Business solutions.

In fact execution environmant is SandBox. It mean that VM completly isolatate form outside word. This provides an uncompromising level of safety and reliability, efficiency.

Decracy integratin WebAssembly to create SmartContracts uses another cutting-edge technology that is part of the future WebAssembly standard: WASI (WebASsembly Interface). This provides uncompromising opportunities for integrating Wasm with DAG Chain. Which in turn significantly expands the possibilities for translating business ideas into real world projects, without regard to the system’s strict limitations (VirtualMachine environment restrictions). This will allow you to quickly and efficiently introduce new ideas of democratic values, with a guarantee of security and reliability. And this is a great step towards economic, business efficiency.

## Technical properties

As an integration environment an advanced innovative tool, Wasmer, is used. Wasmer supports WebAssembly compilation, which guarantees high performance speeds close to those of hardware.

Great points of Wasmer is:
* Fast: Wasmer aims to run WebAssembly at near-native speed
* Pluggable: Wasmer can be used from almost any programming language
* Safe: supporting WASI and Emscripten

The Wasmer supports such mackend:
* **LLVM**
* **Cranlift**
* **Singlepass**

The Wasmer WebAssembly runtime provides various features for users and developers:
* **Backends**: Wasmer supports multiple compiler backends: Singlepass, Cranelift and LLVM. Each of these have different tradeoffs of compilation speed vs runtime speed.
* **Caching**: compiled WebAssembly modules can be reused so subsequent runs of a Wasm file will have very little start up time
* **Metering**: computation time and other resources can be monitored and limits set to control how the Wasm code runs. This is also known as "gas metering"
* _WebAssembly Features_:
  * **Multi-value** return: return multiple values from functions making data transfer between host and guest simpler
  * SIMD: Single Instruction, Multiple data: do heavy number crunching more quickly and/or with lower power usage
* ABIs: it allows to run different types of programs compiled to WebAssembly, with ABIs such as:
  * Emscripten
  * WASI

## DAG integrations

SmartContracts supports features:
* DAG Chain transactions operations
* DAG Chain Node operations
* HTTP requests
* Oracles integractions
* File Storage operations

SmartContracts Layer future plans is:
* Integrations with various types of external SmartContractd like Etherium, Stellar etc.
* Web API integration
* Full-featured SDK
* Debugging and deployment tools for testnet

### SmartContract Layer diagram

![](https://i.imgur.com/ywabBLT.png)

Layer represent basic structural components of  the SmartContracts.
Central elements are:
* Node runtime
* DAG chain

DAG chain layer is not part of the SmartContract layer and presents to define a more complete point of view.

## Layer parts, descriptions and time estimation

For roadmap we should have basic points:
* 1-milestone - part of MVP
* 2-milestone - part of basic layer extensions
* 3-milestone - stage of additional features

### Descruptions & Estimations

* **Node runtime** is a core element of the SmartContract layer. [1-milestone]
* **Node VM runtime** is a runtime and compilation environment for full-featured operations with SmartContract. **[1-milestone]**
* **DAG chain HTTP API** is layer for external communication with **Node runtime**. **[2-milestone]**
* **Development Kit** is toolset with additional tools and features to communicate with **Node runtime**, developing, testing, deploy the SmartContracts and many other possibilities from CLI (command line interface). **[3-milestone]**

### Node VM Runtime

#### WasmVM
It's 1-milstone. 
Based on **WebAssembly VM** (WasmVM).
Possible WasmVM's are:
* Wasmer
* wasmtime
* Lucet

More preferable is **Wasmer**.

#### Gas Metrics
It's 2-milestones. It's part of metrics for reward calculation after SC successful execution.

#### VM extention with DAG feature
1-milestones. Represent extension of Wasmer for DAG chain.

#### SmartContracts SDK
The SC SDK for development and supports. 2 & 3 milestones

#### WASI
WASI is WebAssemble intefaces for extending WasmVM. Very important part of integration VM to DAG chain. 1 and 2-milesones.

