Introduction


Topics Covered:

Intro and…what are we doing here?

Why learn assembly? At first glance, it seems a strange idea that we would require really low-level programming when writing smart contracts.

Saying that, if you’ve been reading/writing smart contracts for any length of time you’ll very quickly run into assembly blocks that seem like black magic. Sometimes you’re trying to do specific operations in solidity and realise the ONLY way to do a particular thing is to reach for predefined assembly block.

If we contrast this to many other languages, jumping to a lower level language is a relatively rare occurence. Jumping to assembly even more so. But when programming smart contracts, having a strong grasp on assembly gives us access to a couple of “super powers”:

  1. As mentioned, there are certain operations on the EVM that are only possible in assembly.
  2. Operating at the low level can unlock some truly amazing gas savings.
  3. Understanding assembly forces you to very deeply understand the implications of the solidity code you’re writing, and will make you better apprecite exactly what is going on in your code in ways that will help you reason about security and efficiency, versus just engaging at the higher level.

I don’t think you need to be reaching for assembly often. I’d actually advise AGAINST using assembly except as a last resort. But I think having a curiosity about the tools and languages we are working with is an essential skill and going deep into the weeds really helps us cultivate that skill.

Why hacking?

Great question.

First, it sounds cool 😎

Second, it’s a way we can learn by doing.

I’ve seen some really excellent articles on assembly (such as from Jean Cvllr or Noxx) but I, personally, learn best with theory and practice.

We’re going to be working with actual contracts with a clear criteria to aim for with each hack, which will allow us to explore different assembly concepts bit-by-bit.

Along the way, by being hands-on, we will be confronting that embarrassing feeling of realising that, maybe we didn’t understand some of those articles quite as well as we thought.

And that’s okay. We will go back, revist and apply our knowledge, and we will come out with a much stronger understanding of what we’re doing versus having not put what we learned into practice.

Thirdly, hacking forces us to think in an adversarial manner - a super important frame of mind to keep ourselves in while writing secure contracts.

Finally, and most importantly, solving the challenges is fun. It’s rewarding.

I like doing fun and rewarding things. I hope you do to.

Next

Top