<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by derastephh on Medium]]></title>
        <description><![CDATA[Stories by derastephh on Medium]]></description>
        <link>https://medium.com/@stephennwebor?source=rss-7df2dad36683------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lPjGp3m6TxeugzhWjNz_Lg.jpeg</url>
            <title>Stories by derastephh on Medium</title>
            <link>https://medium.com/@stephennwebor?source=rss-7df2dad36683------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:34:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stephennwebor/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What’s Inside A Transaction Data?]]></title>
            <link>https://medium.com/@stephennwebor/whats-inside-a-transaction-data-3cef3de0dec7?source=rss-7df2dad36683------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cef3de0dec7</guid>
            <dc:creator><![CDATA[derastephh]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 07:12:42 GMT</pubDate>
            <atom:updated>2026-07-24T07:12:42.581Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last article, we discovered that every transaction starts with four bytes called the function selector. Those four bytes tell the contract which function to execute.</p><p>But here’s another question. When we call this function;</p><pre>vault.deposit(100);</pre><p>where does the 100 go? The selector only tells the contract <strong>what</strong> to execute. It doesn’t tell the contract <strong>which values</strong> to use. So where are they?</p><h3>Let’s Look Inside the Transaction</h3><p>Imagine you send this transaction;</p><pre>vault.deposit(100);</pre><p>What reaches the blockchain looks more like this;</p><pre>0xb6b55f250000000000000000000000000000000000000000000000000000000000000064</pre><p>At first glance, it looks intimidating. But don’t worry. There are only two parts.</p><pre>Function Selector<br><br>↓<br><br>Function Arguments</pre><p>That’s it. Everything after the first four bytes is simply the information your function needs.</p><h3>Think of It Like Filling Out a Form</h3><p>Imagine you’re filling out an application form. At the top, you choose the type of application. That is like the function selector. The rest of the form is where you write your information. Name, age, address, phone number, etc are all the function arguments.</p><p>A smart contract works the same way. The selector says;</p><blockquote>Execute deposit().</blockquote><p>The remaining bytes say;</p><blockquote>Use the value 100.</blockquote><h3>What Happens If There Are Two Parameters?</h3><p>Suppose we have this function;</p><pre>function transfer(address to, uint256 amount) external {}</pre><p>Now we call it;</p><pre>token.transfer(alice, 100);</pre><p>The transaction still starts with the selector. After that comes the address, then the amount. Conceptually, it looks like this;</p><pre>Function Selector<br><br>↓<br><br>Alice&#39;s Address<br><br>↓<br><br>100</pre><p>Notice something? The order actually matters. If the contract expected;</p><pre>(address,uint256)</pre><p>but received;</p><pre>100<br><br>↓<br><br>Alice</pre><p>everything would be interpreted incorrectly. The contract doesn’t know which value is which. It simply reads them in the order they were written.</p><h3>Why Doesn’t Solidity Just Send “100”?</h3><p>Here’s another question. Why doesn’t the transaction simply contain 100 instead of sixty four hexadecimal characters? Because the EVM doesn’t understand decimal numbers. Everything inside a transaction is represented as bytes. Even simple values like 100 must be converted into bytes before being sent. The same happens for addresses, booleans, strings, arrays, etc.</p><p>Everything eventually becomes bytes.</p><h3>This Is Why Calldata Exists</h3><p>The bytes sent with a transaction are called <strong>calldata</strong>. Think of calldata as the package the contract receives. Inside that package are two things.</p><pre>Which function should run?<br><br>↓<br><br>What values should it use?</pre><p>The contract reads both before your solidity code begins executing.</p><h3>What’s Next?</h3><p>We’ve seen what transaction data looks like. Now it’s time to answer a bigger question. How does solidity take something as simple as;</p><pre>token.transfer(alice, 100);</pre><p>and turn it into the exact bytes stored inside calldata?</p><p>In the next article, we’ll break down ABI encoding one step at a time. No magic, no memorization, just the process solidity follows before every function call.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cef3de0dec7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Does the EVM Know Which Function You Called?]]></title>
            <link>https://medium.com/@stephennwebor/how-does-the-evm-know-which-function-you-called-9128f3badbb5?source=rss-7df2dad36683------2</link>
            <guid isPermaLink="false">https://medium.com/p/9128f3badbb5</guid>
            <dc:creator><![CDATA[derastephh]]></dc:creator>
            <pubDate>Thu, 09 Jul 2026 11:21:55 GMT</pubDate>
            <atom:updated>2026-07-09T11:21:55.481Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last article, we followed a transaction from a wallet to a smart contract. We stopped just before one important step. The contract somehow knew it should execute deposit() instead of withdraw().</p><p>But how? After all, the EVM doesn’t understand function names.So what exactly does your transaction send? Let’s find out.</p><h3>A Function Name Never Reaches the Blockchain</h3><p>Suppose you write this function.</p><pre>function deposit(uint256 amount) external {}</pre><p>When you call it like this:</p><pre>vault.deposit(100);</pre><p>you might imagine the transaction contains something like:</p><pre>deposit(100)</pre><p>It doesn’t. The words deposit and amount never reach the blockchain. Before the transaction is sent, solidity converts your function call into bytes. That’s all the EVM understands.</p><h3>Think of It Like a Delivery Package</h3><p>Imagine you’re sending a package. The person delivering it doesn’t care what you wrote inside. They only look at the address on the front. Smart contracts work in a similar way.</p><p>The transaction contains a small piece of data at the beginning that tells the contract exactly where the execution should go. That small piece of data is called the <strong>function selector</strong>. You can think of it as the address written on the package.</p><h3>So What Is a Function Selector?</h3><p>The selector is simply:</p><pre>first 4 bytes of<br><br>keccak256(function signature)</pre><p>So:</p><pre>deposit(uint256) -&gt; keccak256(...) -&gt; 0xb6b55f25...</pre><p>Take the first four bytes.</p><pre>0xb6b55f25</pre><p>Done. That’s the selector.</p><p>You don’t have to calculate this yourself. Most developers never calculate selectors manually. You can do this online <a href="https://emn178.github.io/online-tools/keccak_256.html"><em>here</em></a>, or by using the foundry cast tool.</p><h3>Where Does the Selector Come From?</h3><p>Solidity takes the function signature. A function signature is simply:</p><pre>functionName(parameterTypes)</pre><p>So for example:</p><pre>deposit(uint256)</pre><p>It then hashes it using Keccak256. The hash is much longer than we need.</p><pre>0xb6b55f25...</pre><p>The EVM keeps only the <strong>first four bytes</strong>. Those four bytes become the function selector. That’s what gets placed at the beginning of every transaction.</p><p>You don’t need to memorize how the hash is produced. Just remember this. Every function call starts with four bytes that tell the contract which function to execute.</p><h3>What Does the Transaction Actually Look Like?</h3><p>Let’s call</p><pre>vault.deposit(100);</pre><pre>0xb6b55f25<br>0000000000000000000000000000000000000000000000000000000000000064</pre><p>The first four bytes are the selector. Everything after that is the function’s arguments. So when the contract starts executing, the first thing it reads is:</p><blockquote>Which function is this trying to call?</blockquote><p>Once it recognizes the selector, it jumps to the correct function. The remaining bytes become the function inputs. We’ll look at those in the next article.</p><h3>What’s Next?</h3><p>We’ve identified the first four bytes of a transaction. But what about everything after them? How does the number 100 become a long string of hexadecimal bytes?</p><p>In the next article, we’ll unpack transaction calldata and learn how Solidity packages function arguments so the EVM can understand them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9128f3badbb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Really Happens When You Call a Smart Contract?]]></title>
            <link>https://coinsbench.com/what-really-happens-when-you-call-a-smart-contract-d1329983e9c5?source=rss-7df2dad36683------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1329983e9c5</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contract-security]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[derastephh]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 15:10:34 GMT</pubDate>
            <atom:updated>2026-07-08T08:20:45.369Z</atom:updated>
            <content:encoded><![CDATA[<p>You’ve probably written something like this before.</p><pre>vault.deposit(100e18);</pre><p>Or maybe this:</p><pre>token.transfer(alice, 100);</pre><p>It looks simple. You call a function, it runs, and your transaction succeeds. But have you ever stopped to ask what actually happens between writing that line of code and the function being executed? We’ll find out what happens.</p><p>By the end of this article, you’ll know the journey your transaction takes before a single line inside your function runs.</p><h3>Let’s Follow One Transaction</h3><p>Imagine Alice wants to deposit 100 tokens into a vault. She signs a transaction in her wallet and clicks <strong>confirm</strong>. At this point, nothing inside the smart contract has executed yet. The transaction is simply a request. It contains information like:</p><blockquote>Which contract should receive the transaction?</blockquote><blockquote>Which function should be called?</blockquote><blockquote>What data should be passed to that function?</blockquote><blockquote>How much gas is available?</blockquote><p>Once the transaction is included in a block, the EVM begins its job.</p><h3>The EVM Doesn’t Read Solidity</h3><p>This surprises a lot of beginners. The EVM has never seen your solidity code. It doesn’t know what deposit() means. It doesn’t know what variables are. It doesn’t even know what a function is.</p><p>Before your contract was deployed, solidity compiled it into <strong>bytecode</strong>, which is the language the EVM understands. So when your transaction reaches the blockchain, the EVM only sees bytecode. Everything else has already been translated.</p><p>Think of it like this. You might write a book in English. Someone else translates it into Japanese. A Japanese reader never sees the English version (he obviously can’t read it😅). The EVM is the same. It only reads the translated version.</p><h3>How Does the Contract Know Which Function You Want?</h3><p>Now we have another question. Imagine a contract with three functions.</p><pre>function deposit(uint256 amount) external {}<br><br>function withdraw(uint256 amount) external {}<br><br>function claimRewards() external {}</pre><p>When your transaction reaches the contract, how does it know which one to run? After all, the EVM doesn’t understand function names. It needs another way to identify them.</p><p>This is where <strong>function selectors</strong> come in. Every function has its own unique identifier. When you call deposit(100), the transaction doesn&#39;t actually say:</p><blockquote>call deposit().</blockquote><p>Instead, it carries the function’s selector. In the next article, we’ll see how solidity creates these selectors and why they are only four bytes long. For now, just remember that the selector tells the contract which function you intended to call.</p><h3>The Contract Doesn’t Start at Your Function</h3><p>This is something many people don’t know. When a transaction reaches a contract, the EVM doesn’t immediately jump into deposit(). Instead, execution begins at the start of the contract’s runtime bytecode.</p><p>You can think of it as walking into a hotel. You don’t appear inside your room. You first enter the reception and then the receptionist directs you to the correct room.</p><p>A smart contract works in a similar way. The beginning of the contract checks the function selector. Once it finds a match, execution jumps to the correct function. So the journey looks like this:</p><pre>Transaction sent<br><br>↓<br><br>Contract bytecode starts running<br><br>↓<br><br>Function selector is checked<br><br>↓<br><br>Correct function is found<br><br>↓<br><br>Your function begins executing</pre><p>Notice something important. Your solidity code hasn’t run until the selector has been matched.</p><h3>Why Does This Matter?</h3><p>At first, this might seem like an too much detail. But understanding this flow makes many security concepts much easier to understand later.</p><blockquote>For example:<br>Why can two functions have the same selector?<br>How do selector collisions happen?<br>Why does delegatecall still know which function to execute?<br>Why do proxies work?</blockquote><p>All of those questions start with understanding that contracts don’t execute functions by name. They execute them using selectors hidden inside the transaction.</p><p>We’ll explore that next.</p><h3>What’s Next?</h3><p>We’ve followed a transaction all the way to the contract. But we skipped one important detail. How does deposit(100) become something the EVM can actually understand?</p><p>In the next article, we’ll break open a transaction and see how solidity turns a simple function call into raw bytes that tell the EVM exactly what to execute.</p><p><em>*This article kicks off an EVM series focused on building an understanding of what happens under the hood when smart contracts execute.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1329983e9c5" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/what-really-happens-when-you-call-a-smart-contract-d1329983e9c5">What Really Happens When You Call a Smart Contract?</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The First Thing I Check When I See Division in Solidity]]></title>
            <link>https://coinsbench.com/the-first-thing-i-check-when-i-see-division-in-solidity-cb4e19619ebd?source=rss-7df2dad36683------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb4e19619ebd</guid>
            <category><![CDATA[precision-bugs]]></category>
            <category><![CDATA[solidity-smart-contract]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[smart-contract-auditing]]></category>
            <category><![CDATA[smart-contract-security]]></category>
            <dc:creator><![CDATA[derastephh]]></dc:creator>
            <pubDate>Wed, 01 Jul 2026 07:33:09 GMT</pubDate>
            <atom:updated>2026-07-03T08:11:21.186Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve spent time auditing smart contracts, you’ve probably noticed something. Division isn’t scary. But it deserves attention.</p><p>Whenever I see a line like this:</p><pre>shares = assets * totalShares / totalAssets;</pre><p>I don’t immediately think about math. I ask myself one question.</p><blockquote>“What gets lost here?”</blockquote><p>That single question has led to countless precision bugs across DeFi.</p><h3>Solidity Doesn’t Understand Fractions</h3><p>One thing that surprises beginners is that solidity has no idea what <strong>1.5</strong> means. It only stores whole numbers. So if we write:</p><pre>uint256 result = 3 / 2;</pre><p>the answer isn’t 1.5 <strong>, </strong>It’s simply 1<strong>. </strong>The 0.5 doesn’t get rounded. It doesn’t get stored somewhere. It just disappears. Once you understand that, precision bugs become much easier to spot.</p><h3>This Is What I Actually Look For</h3><p>When I see division during an audit, I don’t start calculating numbers. I start asking questions.</p><blockquote>Can this division round down?</blockquote><blockquote>Who benefits if it does?</blockquote><blockquote>Can someone repeat this many times?</blockquote><p>Those three questions usually tell me whether I should investigate further. For example:</p><pre>uint256 reward = userStake * rewardPool / totalStake;</pre><p>Looks harmless. But imagine this:</p><pre>userStake = 3<br>rewardPool = 100<br>totalStake = 8</pre><p>The real answer is 37.5, but solidity gives 37. Some unit disappears. Now imagine thousands of users doing this every day. Where do all those missing pieces go? That’s the question worth answering.</p><h3>Precision Bugs Usually Hide Here</h3><p>After reviewing enough code, you start seeing patterns. Whenever I find expressions like these, I slow down.</p><pre>amount * price / totalSupply<br>shares * assets / totalShares<br>reward * userBalance / totalBalance</pre><p>None of these are bugs by themselves. They’re just places where rounding can change who wins and who loses.</p><h3>Here’s How I Try to Break It</h3><p>Instead of staring at the code, I give it awkward numbers, not nice numbers. Numbers that don’t divide cleanly. For example:</p><pre>3 / 2<br>5 / 3<br>7 / 4<br>100 / 9</pre><p>If everything divides perfectly, you’re not really testing the edge cases. Precision bugs usually show up when there is a remainder.</p><h3>Proving the Bug</h3><p>Once I suspect rounding matters, I try to prove it with a simple Foundry test. For example:</p><pre>function test_precisionLoss() public {<br>    uint256 reward = 3 * 100 / 8;<br><br>    assertEq(reward, 37);<br>}</pre><p>The important part isn’t the assertion. It’s comparing what solidity returned with what you expected mathematically. If that missing value affects balances, shares, rewards, or withdrawals, you’ve found something worth investigating.</p><h3>Preventing It</h3><p>Most precision bugs aren’t fixed by adding more checks. They’re fixed by changing the order of operations.</p><p>Instead of:</p><pre>amount / total * price;</pre><p>Do:</p><pre>amount * price / total;</pre><p>Multiplying first preserves more precision before division removes the remainder. Sometimes that’s enough. Sometimes you also need proper rounding functions depending on whether users or the protocol should benefit from rounding.</p><h3>My Precision Bug Checklist</h3><p>While auditing a contract, these are the questions I ask.</p><ul><li>Is there a division?</li><li>Can a remainder be discarded?</li><li>Who gains from the rounding?</li><li>Can this happen repeatedly?</li><li>Does the protocol account for the lost precision?</li></ul><p>However, theory is the easy part.</p><p>Next time, we’ll hunt down a real precision bug from a public audit contest and walk through the exact thought process that turned a suspicious line of code into a valid finding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb4e19619ebd" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/the-first-thing-i-check-when-i-see-division-in-solidity-cb4e19619ebd">The First Thing I Check When I See Division in Solidity</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>