May 11, 2019 Editor's Desk

Debugging a smart contract in the blockchain is different from debugging a traditional application build on C++ or JavaScript as you are not running code in real time, but on blockchain, previous transaction execution is mapped with the associated code to debug a transaction.

For this first, we need to understand what is a smart contract. It is a piece of code run on the top of a blockchain, these smart contracts need to make sense in a precise manner, debugging a Smart contract is analyzing a transaction step by step how functions internally work and proceed or where the actual transaction has failed.

Types of error that occur in the solidity programming language that is used to write smart contracts on the ethereum blockchain.

1. Syntax Error

A syntax error occurs when there is a problem found in the syntax of smartcontract code. When your code has a syntax error your smart contract will not compile or get deployed on the blockchain.

In Remix environment syntax errors can easily be diagnosed, as you can see in the picture below, line 11 is missing a semi-colon, this error is highlighted on line 12 using a red cross symbol which also shows what the error actually was.


Syntax error can be easily diagnosed using truffle, remix or any Integrated Development Environment (IDE).

2. Run time Error

Run time errors arise only when you have created and deployed a smart contract to the ethereum blockchain and your solidity code has been compiled to bytecode that has been understood by EVM (Ethereum virtual machine).EVM​ is a component of Ethereum blockchain that runs solidity code and run time error arises when EVM finds out that the user might have entered the wrong input to get a particular output.

Run time errors are a bit difficult to diagnose by the compiler than syntax error because these errors are not identified before deploying on the blockchain, they can only occur when state change takes place in the smart contract.

3. Logic Errors

IDE’s or any other tools are not capable of debugging logic errors, because logic errors are not recognized by EVM, according to EVM everything is perfect and code can be run easily. Logic errors occur when the developer makes a mistake and opens up loopholes in a smart contract due to which expected output would not get generated or these loopholes may attract hackers.

Types of Run time errorOut of Gas

It occurs when the amount of gas available is less than the required amount of gas to carry on the transaction. Gas is nothing but small fractions of ether which get used up upon occurrence of any transaction.


Transaction revert will occur when you are trying to execute a transaction that cannot be executed according to the logic of smart contract hence EVM will return an error and transaction is reverted.

Invalid opcode

When we try to call a code that does not exist then invalid opcode error occurs.

invalid Jump

This error occurs when one tries to call an invalid function.

Stack Overflow

When recursive calling of a function occurs more than 1024 times then stack overflow occurs. In Solidity, a function cannot be called more than 1024 times.

Stack Underflow

It occurs when we try to call a variable that does not exists.

Related posts

Add a comment

Like what you're reading?

Get the latest and insightful blockchain stories on your inbox.