Exercise: Arrays

Practice using arrays and control structures in Solidity.

We’ve learned a few essential topics in the last few lessons, and now it's time to practice our new skills. To do this, we'll write a small smart contract using arrays and control structures.


The smart contract we'll write will allow storing an array of hashes in a smart contract state. It'll allow us to add a hash to an array, check if a particular hash value already exists, and remove it.

While this particular smart contract is primarily to test our Solidity development skills, the overall idea is useful for what is called proof-of-existence. If we want to record that we had a particular file (e.g., describing an invention) at a certain time, we can add a hash of this document to a blockchain. Since blocks in a blockchain contain timestamps, and since we can’t remove old blocks, this could prove that we had a specific file at a particular date.

To start working on the exercise, go to the Remix IDE, create a new project, and add this starter code to a new file.

Get hands-on with 1200+ tech skills courses.