Urgent.News

What's breaking now, across thousands of outlets.

Tech

Yul Dark Arts: Understanding the EVM from first principles

In this article, I want to walk you through my experience learning Yul to better understand how the EVM manages memory and how you can use this to your advantage, whether it is for learning more about the EVM or for trying to squeeze extra performance from a smart contract. What is Yul? Yul is a type-ish, low-level intermediate representation where EVM opcodes are represented as simple function…

Yul is a low-level intermediate representation for the EVM, which gives developers more control over memory management. It is highly flexible and interoperable with Solidity, making it faster for those who know how to use it effectively. However, it is not a fully-fledged programming language and requires developers to manually manage data types, storage, memory, events, and ABI encoding.

To use Yul, you typically write it inside an assembly block within a Solidity smart contract. While Yul can provide benefits in understanding the EVM and potentially improving performance, it also adds a significant mental overhead due to the need for manual memory management. It is generally recommended to stick to Solidity or Vyper for most smart contract development, reserving Yul for specific performance optimizations.

In Yul, you must think in terms of slots rather than variables, as everything in contract storage is represented as a key-value pair in a 32-byte word. Two main opcodes are used for reading and writing: sload and sstore. When reading a single key, you simply use the sload opcode with the appropriate storage slot. Writing is done similarly using the sstore opcode.

For mappings, a slot seed is used as a base, combined with the key to determine the actual slot where the mapping value is stored. This requires calculating the hash using keccak256, taking into account the address padding and seed placement within the memory word. Once the slot is determined, you can read or write the value using sload and sstore as usual.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

What Actually Breaks During a "Zero-Downtime" Cloud Migration

Every cloud migration plan I've seen starts with the same promise: zero downtime. And most of them get pretty close — right up until the one dependency nobody mapped out decides to fall over at 2 a.m.

  • DNS settings often overlooked during migration
  • Stateful services present significant challenges
  • CI/CD pipelines require thorough planning

I checked dozens of UK local business websites by hand. Here's what actually breaks, and the tool I built to do it for me

I'm Alex, 19, Ipswich. For the last month I've been doing something tedious: taking a UK town and a trade - "hairdressers, Wakefield", "accountants, Bristol" - opening every business's own website…

  • Alex, 19, manually checked UK business websites for issues
  • Common problems: domain not resolving, outdated directory listings, missing email addresses
  • LeadDrive tool collects contact info, timestamps checks for verification

Where Need Meets Nothing: finding Florida's aid deserts with Snowflake

This is a submission for Weekend Challenge: Generosity Edition What I Built Generosity has a targeting problem. Money follows attention, attention follows disasters, and disasters get covered where…

  • "Where Need Meets Nothing" tool highlights Florida counties lacking aid
  • Project uses FEMA, Census, and NPPES data from Snowflake's Public Data Marketplace
  • Nine Florida counties identified with highest need-to-resource disparity

More from Sunday 6 September →