Solidity Interview Questions

Solidity Interview questions for developers

As the popularity of blockchain technologies and the world of cryptocurrencies has skyrocketed in recent years, the demand for IT professionals and programmers to develop all kinds of blockchain and crypto-applications has increased. This is where the need for a blockchain developer increases, as this job requires smart-contract writing as an essential part of ensuring obligations between parties in the blockchain industry.

Blockchain Developer Job Demand

Let’s consider the example of ICO popularity. Their history doesn’t go back further than 2013 — that is when the first ICO by Mastercoin was conducted. After just three years, in 2016, 54 major ICOs managed to raise approximately $103 million, and a year later, this number grew to $1.25 billion!

ICO progress in the recent yearsSource: btxchange.io

The major projects of 2017 included 92 ICOs, and there was an even larger number of those less popular. Check out the best ICOs: which projects are most effective in funding.  The demand for blockchain developers is obvious: each project needs to produce safe, secure, hack-resistant code to run on the blockchain platform, thus, each ICO had to hire several smart-contract and blockchain developers.

In addition, blockchain developer jobs are very much valued, as it is not that easy to find a competent professional. This is explained by the fact that this position is among the hardest to fill.

Blockchain developer jobs were the second most in demand in 2017. The following graph shows blockchain job postings in recent years:

Blockchain job postings

Blockchain Developer Description: Skills and Qualities the Candidate Must Have

Every project or company wants to hire an experienced and intelligent blockchain developer. But how to recognize him or her? It is important to stress that although programming knowledge is crucial and a degree in blockchain development is appreciated, other aspects, such as personal qualities, are no less important. Blockchain developer work requires the ability to cooperate, consult, and communicate with co-workers, to be responsible and take the initiative. Let’s outline the main skills and qualities a developer should possess:

  • strong knowledge of IT, programming languages, and SC development
  • the ability to write code individually and deal with possible problems
  • the ability to cooperate with others and work in a team
  • the ability to be self-critical, see one’s own mistakes, and offer solutions
  • the ability to give reasons and explain why certain problems or constraints appear in coding, and deal with them
  • an outgoing personality, easy to work with
  • responsibility, productivity, and honesty

It is also important to note that seeing the candidate in the process of work reveals certain details about him or her. Thus, during an interview (test task), an employer can see how a candidate manages his or her time, finds solutions to problems, deals with difficulties, etc.

In addition to skills and qualities, it should be noted that a blockchain developer resume is another significant aspect to consider. The resume should outline full information about the candidate’s education, work experience, program knowledge, and personal qualities, as well. It should be well-structured and intelligently written, as it will make the first impression about the candidate.

Common Mistakes During an Interview

First, it is worth noting that all people make mistakes. Some of them can even turn out to be beneficial if a candidate notices his or her mistakes and finds a solution right away. Other mistakes can be crucial, and lead to failure.

According to the computer science portal GeeksforGeeks, the most common mistakes made by developer candidates include:

  • poor preparation
  • bad communication skills
  • taking time to think instead of talking the process through
  • making coding mistakes on the whiteboard
  • not being enthusiastic

These are facts! Of course, a smart developer knows what he or she is doing. S/he probably knows how to code well and does a great job, but things can go wrong during an interview.

Poor preparation doesn’t mean that a person isn’t competent in the subject; it means he or she did not take time to revise the material and be ready to give quick and reasonable answers. Bad communication can be another mistake that is easy to avoid. The interviewer wants to communicate with the candidate — to hear his or her thoughts and analyze the candidate’s way of thinking. This is why it is important to be outgoing and responsive. It’s better not to take several minutes to come up with a ready answer, but to guide the interviewer through the thinking process. Being enthusiastic is important, too. If you want to get the job, you shouldn’t hesitate to show it.

Lastly, but most importantly: coding mistakes. Of course, not all interviewers request a coding sample on the whiteboard. Some companies do; others provide a computer. It’s not a secret that developers use various programs, editors, and compilers during their work. And even if the candidate is proficient at what he or she is doing, coding mistakes are very common when it comes to writing on the whiteboard. Here are some to consider avoiding:

  • pseudo, incomplete, or redundant code
  • wrong choice of code name or style
  • input data isn’t validated
  • handwriting is messy and hard to read

Blockchain Developer Description of Task Types During an Interview

It is hard to give an exact example of a blockchain development test task. Each company and employer is unique, and each company works in a different industry and performs a variety of tasks/services/functions.

In general, a developer interview can take up to an hour, 15 minutes of which are dedicated to getting acquainted and general questions and answers. Hence, time dedicated to code-writing can take approximately 45 minutes. It should be remembered, though, that the candidate shouldn’t work quietly all the time — it is in his or her best interests to interact with the interviewer, giving reasonable explanations of the process and chosen actions.

In this section, we would like to point out the importance of general questions during an interview. Even if some of them are basic, it is important to remember all answers and define ideas simply, giving several examples. This part of the interview shows the candidate’s general knowledge, plus their awareness of the latest techniques/programs/methods of work. In addition, it shows communicative and interactive skills.

Here are some examples of questions during an interview, along with possible answers:

1. How did you get into smart contract (SC) development?

With the extreme hype around blockchain technologies, the demand for smart-contract and blockchain developers is rising. With knowledge and experience in IT technologies and computer language coding, it is possible to learn the Solidity programming language for smart-contract development in a pretty short amount of time. In addition, from a technical point of view, blockchain developer requirements aren’t more complicated or challenging than other coding languages. Of course, this isn’t an easy task, but considering the major blockchain benefits and interest in innovation, I decided to commit myself to learning SС development.

2. Can you describe the main steps of SC development?

When all the requirements are clearly set, like ERC standards and patterns, coding can be started. First of all, one should choose the language (Solidity being the most popular).

The next step is to write or reuse the contract in some of the IDE. It is good practice to use a framework (Truffle) as a development environment.

Testing is one of the most important steps in SC development. There are several types of testing: functional, integration, manual. Also, there are some packages that help check code style, small security issues, and test coverage (Solhint, Solium, Solidity coverage).

The contract can be deployed to the Ethereum main network when all of these steps have been finished.

3. What is blockchain?

Blockchain is a digital ledger that consists of a system of blocks with cryptographically encrypted records of various transactions. Because it is decentralized, blockchain provides security, permanence, transparency, and immutability.

As all information is recorded and stored in blocks, each of these blocks contains certain data on transactions. Additionally, the block contains references to the previous one in chain, records on the reward system as well as unique answers to mathematical problems. This is essential to the mining process. This type of scheme is referred to as a “block structure,” and because it stores all types of important information, this structure can vary. Here is one of the block structure examples:

An example of a block structure

4. What is the blockchain consensus algo?

Consensus algorithms are processes in computing that reach agreements on single-data value in blockchain processes. The algorithms are meant to provide network reliability involving numerous unreliable nodes for double-spending prevention.

There are different types of algorithms, like PoW, PoS, DPoS, PoA, PoWeight, BFT or DAGs. Here are some examples and their characteristics:

Types of Consensus Algorithms

CharacteristicsPoWPoSDPosPBFTRAFT
Byzantine Fault Tolerance50%50%50%33%N/A
Crash Fault Tolerance50%50%50%33%50%
Verification Speed>100s<100s<100s<10s<10s
Throughput (TPS)<100<1000<1000<2000>10k
Scalibilitystrongstrongstrongweakweak

5. How is Ethereum blockchain different from Bitcoin blockchain?

Blockchain-based Ethereum is a public software platform that enables application deployment independently of central authorities. Ethereum allows you to work for Ether, not just mine a cryptocurrency (as is done in Bitcoin). The Bitcoin blockchain was initially designed to store and conduct transactions only in Bitcoin form. A distinctive feature of Ethereum is the ability to run any application code in a decentralized manner, while Bitcoin, for instance, offers the use of just one application in particular.

Therefore, the Ethereum blockchain not only transacts payments, but also provides smart-contract execution and runs decentralized applications. Providing a wider range of opportunities, Ethereum is often used as a software platform for different startups.

6. What is Wei, and how does it differ from Ether?

Wei is considered to be an Ether unit or the lowest denomination of Ether, like pennies to pounds or cents to dollars, for instance. Here is the chart of unit values:

Ethereum unit value

7. What is a smart contract?

A smart contract (crypto-contract) is a program with a set of codes used to directly control cryptocurrency transfers and assets between parties dependent upon certain conditions. A blockchain user creates the code and later executes it by blockchain node. The contract executes itself only if the conditions are met. SC can be created on platforms like Ethereum, NXT, and Chain, with automated transactions and script in Bitcoin. Find out how to create smart contracts quickly and easily.

8. What languages can smart contracts be written in?

There are different smart-contract languages (SCL) a contract can be written in. Let’s divide the languages into three main categories: Bitcoin, Ethereum and DSLs:

Smart-Contract Languages

BitcoinEthereumDSLs
Bitcoin ScriptEthereum bytecode
Findel
IvySolidityChorus
SimplicitySolidityXADICO
BitMLLLL
Vyper
Bamboo
functional-solidity-language
e-WASM
Serpent
Mutan
Idris
JULIA
Babbage
Pyramid
L4

9. What is Web3.js?

Web3 for Javascript is a collection of libraries that allow interaction with local/remote nodes on the Ethereum blockchain where HTTP/IPC connection can be used.

These libraries provide Web3 objects that allow applications to run on Ethereum and conduct blockchain interactions. Web3 provides a large number of functions to keep track of block data, see transaction number/balance, and additional features. Read insights on Solidity #3 meetup to find out more about the peculiarities of Web3.js functions.

10. Give some details on the Truffle development environment: framework, structure, and migrations.

Truffle is a framework used for SC development in Ethereum. It was built to provide maximum speed, and includes smart optimization for best results. Its structure has the following features:

Truffle features

truffle features

Migrations, an essential part in SC deployment, are JS files responsible for task staging. During project evolvement, migration scripts are created and recorded through a special contract on-chain to ensure further blockchain evolution.

11. What is EVM?

EVM (Ethereum Virtual Machine) is a decentralized application platform that executes smart contracts, provides security, and prevents attacks like denial-of-service. It is maintained and run by many network-connected nodes. All network nodes run EVM and execute some instructions. Additionally, EVM establishes communication without interference, and eliminates program access to each other’s status.

12. How do gas limit and gas price influence the mining of transactions?

As Ethereum transactions run on gas instead of Ethers, the execution of certain commands and transactions costs gas. This type of execution is presented by the amount of gas you send (gas price) and a total block gas limit. The gas limit is modified by the user who sends the transaction; it is the amount of gas sent along. The gas price is the actual transaction cost, which combines the cost of the transaction and the cost of execution. The transaction price equals gas used multiplied by gas price.

The gas limit of a transaction can put the time of mining into a block. Transactions with high gas limits can be less prioritized and take more time to get into the block.

13. What are the existing access modifiers, and how are they different?

There are a number of Solidity function modifiers that are used to change the behaviour of various functions. They can check function conditions automatically, before the execution. Access modifiers are contract inheritable properties. Functions can be divided into:

  • external
  • private
  • public
  • internal

These functions differ one from another according to call method, either externally, from other contracts, or publicly, via messages. They may provide only internal, private access.

14. What is a fallback method?

It is a process of triggering fallback functions when the function signature does not match any other function specified in the identifier, or if specific data isn’t supplied. Functions can also be executed when plain Ether is received (without any data provided).

15. What are the Ethereum network types? What are the differences between them?

As of today, most Ethereum projects are run on the Ethereum public blockchain, which provides access to a number of participants, nodes, currencies, and markets. Depending on permitted access, there are three main types of Ethereum network: public, private, and consortium blockchains.

Ethereum Network Types

 Public BlockchainPrivate BlockchainFederated/Consortium Blockchain
AccessAnyoneSingle organizationMultiple selected organizations
Participants- Permissionless
- Anonymous
- Permissioned
- Known identities
- Permissioned
- Known identities
Security- Consensus mechanism
- Proof of Work / Proof of Stake
- Pre-approved participants
- Voting/multi-party consensus
- Pre-approved participants
- Voting/multi-party consensus
Transaction Speed- Slow- Lighter and faster- Lighter and faster

16. How are libraries different from contracts?

Though libraries and contracts are somewhat similar, libraries can be deployed once at a particular address. Thus, the library code can be reused via the DELEGATECALL EVM feature. When one calls library functions, the code executes itself in the contract. Visually, library call functions are the same as base-contract call functions, but libraries won’t be visible in the hierarchy of inheritance. Compared to contracts, library restrictions include: no state variables, the inability to inherit or be inherited, and the inability to receive the Ether.

17. Please describe specific contract interaction features: DELEGATECALL, STATICCALL, library differences, use cases, and gas costs.

DELEGATECALL allows the user (delegates the right) to perform various actions with storage. It is a security risk that provides trust in the sending and receiving of contracts, and ensures the storage safety.

STATICCALL is a new opcode used to increase security in smart contracts. It can also call another contract, but disables any modifications or state changes during the call.

Libraries act as key players. They don’t have a storage option, and don’t hold an Ether. That is why libraries have to undergo an audit before being put into production (with DELEGATECALL, for instance).

Library types include the following:

  • static
  • dynamic
  • shared
  • remote

A library is defined as static when its code can be accessed during the invoking program process. A dynamic library is distinctive, as it can be loaded at run time and linked by a dynamic linker when the program is prepared for execution. A shared library (object) is a file that is possible to share by further executable/shared files. Remote libraries are used to separate executables over the web to another computer.

Below is an example of library use:

how to use libraries

Gas cost depends upon the number of instructions, their type, and the amount of storage.

18. What is the Ecrecover function? Provide an example, please.

Ecrecover recovers public key addresses from an elliptic curved signature, and returns zero errors.
Here is an example of a function:

Ecrecover code example

19. Talk about storage vs memory.

Storage and memory are keywords used in coding to store or save certain types of data, like arrays or structs. They are two of three areas where EVM stores items.

Storage resides in contract-state variables. Each of these contracts has an individual storage that is persistent, but a bit expensive to use. Storage can map up to 256-bit words within itself, but can’t read or write to any other storage.

Memory, on the other hand, holds temporary items and can be erased between function calls. It is linear, and has the ability to address at the byte level, also limited to 256 bit-width. In addition, memory is more expensive, depending upon expansion size and quadratic scalability.

20. What is the ERC20 interface?

ERC20 is a token standard that describes different functions and events that must be implemented in an Ethereum token contract. In order to meet ERC20 standards, an interface contract declares a set of necessary functions and events. Here is an interface example:

ERC20 standard interface

21. What is the ERC721 interface?

ERC721 is an open, free standard describing how to build tokens on Ethereum. Its main distinctive feature is that all ERC721 tokens are unique. An interface has to allow these tokens to be managed/owned/traded. Here is an interface example:

ERC721 interface1ERC721 interface2ERC721 interface3ERC721 interface4

22. What are the most common SC vulnerabilities?

Given that smart contracts are immutable, it is extremely important to deploy intelligent code without any pitfalls. It has to be secure and resistant to possible attacks. This is why the developer has to evaluate the principal risks and vulnerabilities that are likely to occur. Among the major ones:

Smart-Contract Risks and Vulnerabilities

VulnerabilitiesTo avoid hacks, it is crucial to:
private information and randomnesstreat warnings seriously
re-entrancyrestrict the storage amount of Ether in an SC
gas limit and loopskeep contracts small and modular
sending and receiving Etheruse the checks-effects-interactions pattern
callstack depthinclude a fail-safe mode
tx.originuse formal verification

The blockchain developer role is very important in any project development. In order to get this job, one should carefully prepare: revise the material, write a well-structured and comprehensive resume, and increase communication and job-oriented skills.

If you are interested to find out more about ICOs, smart contracts, and blockchain news, visit the Applicature blog. If you have any questions, the team would be more than happy to help you out!

No Comments

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)
Loading...
Post A Comment