iota iota smart contract iota smart contracts tangle

The Tangle Angle: What Are IOTA Smart Contracts?

Written By Ivan on Tech

Jun 03, 2020

IOTA is one of the most exciting projects in the space with a unique underlying protocol called the "IOTA Tangle” or “DAG.” Tangle has been designed to overcome the inefficiencies of the traditional blockchain and presents a new way for a decentralized P2P system to reach consensus. IOTA allows instant micropayments without incurring a fee, ensuring the fulfillment of the smallest tasks in the unified network like sticking on a tag, turning off the tap in the bathroom, etc. This feature allows IOTA's integration into the Internet of Things by performing transactions between any machines with internet or points. IOTA addresses the main inherent issues of the Internet of Things, i.e., security and scalability.

The IOTA Foundation

The IOTA Foundation was formed in 2015 as a not-for-profit project by four veterans of blockchain technology - David Sønstebø and Dominik Schiener. 

  • David Sønstebø: Describing himself as a “serial entrepreneur’ of technologies, Sønstebø is involved in Internet-of-Things, distributed ledger/ blockchain/ tangle technologies, Smart Cities, Digital identity, eGovernance, and innovative hardware design. He is also the founder and serves as the CEO of a stealth hardware IP start-up developing an ultra-low-power processor for the Internet of Things.
  • Dominik Schiener: Schiener has founded several companies before IOTA - Finhaus Ltd. in 2015, BitHaus GmbH in 2014, and Fieyy in 2012.  He is working on several projects based on blockchain and smart contracts, especially on new Governance solutions that make use of both, collective intelligence and new technologies to create more efficient, cheaper, and transparent systems.

The IOTA team is segregated into working groups focused on promoting and enabling IOTA's use in Identity and MyDate; Social Causes; Supply Chain; Mobility; E-Health; Fintech; Smart Cities and Infrastructure; R&D; Interoperability; Energy; Industry 4.0; and Others.

Tangle - How does it Work?

IOTA’s tangle has no blocks and every transaction confirms two older transactions, i.e. for every transaction to get approved, it relies on one or more following transactions to happen (IOTA Tangle needs two parent transactions). This forms a never-ending tree-like structure. Unlike Bitcoin or Ethereum, the consensus and validation are done by the whole network of active participants by giving everyone an equal say in the network regarding the transaction making process.

The process has three steps:

  • At first, a user signs the transactions with a private key.
  • Then tangle uses Markov Chain Monte Carlo (MCMC) algorithm to select two unconfirmed transactions to check if these do not produce conflicting results.
  • Next, the node is required to solve a cryptographic puzzle to validate the transaction. This step is similar to Bitcoin's means some Proof-of-Work consensus system. 

On successful completion, the network accepts the transaction. Executing the MCMC algorithm provides information about the possibility of the transaction the system allows. IOTA offers traders the freedom to decide with which probability they want to start accepting payments. IOTA works with a single administrator node called the Coordinator, which confirms all transactions in a set of released milestones. The Coordinator assures security in the early stage of the network as it grows. It will eventually be removed when the network becomes sufficiently large. Also, interestingly, IOTA tokens are not mineable.

Tangle vs Blockchain 

Tangle architecture several advantages over traditional blockchain technology - it is highly scalable, decentralized, modular in nature, and fee-less.

  • Highly Scalable: The Directed Acyclic Graph (DAG) provides a more decentralized solution than blockchain. Tangle’s parallelized transaction validation allows the IOTA platform to handle a vast number of transactions than any of the competing blockchain technology, meaning a very high throughput and leading to a true machine-to-machine transaction solution. This means all IoT devices are paying or transacting each other for services given in an extensively complex network without the need for a digital ledger or a ledger consensus process to slow them down.
  • No Fees for Transactions: Tangle has eliminated the need for miners or validators. Instead, the network users take up this task of validation through computation, leading to zero transaction fees for small value exchanges. Therefore, IOTA’s IoT-based ecosystems can handle vast volumes of micro and nano transactions without worrying about high fees or unpredictability of the fees.
  • Compatible with IoT: The IOTA Tangle is designed and optimized with the limitation of IoT devices in mind. As these devices will actively participate in the validation of the network transactions, IoT devices must handle the IOTA client.
  • Partition-Tolerant: In a blockchain, all users need to synchronize for every transaction. On the other hand, in IOTA, multiple tangles exist in numerous disconnected clusters, allowing it to make offline, asynchronous transactions. This works perfectly for IoT devices since asynchronicity is necessary for its operations.
  • Security: Though blockchain has taken the tech world by storm, with the eventual introduction of Quantum computing,  its dependency on cryptography can become a problem. Quantum computing will allow hackers to launch brute force attacks against blockchain-based applications. This is where Tangle can shine as it uses a quantum-resistant algorithm called the Winternitz One-Time Signature Scheme, providing much better inherent security against this threat.

IOTA Consensus Mechanism

IOTA’s consensus mechanism used to be based on a centralized coordinator who made sure that no one is misbehaving in the ecosystem. The idea was to have honest nodes picking up transactions that are yet to be validated and attacking them to the Tangle. IOTA has since decentralized its co-ordinator with the Coordicide protocol. While this is very admirable, IOTA had to take one more step to ensure that the consensus process is as seamless as possible.

Shimmer voting

  • Shimmer consensus only cares about the opinion of a mall subset of nodes. Its primary purpose isn’t to change the view of the supermajority.
  • The nodes don’t need to vote on every transaction. Votes are only required to resolve conflicts.
  • If a node receives two different sub-tangles simultaneously, it will reject the vote at once and decides on a "sole survivor."
  • If the node violates this rule, they get punished by being permanently dropped from the network.

Alternative consensus mechanisms

IOTA is also looking to integrate the following consensus mechanisms:

  • Cellular consensus.
  • Fast probabilistic consensus.

Cellular Consensus

  • This process looks like a cellular automaton in which the individual nodes act as cells that regularly take note of their neighbor’s behavior.
  • The nodes adjust their personal opinion per their neighbor’s state.


  • The implementation is straightforward and asynchronous. 
  • It’s highly resilient to attack vectors and its message overhead is very efficient.


  • While there is no doubting its capabilities, the biggest problem with Cellular consensus is it’s chaotic and complex nature. It needs to thoroughly tested in a testnet before mainnet deployment.

Fast Probabilistic Consensus (FPC)

  • FPC is similar to Cellular, but the only difference is that instead of being an asynchronous system, the voting process occurs in multiple rounds.
  • In each round, a node randomly chooses some of its peer nodes and asks them to give their current opinion on a particular query.
  • The node then creates its view based on the majority of the answers it receives from the rest of the network.
  • The node continually changes its view based on the majority it receives in the subsequent rounds.
  • After the node doesn’t change its state following a certain number of voting rounds


  • The system uses a non-fixed threshold for its majority. A decentralized random number sequence derives this thresh. Making the threshold non-fixed ensures that attackers don’t nuke the algorithm to delay consensus.
  • Consensus is guaranteed within a small number of rounds and with a small set of nodes compatible with Shimmer’s voting philosophy.

IOTA Collaborations and Projects

The IOTA Foundation has established a collaboration with Volkswagen and Innogy to develop CarPass - an IOTA based technology that brings features such as secure audit trails, digital identities, and charging networks for cars.

With Microsoft, Deutsche Telekom, Fujitsu, and Samsung, the Foundation opened up a data marketplace using IOTA technology. The IOTA Foundation is also a founding member of the Trusted IOT Alliance, which includes four firms Bosch, ConsenSys, USbank, and Cisco. As per IOTA’s Twitter post, Porsche Digital Labs and IOTA will be working together on a project initiated by Startup Autobahn called Program 4.

In September, the CognIOTA processor platform (CPU) announced IOTA as its payment instrument. The platform allows users to rent their idle CPU's for others in the network to use in real-time. 

IOTA's MAM (masked authenticated messages) is already being used in The Bosch XDK IoT developer kit and the RuuviTag, an open-source sensor beacon from Ruuvi Labs. Examples of these are portable weather stations, Eddystone proximity beacons, vehicle locators, and similar applications that securely report telemetry data, or receive instruction. On May 29, 2018, IOTA released Trinity Wallet, accessible from both desktop and mobile.

Will IOTA be able to do smart contracts?

The tangle’s chief properties - mainly scalability, high throughput, and feeless transactions - lends itself organically to several verticals like supply chain, smart cities, industrial IoT, etc. To make all these a reality, IOTA must have smart contract functionalities. So, before we go further, let’s understand what a smart contract is.

What is a smart contract?

Think of how a contract was and what it is. Its a legally binding agreement between two people, wherein one party provides a service, while the other party pays them for it. All this is overseen by a third-party, like a lawyer. The third-party ensures that no one violates the terms of the contract.

The problem here is obvious. How can you make sure that overseeing third-party is going to do their job well? Thankfully, smart contracts allow us to create a system where we can negate the need for a third-party. Nick Szabo first conceptualized the idea, and they are a list of deterministic instructions that are automated and self-executed. Smart contracts work on an “IF-THIS-THEN” philosophy.

  • IF: The condition is met.
  • THIS: The action is executed.
  • THEN: The next condition is checked.

Each line of code in the smart contract gets executed sequentially.

Are smart contracts on IOTA layer-1 or layer-2?

Layer-1 and Layer-2 are terms used to describe functions that are on-chain and off-chain, respectively. 

Layer-1 smart contracts

Protocols like Ethereum use layer-1 smart contracts. The contract code is executed and validated by all the nodes in the network. 


  • The biggest the network, the most the security of the smart contract.
  • You don’t need to provide a signature to transfer tokens from your account.


  • The biggest problem with layer-1 smart contracts is that they are not very scalable since a supermajority of the nodes must execute them.
  • The interactions within the contracts are subject to volatile network transaction fees. Plus, these fees are proportional to the price of the underlying token.
  • Layer-1 smart contracts also tend to bloat up the blockchain. So if a dApp becomes popular, the demand may delay routine transactions within the network.

Layer-2 smart contracts

On the other hand, we have off-chain smart contracts that are executed on top of the underlying blockchain. A committee chosen by the Owner completes the contract. The committee is a subset of all the nodes in the network.


  • The overall cost of a smart contract interaction is not tied to the volatility of the underlying asset.
  • The contract doesn’t bloat up the main blockchain. 
  • Since a supermajority of the nodes doesn’t need to approve the contract it’s a lot more scalable.


  • Since the contract is not running inside the blockchain, you will need to sign every single transaction.
  • Not as decentralized as the layer-1 option.

How do smart contracts work in IOTA?

IOTA uses layer-2 smart contracts, which act as “immutable state machines.” What exactly does that mean? Well, let’s take a look:

  • Immutability means that whenever some data is added inside IOTA’s tangle, it's non-tamperable. Tangle also provides full transparency and a complete audit trail of its transactions.
  • The state of a smart contract includes data such as account balances, input data, and changes made in the instance of a smart contract over time. Every single state transition made on the Tangle is considered a state update.

Why are IOTA smart contracts layer-2?

As mentioned above, the main problem with layer-1 smart contracts, like in Ethereum, is its severe lack of scalability. Every single, smart contract interaction is like a typical blockchain transaction that needs to be approved by a majority of the nodes in the network. This creates a massive bottleneck in the entire process. As the network increases in size over time, it will delay the process even further.

Along with that, there is also a cost issue. Not only do you have to pay the transaction fees, but you will also need to pay “gas fees” to keep the contract running. Every single line of code costs a certain amount of miner computational power, called “gas.” As such, executing these contracts can become expensive, which can turn off the developers from entering the space.

This is the biggest reason why IOTA smart contracts are layer-2 protocols. Every single IOTA smart contract can run in a localized environment without forcing the whole network to solve a gazillion different transactions every single day. Another cool off-shoot of this property is that it will allow IOTA to integrate sharding in the future effortlessly.

Smart Contracts on IOTA - The Components

Now, let’s look into the different components that make up an IOTA smart contract.

#1 The Owner

As with any protocol, every single smart contract has an owner. The owner can be a single entity or a group of individuals. 

The owner is in charge of:

  • Creating the underlying code and submitting it to the network for validation.
  • They are not in charge of running the contract. 
  • Selecting the committee in charge of the contract execution. The committee consists of specific nodes that are designated a particular contract for implementation.
  • Deciding how many nodes in the protocol need to validate a contract transaction for it to pass through. This number is also known as a “quorum.”
  • Defining general configuration parameters of the smart contract.

The owners need to decide how to customize their smart contracts, depending on their role and purpose. Eg. A smart contract that handles a game contract, which does microtransactions, needs only a few nodes in the committee.

#2 Economic and Social Incentives

Having read the previous section, a pretty valid question to ask here is – Why should the IOTA nodes be bothered with being a part of a committee for your contract? What do they have to gain? After all, IOTA transactions are supposed to be feeless, right? Well...not so much.

Turn out that you can integrate certain economic and social incentives in your contracts to benefit your committee. First, let’s look at some financial incentives.

  • Owners can charge a fee on their IOTA smart contracts to covers operational costs. This basically acts as a reward.
  • Both the owner and the committee can receive these rewards. The owner can negotiate with the committee nodes to decide how the reward gets distributed.

Along with the economic aspect, committees have the opportunity to earn some social brownie points and build a good reputation.

  • Smart contract owners will only want to choose nodes that have a good reputation and work history.
  • This will only incentivize the committee nodes to do everything in their power to provide the best possible service.

#3 Committee and Quorum

The committee owns the smart contract address and contains the locked up IOTA tokens. These tokens are open to only a quorum of committee nodes that must cooperate to move these tokens. IOTA ensures that nodes have equal ownership over these tokens due to the Boneh–Lynn–Shacham (BLS) signature scheme. This ensures the quorum must produce a valid signature with their secret key to update the contract’s state and move the funds locked up in the contract.

How to Code IOTA Smart Contracts?

The underlying code of smart contracts in IOTA is WebAssembly (WASM) language. These contracts are executed in the Virtual Machine (VM). Here are some things keep in mind when you are creating these contracts.

  • The program takes in two transactions as input - Request transaction and Current state transaction.
  • The next transaction has to refer to the request transaction and the previous state transaction to create a link.
  • This linking allows you to deterministically build a chain of state changes that gets triggered via input functions.
  • Tangle stores the hash of the program, making it immutable. Any change made in the code will change the hash, which triggers a snowball effect.

Post-Coordicide, IOTA will enjoy full smart contract implementation. It will implement the UTXO model (made famous by Bitcoin) for value transactions.


IOTA has one of the most compelling underlying technology in the space. It’s literally unlike any other project out there, and the tangle architecture should be studied in-depth. Learning how to create IOTA smart contracts will help you interact with it on a very deep level. They have made some exciting partnerships in recent times and have an excellent team. With the implementation of Coordicide, IOTA has managed to integrate more profound decentralization into its protocol. Be on the lookout for this project.

Meanwhile, why don’t you check out some of the courses we have on Ivan on Tech Academy? We have several high-value accredited courses on blockchain and cryptocurrency that have been created by our in-house trainers and industry experts. What's more, the extensive Ivan on Tech Academy blog breaks down everything from the advantages of DeFi, how to increase your developer salary, understanding crypto staking, or knowing how to choose the right blockchain school.  If you want to learn how to code blockchain games or learn about the technology itself, then look no further!

Like what you're reading?

Get to work in a fast growing industry. Start learning blockchain together with our 20,000+ students today.
Use coupon code BLOG20 for 20% off.

Become Blockchain Certified Today No Prior Knowledge Needed!

Get our Free Ebook

Enter your email and we will send it to you!