I was thinking about different smart contract uses cases.


Imagine a service that classifies images. It takes an image of an animal (e.g. a cat) as input and determines the type of the animal.

enter image description here

This kind of classification problem is solved using machine learning. The image recognition service uses training data to create a machine learning model. This model is open to the public via a prediction api. Users pay a fee to query this api. The machine learning model is not immutable. As new images are provided the model is retrained to improve future predictions.

Business transaction

To get a prediction following steps are required:

  • input image
  • check account balance, when enough money is available, proceed, else abort
  • wait for image recognition service to deliver output
  • receive output

Smart contract

So my question is, can this idea/ business transaction be implemented as a smart contract? Does it make sense?

Since a smart contract is immutable, for each (retrained) machine learning model, a new smart contract must be created. And one must keep track of old smart contracts, because they will deliver worse predictions. Or is there an option to destroy "old" smart contracts?

Having a highly mutable service, would it not be better to use a service like oraclize.it to implement API calls to the external service?

2 Answers 2


I think you can still use a smart contract for the payments. This part would be immutable and you can track your payments and such. I think an offchain solution for sending and receiving the images/answer would make more sense. Since the machine learning isnt happening in the contract, you should never have to redeploy it.

  • Thanks Karan, can you elaborate how a smart contract just for payments would look like? What would be the outcome of the contract? Nov 30, 2017 at 13:45

There are three things happening here:

  1. The building of ML model
  2. The inference
  3. The payment for using the service

Now based on your description, what you want is the payment part which can happen on-chain using a smart contract. #1 and #2 are happening off-chain and you don't need to redeploy smart contract for any change there. Payment use-case is applicable for any SaaS, not just an inference service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.