Machine Learning in the World Of Blockchain and Cryptocurrency

Exploring machine learning and its applicability in the world of cryptocurrency mining and trading.

Photo by Thought Catalog on Unsplash


The world of Cryptocurrency and Blockchain is increasingly getting more exciting and rightfully so, as both Ethereum and Bitcoin have so far seen all-time highs in price in 2021. And not to mention an increase in the application of blockchain technology, especially with the rise in popularity of Non-Fungible Tokens (NFTs).

Like any technology, blockchain and cryptocurrencies have issues associated with security, utilisation, and efficiency. Beyond all the excitement and mainstream attention, there are reasonable efforts focused on solving significant blockchain-related problems.

This article will introduce a few of these said problems and the research efforts that are using machine learning techniques to solve blockchain/crypto related problems. Research presented in this article was released within the last few years.

1. Trading (Reinforcement Learning)

Photo by Pierre Borthiry on Unsplash

Trading cryptocurrencies such as Bitcoin and Ethereum has become an activity amongst retail investors and large financial institutions. As of the writing of this article, there are 308 cryptocurrency exchanges tracked on CoinMarketCap.

Traditional trading bots used in the stock market today come with embedded machine learning-powered algorithms. Therefore, it’s no surprise that ML techniques also lend a hand in building systems that trade the cryptocurrency markets.

Typing “Machine Learning crypto trading bots” on Google search engine yields over 12 million search results, but let’s draw our attention to academic efforts.

Thomas E. Koker and Dimitrios Koutmos authored a research paper that presented the use of direct reinforcement learning to create a model for cryptocurrency-based active trading.

Reinforcement Learning(RL) is a subdomain of Machine Learning that’s common within the game and simulation programs. RL operates by training programs (agents) on developing an optimised strategy (policy) towards gaining rewards within an interactive environment.

The approach presented in this particular research leverages Direct Reinforcement Learning (DRL). There is no immediate feedback on performance to the agent in traditional RL, but within DRL, the performance from previous windows is used as feedback to the agent. Using DRL, the researchers were able to do away with creating a price forecasting model and created a system that adapts based on a specified time interval (daily).


Reinforcement Learning is a viable approach to develop cryptocurrency trading strategies that are profitable and adaptive.

2. Optimizing Mining Strategies (Reinforcement Learning)

Photo by Bart van Dijk on Unsplash

Before I go into research here’s a quick crash course on how bitcoin mining works. Mining cryptocurrency involves employing computing resources to guess a set of values used to solve a function on a blockchain. The miner that solves the function is allowed to update the blockchain with valid pending transactions.

The blockchain network is then updated to contain the new transactions. The purpose of mining is to update the blockchain with pending transactions, and rewards are provided for the miners' efforts.

Miners are rewarded for this effort with block rewards(i.e. bitcoin) and transaction fees accrued from corresponding transactions. The more powerful your computer is, the more guesses you can make to solve the function. Do note this is an oversimplified description of crypto mining, but you get the gist.

This section explores research efforts towards presenting the applicability of ML techniques to optimise mining efforts and prevent the hijacking of mining resources.

Taotao Wang, Soung Chang Liew, and Shengli Zhang authored a research paper, published in Jan 2021, that presents the application of reinforcement learning(RL) for optimising blockchain mining strategy for cryptocurrencies like Bitcoin.

Their research effort proved that without an initial model of the blockchain and corresponding parameters (miner’s compute resource, transaction fees etc.) it was possible to leverage RL techniques to dynamically extrapolate mining strategies that are more performant when compared to other strategies (traditional honest mining and selfish mining).

Traditional reinforcement learning algorithms devise methods by which agents can maximise the obtainment of rewards in an environment. But the blockchain network is a dynamic environment in which a representative model can’t be easily created. The paper's authors devised a multidimensional RL algorithm that uses Q Learning (model-free algorithm) to optimise cryptocurrency mining.

The authors proved that through machine learning techniques, the development of performant mining strategies could be solved. It’s no secret that bitcoin and cryptocurrency mining is a booming industry. Several mining companies such as Argo Blockchain, Riot Blockchain and Hive Blockchain have reportedly mined several millions worth of Bitcoins. These same companies could have ML Engineers amongst their tech teams.


Researchers have created reinforcement learning systems that provide optimisation on cryptocurrency mining strategies.

3. Tackling Cryptojacking (Deep Learning)

Photo by imgix on Unsplash

Another notable utilisation of machine learning within cryptocurrency mining has to do with security. Research labs backed by academic institutions and national governments are equipped with considerable computing resources and infrastructure. This makes them prime targets for ‘cryptojackers’.

Cryptojackers hijack computational resources to mine cryptocurrencies. Such attacks have become common and made headlines.

Researchers from the USA have combined efforts to devise a method of detecting the presence of malicious programs that intend to hijack compute resource.

SiCaGCN is the name given to the system created by the researchers. SiCaGCN determines the similarities between a pair of programs or code based on distance measurements conducted on a control-flow graph representation of the programs.

The SiCaGCN system comprises components of neural network architectures and techniques found in the Deep Learning and ML domain.

  • Control Flow Graphs: A representation of the flow of instruction execution within a code/program, where each node represents a basic block. Directed edges correspond to jumps or change of flow in code execution.
  • Graph Convolutional Neural Networks: Neural network architecture designed to conduct convolutions operations on graphs.
  • Attention Mechanism: A technique devised to highlight or enhance important dependencies between inputs/outputs or inputs.
  • Neural Tensor Network, Capsule Networks, Distance Measurements (Graph Edit Distance and Maximum Common Subgraph (MCS))

This article doesn’t aim to present a detailed analysis of SiCaGCN, but below is a quick step by step overview of the high-level operations of the system:

  1. Convert code/program into Control Flow Graph (CFG) of basic blocks representation.
  2. Pass the CFG of basic blocks as input to the SiCaGCN model through a Graph Convolutional neural network to create an embedding of the CFG of basic blocks.
  3. Attention Mechanism (NLP) and Capsule Network are leveraged to extract important and relevant features from the input graphs, as a result of this creating better embeddings.
  4. Use efficient distance measurements (Graph Edit Distance, GED) and Maximum Common Subgraph (MCS)) to determine similarity score between graph embeddings.
  5. An instance of training data consists of a pair of CFG of basic blocks and their ground truth similarity score. During testings, the input to the model is a pair CFG of basic blocks derived from code pairs, and the output is a similarity score.
SiCaGCN Architecture. Image from original research paper

The exciting aspect of the research is the real-world application of the SiCaGCN system. The researchers tested the system's capabilities to detect bitcoin mining code in a collection of scientific source code. SiCaGCN performed well when compared against another graph similarity computation system (SimGNN). It is not far-fetched to assume SiCaGCN could be modified to operate into a broader anti-virus system.


Researchers have devised a unique and efficient method of detecting malicious code using deep learning techniques to characterise and compare code. The system is named SiCaGCN and provides promising results when tested on its ability to detect foreign bitcoin mining code. The system prevents the abusive and unauthorised usage of computing resources by foreign programs.


Machine Learning has a place in the world of blockchains and cryptocurrencies. ML techniques applicability spans further than cryptocurrency price forecasting or trading.

As more of these techniques make their way to production environments and get commercialised, the world of blockchain could start opening up to Machine Learning practitioners in the coming years.

Thanks for reading

To connect with me or find more content similar to this article, do the following:

  1. Subscribe to my Email list for more content
  2. Follow me on Medium
  3. Connect on LinkedIn and Twitter

Creating A Data Science And Machine Learning Portfolio With Notion

Machine Learning In The World Of Blockchain and Cryptocurrency was originally published in Towards Data Science on Medium, where people are continuing the conversation by highlighting and responding to this story.