-
Notifications
You must be signed in to change notification settings - Fork 205
Executing certain Transactions requires the execution of SmartContracts, which are custom programs that can perform complex tasks on behalf of the caller. The execution of any SmartContract is always initiated by a Transaction, and the results of the SmartContract will be stored on the Blockchain as part of the Transaction that initiated it. It is required that all Nodes which execute a SmartContract must arrive at identical results, otherwise the entire Block that was being built at that time might be rejected (see Participating in Consensus for details on how Blocks are approved or rejected).
The actual task of executing SmartContracts falls to a dedicated software component called the Virtual Machine (VM). Note that this VM has nothing to do with applications such as VirtualBox or VMWare - these are system virtual machines, specialized in virtualizing hardware and running entire operating systems. By contrast, the VM used to execute SmartContract code is a process virtual machine, specialized in providing an isolated and abstracted runtime environment, independent of the physical platform or of the underlying operating system. It is thus more similar to the Java Virtual Machine, although designed with a more specialized purpose and enriched with APIs that enable the programs it runs to perform Blockchain-specific operations.
In order to execute SmartContract code, the Elrond Node currently provides its own custom Virtual Machine, called IELE VM. The Node is not limited to this VM, though - by virtue of its Virtual Machine Adapter, the Node can theoretically support any number of different Virtual Machines. There is ongoing work to integrate a WASM-based VM with the Elrond Node. Still, the VM with the best support currently remains IELE.
- ☐ What can a SmartContract do?
- ☐ Examples of SmartContracts
- ☐ Computing resources available to SmartContracts (i.e. permanent storage)
- ☐ Execution environment of a SmartContract
- ☐ What is there to know when writing a SmartContract?
A SmartContract is a piece of code containing individually-callable functions named Methods, which perform some predefined tasks on the Blockchain, on behalf of its caller. These tasks are designed by the developer of the SmartContract, and available to any user of the Elrond Network. The SmartContract developer then writes the code of the SmartContract in their programming language of choice. It is important that developers document the behavior of their SmartContracts properly, because users must understand what it does before calling any of their Methods and trust that the code is not performing any malicious actions.
After writing the code, a SmartContract must be deployed to the Blockchain before any attempt to execute it. Deploying a SmartContract involves compiling the written code to bytecode, then constructing a special Transaction which, when executed by the Nodes, will cause the SmartContract to be validated, stored and published on the Blockchain.
- ☐ Structure of a SmartContract
- ☐ Compiling a SmartContract
TODO
TODO
TODO