Oscar W

Tech Savvy. ReactJS Developer. Blockchain Enthusiast.

AI Smart Contracts — The Past, Present, and Future

This article is the second part of a series on AI on blockchain Ecosystems. In these overviews, I will provide outlines of why we need it, how is it achieved, and what does it offer.

Article Series:

- Part 1: AI on Blockchain — What’s the catch?
- Part 2: AI Smart Contracts — The Past, Present, and Future
- Part 3: Running Artificial Intelligence on the Blockchain
- Part 4: Cortex AI on Blockchain Ecosystem
- Part 5: AI on Blockchain Use CasesS

Smart contracts, known to be used with the blockchain technology, is a computer program that directly controls the transfer of digital currencies or assets between parties under certain conditions.

Smart contracts, contrary to traditional contracts, covert the agreement statements into a computer program with code. A smart contract not only defines the rules and penalties related to an agreement in the same way that a traditional contract does, but it can also automatically enforce those obligations.

It has the potential to disintermediate industries such as the legal and financial fields by simplifying and automating routine and repetitive processes for which people currently pay lawyers and banks hefty fees to do.

How Do Traditional Contracts Work?

A traditional contract is an understanding or agreement between two or more parties to do certain things. It is a written set of conditions and actions to be performed. Since the written contract is not void of ambiguity, different parties can have a different interpretation of the contract. Thus, it requires a third party to enforce the law.

A contract contains the agreement statements in written formats, such as,

If Team X wins, all the money shall be given to A. If Team X loses, all the money shall go to B

The execution of a traditional contract requires human validation to check the terms and conditions and decide the next steps according to the written agreement. Limitations with traditional paper contracts are:

  1. They are Passive — Whenever a contract needs to be enforced, it is done passively in which a party does the paperwork internally and send it to the other party to check the paperwork and respond accordingly back to the original party.
  2. Asymmetric Information — It is difficult for both parties to have the same data in hand to create a fair contract; not to mention that most of the times there will be missing data.
  3. They are Inefficient — A contract needs to be checked, validated, and approved, enabled next steps, etc.
  4. Costly — It may involve a third party which consumes time and resources.
  5. User Error and Fraud — Even if the above points are solved, it does not neglect the possibility for a party to break the contract.

How Do Smart Contracts Work?

In 1994, Nick Szabo, a legal scholar and cryptographer, developed the idea of “smart contract” with the goal of bringing highly evolved practices of contract law on electronic commerce protocols for strangers on the internet. Nowadays, smart contracts are programming codes that store and replicate on the system and supervise by the network of computers that run the blockchain.

Because smart contracts exist on the blockchain, anyone can program the codes that self-executes without the need for intermediate parties. For example, a smart contract could look like this:

Starting Balance in the contract = Take Money From A.
Update Starting Balance = Take Money From B.
Record outcome of the bet as per received signal.
If ( Outcome = ‘Team X wins’ ) { Send Money To A }
Else { Send Money To B }

When the code is uploaded onto the blockchain as a transaction in a new block, it will wait for the signal to execute base on the result of the bet. When the smart contract receives the signal, it will execute automatically to send the money to the rightful winner of the bet.

Issues With Traditional Contracts Solved

Using smart contracts can solve the problems that traditional contracts are facing:

  1. Execution of smart contracts is Active — Once both parties agree with bone or more conditions are met, the smart contract will automatically run the codes and no one can stop the process.
  2. Full record and Data available — Records and origins of data are all stored on the blockchain, thus eliminates asymmetric information.
  3. Smart contracts are Efficient — The code executes within seconds and sends the money immediately.
  4. Low fee — There is no paperwork or third party involved which cut down the cost.
  5. Eliminate User Error — Smart contracts eliminate user facilitation to the minimum which reduces user error and fraud.

Smart contracts’ potential goes beyond the simple transfer of assets, there could be multiple smart contracts linking to one another to provide utility to other contracts. The same principle applies to real-world scenarios. Industries like medical records, logistics, finance, insurance, and IoT can all benefit from the smart contracts to eliminate third parties.

How Are they Used Today?

Blockchain and smart contracts are two different technologies, however, blockchain is ideal for storing smart contracts because of its security and immutability. Bitcoin, being as the first blockchain use case, has limited smart contract support. Unlike Ethereum, Bitcoin is not “Turing-complete” meaning the complexity of the algorithms is restricted.

In 2014, Vitalik Buterin designed and developed Ethereum with smart contracts in mind. One of the most renowned uses of smart contracts is the ERC20 token, a standard based on the Ethereum network allowing issuance of tokens that can be traded with another token. Smart contracts are used to facilitate transactions of tokens and record balances of tokens. Well-known Tokens such as BNB, ZRX, TUSD, BNT, KNC, LINK are all ERC20 based.

However, a recent study done by Kiffer, Levin, and Mislove showed that the diversity of smart contracts are “low and most contracts are direct- or near-copies of other contracts”.

Ethereum’s smart contract ecosystem has a considerable lack of diversity. Most contracts reuse code extensively, and there are few creators compared to the number of overall contracts. It remains to be seen whether this lack of diversity is endemic to smart contracts (or Ethereum itself), or if it is merely a reflection of the relative youth of smart contracts as a whole — perhaps as new contracts and modes of interactions are developed, we will see an increase in diversity. — Kiffer, Levin, and Mislove

The status quo is about to change. Whilst there are various approaches to solving the problem, enabling AI on the blockchain and integrating AI to be nested within the smart contract offers us a powerful solution. Without enhancing the capability of the smart contract it is hard to implement real-world applications.

The Future Of Smart Contracts

Cortex is a decentralized Artificial Intelligence Platform that supports AI smart contract and AI execution. AI developers can upload their models to the blockchain, Smart Contract and DApp developers can then access these AI models by paying CTXC, the Cortex native token.

With Cortex’s unique approach to bringing AI inference directly on-chain, the inference result no longer comes from a third-party Oracle, eliminating the trust problem. Fundamentally, what Cortex does is to explore the new possibilities when computing power of the Virtual Machine is enhanced with a specific set of instructions.

The writing of AI smart contract can be done with Solidity, the programming language used for Ethereum developers. Cortex’s CVM is backward-compatible with EVM but adds infer instructions.

Nowadays, advanced sports statistics are available on websites like basketball-reference. Let’s say you use the historical data and develop a prediction model on future winning outcomes, and you also want to make bets automatically if predict winners at a rate of above 80%.

An AI smart contract with this prediction model could look like this:

Prediction result (that Team X wins) = Infer prediction model with Team X against Team Y
If ( Prediction result > 0.80 ) { send Money to bet Team X wins }
Else if ( Prediction result < 0.20 ) { send Money to bet Team Y wins }
Else { do nothing }

When you provide Team X and Y to this AI smart contract (or even write another smart contract to get the daily schedule on the internet to further automate the process), it will predict the winning percentage rate of Team X against Team Y and make bet base on the prediction.


Artificial intelligence is changing how we conduct our daily lives and various industries are turning to AI. Using blockchain without AI is asking the industries to move backward. This is the real reason why smart contracts have not been very successful thus far — the lack of integration of Artificial Intelligence with blockchain. The AI smart contract is the much-needed feature missing in all popular blockchains today.

As the first infrastructural blockchain to support on-chain AI, Cortex will not only allow AI smart contract but will also build an open source developer community to facilitate the future development of AI and blockchain technology. The entire ecosystem will have a supportive open-source platform in AI and blockchain development.

More by Oscar W

Topics of interest

More Related Stories