Introduction
At the moment, Smart Contracts are only available on Shimmer and its Public Testnet network.
Smart contracts are deterministic applications that run on a distributed network with multiple validators that execute and validate the same code. Their deterministic and distributed nature makes them predictable, stable and trustworthy.
Scalable Smart Contracts
Due to the distributed nature of smart contracts, i.e. they run on a network of validators instead of a single computer, the execution of smart contract is resource intensive as it has to deal with the overhead of the communication between validators in the network. This can lead to relatively high fees for smart contract execution, as well as scalability issues when running on a single blockchain. However, the IOTA Smart Contract Protocol allows many blockchains that execute smart contracts to run in parallel and communicate with one another, therefore solving the scalability problem. Enabling interoperability and horizontal scaling of dApps.
At the same time, ISC provides advanced means of communication between its chains and preserves the ability to create complex, composed smart contracts.
ISC Architecture
IOTA Smart Contracts (ISC) function as a Layer 2 extension to the IOTA Multi-Asset Ledger. As validator nodes execute the smart contracts, they tally these state changes and write them into the chain. In turn ISC chains, each with their state and smart contracts, update their state collectively and interact with Layer 1 and other L2 chains, offering a sophisticated multi-chain architecture.
IOTA Smart Contacts multichain architecture.
Explore the comprehensive overview of IOTA Smart Contracts in the ISC white paper.
Supported VMs
The IOTA Smart Contracts currently supports EVM/Solidity smart contracts, as well as an experimental Wasm VM.
Sandbox Interface
ISC Smart contracts can access the Sandbox interface. This interface provides access to the chain state, native assets, allows interaction with other contracts/chains, as well as various utilities like cryptographic functions and event dispatching.
Calling a Smart Contract
Entry Points and Requests
Smart contracts are activated through entry points, similar to function calls. Entry points can be view-only or allow state modifications. They are triggered by requests, signed by senders. Smart contracts on the same chain can synchronously invoke each other, ensuring deterministic results. However, requests between chains are asynchronous and may involve delays.
Gas
Running a request consumes 'gas'. Gas units are a measurement of "how expensive" a computation is to execute. You can specify a GasBudget
for each request, with costs charged to your on-chain account.
On-Ledger Requests
An on-ledger request is a Layer 1 transaction that validator nodes retrieve from the Tangle. The Tangle acts as an arbiter between users and chains and guarantees that the transaction is valid, making it the only way to transfer assets to a chain or between chains.
Off-Ledger Requests
If all necessary assets are in the chain already, it is possible to send a request directly to that chain's validator nodes. This way, you don’t have to wait for the Tangle to process the message, significantly reducing the overall confirmation time. Due to the shorter delay, off-ledger requests are preferred over on-ledger requests unless you need to deposit assets to the chain.