<?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 Zarah Gathoni on Medium]]></title>
        <description><![CDATA[Stories by Zarah Gathoni on Medium]]></description>
        <link>https://medium.com/@zarahgathoni76?source=rss-13fd05408f56------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0usP9y_IAfno3SpMVSJIQw.jpeg</url>
            <title>Stories by Zarah Gathoni on Medium</title>
            <link>https://medium.com/@zarahgathoni76?source=rss-13fd05408f56------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:28:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zarahgathoni76/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[My first kill: Bitcoin Mutants]]></title>
            <link>https://medium.com/@zarahgathoni76/my-first-kill-bitcoin-mutants-9e4e5a08a1a6?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e4e5a08a1a6</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 06:19:19 GMT</pubDate>
            <atom:updated>2026-11-21T07:49:36.344Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3W6iYsyIiQ-xXVRz7IFEZQ.png" /></figure><p>Contributing to Bitcoin, especially <a href="https://github.com/bitcoin/bitcoin">Bitcoin Core</a>, can be daunting, but it’s been easier than I thought.</p><p>The goal was to start simple, with something genuinely relevant. One of the <a href="https://btrust.tech/">Btrust </a>mentors gave us a talk on fuzzing and mutants. My first stop was <a href="https://mutanthub.space/">MutantHub</a>, a curated list of surviving mutants in Bitcoin Core. The mutants come from brunoerg’s mutation <a href="https://delvingbitcoin.org/t/incremental-mutation-testing-in-the-bitcoin-core/2197">testing tool</a>.</p><p><strong>What are mutants, you ask?</strong></p><p>A mutant is basically a copy of the code with one small, deliberate change, made to test the tests.</p><p><a href="https://mutanthub.space/mutants/4388">This</a> one, for instance, changes &amp;&amp; into || to see if any test notices when the code stops filtering out a finished chainstate.</p><p>None did, so the mutant survived.</p><p>Which brings me to my next point.</p><p><strong>The three states of a mutant</strong></p><ul><li>Survived: the tests do not catch the broken code.</li><li>Killed: at least one test fails, so the change is caught.</li><li>Equivalent: the change does not affect the program’s behaviour, so there is nothing to catch.</li></ul><p>What a surviving mutant like <a href="https://mutanthub.space/mutants/4383">this</a> proves:</p><p>No test can tell the broken code from the real code. It does <strong>not</strong> prove the code has a bug. The original code was correct the whole time. It proves a <strong>gap in the tests</strong>: if someone broke that line for real, CI would stay green. Sometimes it proves nothing at all, because the mutant is equivalent.</p><p><strong>Right, now about my first kill</strong></p><p>The mutant was simple and affected <a href="https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp">this</a> file:</p><pre>-  if (chainstate &amp;&amp; chainstate-&gt;m_assumeutxo != Assumeutxo::INVALID &amp;&amp; !chainstate-&gt;m_target_utxohash) {<br>+  if (chainstate || chainstate-&gt;m_assumeutxo != Assumeutxo::INVALID &amp;&amp; !chainstate-&gt;m_target_utxohash) {</pre><p>This line lives in ActivateBestChains(). It decides which chainstate the node keeps advancing. The original only lets a chainstate through if <strong>all three</strong> are true:</p><ol><li>it exists</li><li>its snapshot was not proven bad (!= INVALID)</li><li>it has not finished its job yet (!m_target_utxohash)</li></ol><p>The mutant swaps the first &amp;&amp; for ||. Now the first check alone is enough, and a chainstate always exists. So the condition is <strong>always true</strong>. Every chainstate gets through, including the background one that already finished validating the snapshot.</p><p><strong>Murder 101: a step-by-step</strong></p><p><em>The only murder where you want witnesses.</em></p><p><strong>Step 1: Intention</strong><br> Find out what the code is supposed to do. Some context: assumeutxo lets a node start from a snapshot and check it in the background. Once that check is done, the background chainstate should be left alone. The code should make sure it is not advanced again, and no test was catching it.</p><p><strong>Step 2: The stakeout</strong><br> Find where the code is being tested and what the test checks. The <a href="https://github.com/bitcoin/bitcoin/blob/master/src/test/validation_chainstatemanager_tests.cpp">test</a> I needed already reached the right moment, a finished chainstate still sitting in memory. It just never looked.</p><p><strong>Step 3: The weapon</strong><br>Keep it minimal. The test already validated the snapshot, so right after that I added one line:</p><pre>res = WITH_LOCK(::cs_main, return chainman.MaybeValidateSnapshot(validated_cs, active_cs));<br>BOOST_CHECK_EQUAL(res, SnapshotCompletionResult::SUCCESS);<br>BOOST_CHECK(chainman.ActivateBestChains());</pre><p>At this point the finished background chainstate is still in memory. The new line asks the node to advance its chainstates, and checks that it succeeds.</p><p><strong>Step 4: The kill</strong></p><p>Put the mutant back in and run the test. The finished chainstate now gets through the filter. Bitcoin Core has a safety guard for exactly this: if a finished chainstate is ever advanced, ActivateBestChain refuses and fails. So ActivateBestChains() fails, my BOOST_CHECK fails, and the test aborts. Mutant dead.</p><p>For the two pruning mutants (#4385 and #4386), I added these lines in the same test, just before validation:</p><pre>auto prune_range = WITH_LOCK(::cs_main, return active_cs.GetPruneRange(active_cs.m_chain.Height()));<br>BOOST_CHECK_EQUAL(prune_range.first, 111);<br>BOOST_CHECK_EQUAL(prune_range.second, 0);</pre><p>The snapshot is at block 110, so pruning must start at 111. The chain is shorter than 288 blocks, so nothing can be pruned yet, which is why the end is 0. The mutants return 109 and 210, and the checks fail.</p><p><strong>Step 5: The alibi</strong><br> Take the mutant out and run it again. Everything passes. Your test only fails when the code is broken.</p><p><strong>Step 6: Accomplices</strong><br>I looked at <a href="https://github.com/bitcoin/bitcoin/pull/33060">other</a> PRs killing mutants. <a href="https://github.com/bitcoin/bitcoin/pull/36054">Both</a> batched several mutants together. So after spending a whole day on one mutant, I spent the next day finding mutants around the same code, and found <a href="https://mutanthub.space/mutants/4385">#4385</a> and <a href="https://mutanthub.space/mutants/4386">#4386</a>. They were in the same file, and the assertions went in the same test block, so I batched them.</p><p><strong>Step 7: The trial</strong><br>I opened a<a href="https://github.com/bitcoin/bitcoin/pull/36827"> PR </a>as a certified killer. I opened a PR as a certified killer At the time of writing, it’s still open, with ACKs from brunoerg (who built the mutation testing tool) and ViniciusCestarii. It hasn’t been merged yet.</p><p>The good thing about mutants: you just make the change and test until you are able to catch it. Combine that with accepted conventions and the existing code format, and you too can kill mutants.</p><p><strong>What I learned</strong></p><ol><li>Look at the existing code conventions, comments, and commit style, and match them.</li><li>Take notes from people doing the same thing.</li><li>Write it in my own words. It doesn’t matter if you’re not a good writer.</li><li>No @ tags in PR descriptions.</li><li>Plain text. It becomes the merge commit.</li><li>Explain every force push.</li><li>Test, test, test. Prove it fails without the fix.</li><li>Check your change is actually applied before you test.</li><li>A red CI isn’t always your fault. Check before you panic.</li><li>Positive and negative reviews are both part of the process. You need both.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e4e5a08a1a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[First time? Wallet Interaction from Bitcoin Core]]></title>
            <link>https://medium.com/@zarahgathoni76/first-time-wallet-interaction-from-bitcoin-core-73c09e7bb8f8?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/73c09e7bb8f8</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Wed, 21 Oct 2026 21:36:02 GMT</pubDate>
            <atom:updated>2026-10-21T21:36:02.655Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are reading this article, you are probably trying to build on Bitcoin Core wallets, or just curious about how Bitcoin works, or just one of my followers who happened to see the article link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*g4ZbCYLDMd7pT-9SXfhoTA.gif" /></figure><p>Either way, I am going to walk you through wallet interaction with Bitcoin. I have been experimenting a lot with wallet descriptors over the last couple of weeks while learning about Bitcoin Core, and I find that the setup itself can be daunting. So I’m creating this guide for anyone who would want to play around with wallets as well.</p><p>If you would like to follow along, here is the prerequisite:</p><h4><strong>Install and run Bitcoin Core on regtest</strong></h4><p>If you don’t have that installed, there are two ways you can go about it: install it from <a href="https://bitcoin.org/en/download">here</a> or clone the <a href="https://github.com/bitcoin/bitcoin">Bitcoin Core repo</a> and build from source. There are installation guides for all operating systems:</p><p><a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md">build-unix.md</a>: Linux and general Unix <br><a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md">build-osx.md</a>: macOS <br><a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md">build-windows.md</a>: Windows, cross-compiling from Linux <br><a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows-msvc.md">build-windows-msvc.md</a>: Windows, building natively with Visual Studio <br><a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-openbsd.md">build-freebsd.md</a>, build-netbsd.md, build-openbsd.md: the BSD systems</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*yJ6pW9yZkeHjlivOKeaiiA.gif" /></figure><p><strong>What to pick: </strong>While picking the installation method, consider this: if your goal is to run a node and wallets, the official binary installation works fine. If you want to do more than that, like contribute to Bitcoin or test PRs, build from the repo.</p><p>If you are building from source, install the dependencies listed in the build guide for your OS first, then run:</p><p>git clone <a href="https://github.com/bitcoin/bitcoin.git">https://github.com/bitcoin/bitcoin.git</a><br>cd bitcoin</p><p>//configure<br>cmake -B build -DENABLE_IPC=OFF</p><p>//compile<br>cmake --build build -j$(nproc)</p><p><strong><em>PATH (Optional)</em></strong><br>Run one of these, so you don’t have to type the full path to your commands:<br>export PATH=$HOME/bitcoin-31.1/bin:$PATH (if running the official download)<br>export PATH=$HOME/bitcoin/build/bin:$PATH (if building from the repo)</p><p><strong>Now start your node in regtest mode:</strong></p><p>bitcoind -regtest -daemon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*sgf7sh3KaKtBXP_HIDemCg.png" /><figcaption>You should have something like this</figcaption></figure><p>If you skipped the PATH step above, use the full path instead, for example: ./build/bin/bitcoind -regtest -daemon from inside the repo, or ./bitcoin-31.1/bin/bitcoind -regtest -daemon from the official download. The same goes for bitcoin-cli below.</p><p><strong>Note</strong>: You might experience a few errors based on your setup or missing dependencies; feel free to paste the errors into an LLM to help you debug.</p><p>Now let’s actually get some wallet action (finally, I know):</p><h4><strong>Create a wallet:</strong></h4><p>bitcoin-cli -regtest createwallet &quot;mywallet&quot;<br>This should return the wallet name, “mywallet” in this case (you can name it anything).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*GUf9iHGYIgEPpwHdEsAs9Q.png" /><figcaption>Your terminal should have something like this</figcaption></figure><p>Now let’s <strong>mine</strong> some bitcoin to it.</p><figure><img alt="Mining Bitcoin" src="https://cdn-images-1.medium.com/max/480/1*swjMVeVbtqdgI7E6blWMBQ.gif" /></figure><p>The mining command takes an address, so you get one from the wallet first.<br>Get a <strong>new address</strong> to send your test coins to:<br>ADDR=$(bitcoin-cli -regtest getnewaddress)</p><p>A wallet holds descriptors, which are recipes for making addresses. getnewaddress creates a new address from the wallet’s active descriptor, using the next unused index.<br>Core also derives a batch of addresses in advance and keeps them in a keypool, so it can spot payments to them. The descriptor is the formula that makes those addresses.</p><p>You can see the wallet descriptors by running:<br>bitcoin-cli -regtest listdescriptors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*vyFpVwBRlBsVm2uHHpO7Rg.png" /><figcaption>First and second descriptor (You should have something like this)</figcaption></figure><p>If you have several wallets loaded, you should specify the wallet name:<br>bitcoin-cli -regtest -rpcwallet=mywallet listdescriptors</p><p>To create test coins, we need to mine 101 blocks. Every block you mine pays a 50 BTC reward to your address. Bitcoin only lets you spend that reward after 100 more blocks are mined on top of it. Mining 101 blocks makes the reward from block 1 spendable, so your balance shows 50 BTC. In regtest, we can simulate this with this command:</p><p>bitcoin-cli -regtest generatetoaddress 101 $ADDR</p><p>So run it and get your wallet <strong>balance</strong>:</p><p>bitcoin-cli -regtest getbalance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*PPgwgBMHWzy2QgVGZJ27UQ.png" /><figcaption>wallet balance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*km1NtROYsNlfxen-ldnGVw.gif" /><figcaption>You right now</figcaption></figure><p>You can also mine to a descriptor if you’d prefer. generatetodescriptor needs a descriptor for a single address. The ranged descriptors from listdescriptors end in /* and are rejected. getaddressinfo returns the descriptor for one address, so use it to get one. Run these in order:</p><p>Get a new address:<br>MINE_ADDR=$(bitcoin-cli -regtest getnewaddress)</p><p>See the descriptor behind that address (look for the “desc” line):<br>bitcoin-cli -regtest getaddressinfo $MINE_ADDR</p><p>Copy the value of “desc” and mine to it:<br>bitcoin-cli -regtest generatetodescriptor 101 &quot;PASTE_DESC_HERE&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*PTknRuvAuKJ8LgCt3KI2HA.png" /><figcaption>you should have more</figcaption></figure><p>Get balance:<br>bitcoin-cli -regtest getbalance</p><p>To see more variations of wallet commands you can run, or otherwise, check out more Bitcoin RPCs <a href="https://bitcoincore.org/en/doc/">here</a> and what they do<br>You can also run bitcoin-cli help if you’d rather see them from the terminal.</p><h4><strong>Wallet transfers</strong></h4><p>Now you can send some of your balance to<strong> another wallet</strong>. Create a second wallet and get an address from it:</p><p>bitcoin-cli -regtest createwallet &quot;wallet2&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*ymr107jr93BZ-eYRdBUbfQ.png" /><figcaption>Wallet 2 generation result</figcaption></figure><p>ADDR2=$(bitcoin-cli -regtest -rpcwallet=wallet2 getnewaddress)</p><p>Send coins from mywallet (a fresh regtest node has no fee estimate, so we set the fee rate):</p><p>bitcoin-cli -regtest -rpcwallet=mywallet -named sendtoaddress address=$ADDR2 amount=1 fee_rate=1</p><p>Mine one block to confirm it, then check the balance of wallet2:</p><p>bitcoin-cli -regtest -rpcwallet=mywallet generatetoaddress 1 $ADDR<br>bitcoin-cli -regtest -rpcwallet=wallet2 getbalance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*nwKhnVaLvxTk5fXy743YgA.png" /><figcaption>You should have something like this</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*9dDS1wzQkMu_IhZIBmc43Q.gif" /></figure><p>Congratulations, you have successfully created a wallet from Bitcoin Core and interacted with it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73c09e7bb8f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lightning Transaction Through the Codebase]]></title>
            <link>https://medium.com/@zarahgathoni76/lightning-transaction-through-the-codebase-702b55b56703?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/702b55b56703</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 09:07:42 GMT</pubDate>
            <atom:updated>2026-10-12T09:23:15.207Z</atom:updated>
            <content:encoded><![CDATA[<p>There are five layers of the Lightning network:</p><p>Transport layer -&gt; Base Layer -&gt; Update Layer -&gt; Transfer Layer -&gt; Multihop layer</p><p>This article traces a transaction through channel creation, the Update and Transfer layers, looking at how it executes on the Lightning network. I pulled out 3 functions for each of the 3 layers from <a href="https://github.com/lightningnetwork/lnd/blob/master/input/script_utils.go#L175">lnd</a>, and hopefully it gives you an idea of how the user interacts with the codebase.</p><p>Take a minute to look at the image below until you are confused, so you can come back at the end and actually understand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqZzxwNweHACXDhL6baaAg.png" /></figure><h4><strong>Channel Creation</strong></h4><p>The first step in creating a Lightning transaction is creating a channel. Ideally, a channel should have only two transactions on the blockchain: one funding transaction, which opens and represents the channel on-chain, and one closing transaction that settles final balances on-chain. Everything else happens off-chain. Channel creation is the first step that allows other Lightning layers to exist.</p><p>The user clicks Open Channel or Connect Node on an app or wallet, and this calls the LND’s openChannel RPC. Both nodes agree on the keys and amounts by calling it, and once they have agreed on the amounts, they call this function.</p><pre>func GenFundingPkScript(aPub, bPub []byte, amt int64) ([]byte, *wire.TxOut, error) {<br> // As a sanity check, ensure that the passed amount is above zero.<br> if amt &lt;= 0 {<br>  return nil, nil, fmt.Errorf(&quot;can&#39;t create FundTx script with &quot; +<br>   &quot;zero, or negative coins&quot;)<br> }<br><br> // First, create the 2-of-2 multi-sig script itself.<br> witnessScript, err := GenMultiSigScript(aPub, bPub)<br> if err != nil {<br>  return nil, nil, err<br> }<br><br> // With the 2-of-2 script in had, generate a p2wsh script which pays<br> // to the funding script.<br> pkScript, err := WitnessScriptHash(witnessScript)<br> if err != nil {<br>  return nil, nil, err<br> }<br><br> return witnessScript, wire.NewTxOut(amt, pkScript), nil<br>}</pre><blockquote>Produce two valid signatures” (2-of-2 multisig)</blockquote><p>The function above creates a 2-of-2 multisig output on which the entire channel transaction is built. The funds are locked in this output, which both parties jointly control, until both sides sign a spend. The initial channel can be funded entirely by one participant, or by both. To build it, the function calls GenMultiSigScript. WitnessScriptHash hashes the multisig script nd this is what gets sent on-chain. The function returns the raw script, needs to approve spends, and wire.TxOut , which becomes part of the funding transaction which gets broadcast to the Bitcoin network. When the funding transaction reaches the required confirmation depth, the peers exchange channel_ready messages and the channel can become usable.</p><h4><strong>The Update layer</strong></h4><p>Once funded, the channel needs a way to represent “who has what” and update it repeatedly, off-chain, without either side being able to cheat by reverting to an old, more favorable balance. Hence, the update layer</p><p>User A calls SendPayment/AddInvoice through lnd. A new transaction commitment is triggered once htlcswitch decides whether to resolve an existing HTLC or add a new one. An HTLC is a Hash Time-Locked Contract: a conditional output that lets payments trustlessly cross one hop of a Lightning channel. This is the script that says: if this person has a revocation key ‘RevKeyHash’, they can have the funds. It is what ensures that money moves correctly or safely bounces back, but I digress. You can learn more about HTLCs<a href="https://www.ellemouton.com/posts/htlc-deep-dive/"> here</a>.</p><p>Then we call this function:</p><pre>func CommitScriptToSelf(csvTimeout uint32, selfKey, revokeKey *btcec.PublicKey) ([]byte, error) {<br> // This script is spendable under two conditions: either the<br> // &#39;csvTimeout&#39; has passed and we can redeem our funds, or they can<br> // produce a valid signature with the revocation public key. The<br> // revocation public key will *only* be known to the other party if we<br> // have divulged the revocation hash, allowing them to homomorphically<br> // derive the proper private key which corresponds to the revoke public<br> // key.<br> return txscript.ScriptTemplate(<br>  `<br>  OP_IF<br>   {{ hex .RevokeKey }}<br>  OP_ELSE<br>   {{ .CsvTimeout }} OP_CHECKSEQUENCEVERIFY OP_DROP<br>   {{ hex .SelfKey }}<br>  OP_ENDIF<br>  OP_CHECKSIG`,<br>  txscript.WithScriptTemplateParams(TemplateParams{<br>   &quot;RevokeKey&quot;:  revokeKey.SerializeCompressed(),<br>   &quot;CsvTimeout&quot;: int64(csvTimeout),<br>   &quot;SelfKey&quot;:    selfKey.SerializeCompressed(),<br>  }),<br> )<br>}</pre><blockquote>Either sign with the revocation key, or wait out the delay and sign with your own key</blockquote><p>The function constructs each party’s output on their respective commitment transactions. The two nodes then exchange the commitment transaction, sign it, and store it off-chain. The script only goes on-chain if someone force-closes the channel.</p><p>The function is internal to lnd’s lnwallet package, so it&#39;s abstracted from users; it&#39;s only involved when changing the channel state. Let&#39;s break down the function:</p><p><strong><em>Function Inputs:</em></strong><br>csvTimeout- number of blocks the user must wait before sending their own output. This is the to_self_delay that is negotiated at channel open and used every time after that. The selfKey is specific to a user&#39;s commitment state; every commitment state creates a new key.</p><p>The revokeKey is also state-specific— a counterparty can use it if the state gets broadcast after being superseded by a transaction spending the OP_IF branch. The person holding the revocation key gets the funds, and the one who broadcasts a stale state gets slashed. In <a href="https://www.bitcoinlightning.com/eltoo-protocol/">Eltoo</a>, however, the punishment is skipped, and the key just overwrites the old state.</p><p><strong><em>Flow:</em></strong></p><p>The function builds a script template using two competing paths: the OP_IF branch is revocation, and OP_ELSE is an honest self-spend after the csvTimeout blocks have passed. {{ .CsvTimeout }} OP_CHECKSEQUENCEVERIFY OP_DROP enforces the wait. OP_ENDIF OP_CHECKSIG closes it out, as OP_CHECKSIG checks the signature against the key that either of the branches leaves upon execution.</p><p><strong><em>Output:</em></strong></p><p>The function produces the final script bytes, which become an output of the commitment transaction wrapped in P2WSH. This script becomes the to_local output of a specific party’s commitment transaction, and paired with the counterparty’s CommitScriptUnencumbered. This function runs every time the channel balance changes, generating new revokeKey and selfKey at every change.</p><h4><strong>The Transfer Layer</strong></h4><p>This is what runs every time a payment needs to move through a channel, especially when the payment is crossing a hop.</p><p>A user taps sendPayment or shares an invoice to receive a payment. The wallet call sendPayment function in LND, or an invoice triggers AddInvoice, which calls htlcSwitch, which can either reset the payment as the final recipient or forward it. This triggers a new commitment transaction just like the update layer but with an extra output. The extra output is what ReceiverHTLCScript<strong> </strong>builds<strong>.</strong></p><pre>func ReceiverHTLCScript(cltvExpiry uint32, senderHtlcKey,<br> receiverHtlcKey, revocationKey *btcec.PublicKey,<br> paymentHash []byte, confirmedSpend bool) ([]byte, error) {<br><br> // The script structure mirrors SenderHTLCScript but from the<br> // receiver&#39;s perspective:<br> //   - Revocation path: DUP+HASH160 check, then checksig.<br> //   - Else: push sender key, swap, check size.<br> //     - If 32 bytes (preimage path): hash160-verify the preimage,<br> //       then 2-of-2 multisig with sender+receiver keys.<br> //     - If not 32 bytes (timeout path): drop, CLTV check, checksig.<br> //   - Optional 1-block CSV for confirmed spend.<br> scriptTemplate := `<br>  OP_DUP OP_HASH160 {{ hex .RevKeyHash }} OP_EQUAL<br>  OP_IF<br>   OP_CHECKSIG<br>  OP_ELSE<br>   {{ hex .SenderKey }}<br>   OP_SWAP<br>   OP_SIZE 32 OP_EQUAL<br>   OP_IF<br>    OP_HASH160 {{ hex .PaymentHashRipemd }}<br>    OP_EQUALVERIFY<br>    OP_2 OP_SWAP {{ hex .ReceiverKey }}<br>    OP_2 OP_CHECKMULTISIG<br>   OP_ELSE<br>    OP_DROP<br>    {{ .CltvExpiry }} OP_CHECKLOCKTIMEVERIFY<br>    OP_DROP OP_CHECKSIG<br>   OP_ENDIF<br> `<br><br> // Add 1 block CSV delay for non-revocation clauses if confirmation is<br> // required.<br> if confirmedSpend {<br>  scriptTemplate += `<br>   OP_1 OP_CHECKSEQUENCEVERIFY OP_DROP`<br> }<br><br> // Close out the outer if statement.<br> scriptTemplate += ` OP_ENDIF`<br><br> // Use the ScriptTemplate function with the properly formatted template<br> return txscript.ScriptTemplate(<br>  scriptTemplate,<br>  txscript.WithScriptTemplateParams(TemplateParams{<br>   &quot;RevKeyHash&quot;: address.Hash160(<br>    revocationKey.SerializeCompressed(),<br>   ),<br>   &quot;SenderKey&quot;:         senderHtlcKey.SerializeCompressed(),   //nolint:ll<br>   &quot;ReceiverKey&quot;:       receiverHtlcKey.SerializeCompressed(), //nolint:ll<br>   &quot;PaymentHashRipemd&quot;: Ripemd160H(paymentHash),<br>   &quot;CltvExpiry&quot;:        int64(cltvExpiry),<br>  }),<br> )<br>}</pre><blockquote>Either sign with the revocation key, or wait out the delay and sign with your own key</blockquote><p>It takes on freshly derived HTLC keys, revocationKey, and the payment hash that we need from the receiver.</p><p>Take in 6 inputs: cltvExpiry is the absolute deadline for claiming a payment.senderHtlcKey/receiverHtlcKey are keys deuved for every HTLC. revocationKey is still for state punishment, just like in the update later. <strong>paymentHash </strong>represents the hash that the receiver produces before receiving the payments, and confirmed spend specifies whether to add a one-block delay.</p><p>Just like in the transfer layer, the flow starts with revocation, but with an extra layer to handle on-flight payments. If the payment is not revoked, the script triggers the hashlock path, which matches the hash to PaymentHashRipemdIf this hash matches the multisig between the sender and receiver, the receiver can actuate the payment using the secret. Else, the sender can reclaim the funds using the OP_CHECKLOCKTIMEVERIFY, cltvExpirypath.</p><p>The function outputs a P2WSH, a conditional script added as an extra output together with the outputs from the update layer. This extra output is dropped once the preimage is revealed and only goes on-chain if the transaction is force-closed. Whichever path fires, the HTLC resolves and collapses back into a plain balance, back to the update layer. evaluateHTLCView recalculates the HTLC balances before handing them to the update layer’s CommitScriptToSelf.</p><p><strong>ps:</strong></p><p>Every one of these lives as Bitcoin Script, evaluated by the same rules as any ordinary transaction. Bitcoin itself has no concept of “Lightning”; it just sees scripts with OP_IF branches, CSV checks, CLTV checks, hash comparisons. Everything that makes this “Lightning” is entirely in how lnd (or CLN, same logic, different language) chooses to construct, exchange, and hold these scripts off-chain, only falling back to actual on-chain broadcast when something needs enforcing for real.</p><p>I hope this gives you an idea of how a transaction fulfills on Lightning from the moment the user initializes it. I thought including the functions would help put the new concepts in context; at least they did for me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=702b55b56703" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Overview of Bitcoin Scripts, Addresses, and Encodings]]></title>
            <link>https://medium.com/@zarahgathoni76/an-overview-of-bitcoin-scripts-addresses-and-encodings-f97eea8db202?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/f97eea8db202</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 06:48:56 GMT</pubDate>
            <atom:updated>2026-09-14T06:48:56.460Z</atom:updated>
            <content:encoded><![CDATA[<p>Bitcoin Core, the reference implementation of the Bitcoin protocol, is written in C++. Script, the small language used to lock and unlock transaction outputs, is separate. Bitcoin’s original whitepaper never even mentions “script” or “contracts”; it describes ownership simply as a chain of digital signatures. Script was added later, in the earliest released code, to generalize that idea rather than hardcode a new special case for every new transaction type Satoshi could think of.</p><h3>Why Script?</h3><p>Bitcoin Script is predictable and safe. This matters across Bitcoin’s codebase, where a powerful but unpredictable language would be a liability rather than a feature. Script is stack-based, meaning there are no memory locations and no variables. Everything happens through pushing and popping items on a stack. Opcodes operate on the item at the top of the stack and return the result to the stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zJwAQFMxjLKTi3serrMLZg.png" /></figure><p>It’s not Turing-complete: Bitcoin Script is designed without loops and jumps like while and for, which you’d see in other languages. This prevents execution from running forever, which would otherwise open the door to a DoS attack or the halting problem. There is conditional branching, of course, with OP_IF and OP_ENDIF, but the goal is to make sure the script executes from top to bottom, once.</p><p>Another important aspect of Bitcoin Script is that it’s context-free. Once a script is evaluated as true or false, it stays that way regardless of external state. This matters for consensus, since every node needs to re-run the same script and arrive at the same result to validate a transaction.</p><p>As Satoshi explained in a 2010 mailing list post, once Bitcoin’s core design was released, it was “set in stone for the rest of its lifetime,” so he wanted Script to support every transaction type he could think of in advance, rather than needing new special-case code and data fields for each one. That design choice has held up: new spending patterns, like multisig or, more recently, Taproot, have been layered on top of the same small opcode set over the years, without needing to change Bitcoin’s consensus rules from scratch each time.</p><p>That same small, fixed set of primitives is also what makes a tool like Miniscript possible later on (more on that under Other Concepts): because Script only ever does a few well-understood things, software can reason about it systematically, rather than treating every script as a one-off puzzle.</p><h3>Bitcoin Scripts</h3><p>A locking script (ScriptPubKey) is placed on every output, and an unlocking script (ScriptSig, or witness data for newer output types) is provided to spend that output in a later transaction. A script contains two basic things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALjkT2pSDiaLRN9_Lu2L-w.png" /></figure><ul><li><strong>Data</strong> = signature + public key (supplied by the spender in the ScriptSig)</li><li><strong>Opcode</strong> = the instructions (DUP, HASH160, EQUALVERIFY, CHECKSIG). You can check more opcodes <a href="https://wiki.bitcoinsv.io/index.php/Opcodes_used_in_Bitcoin_Script">here</a>.</li></ul><p>In a typical P2PKH pair: the locking script (ScriptPubKey) contains the public key hash as its data; the unlocking script (ScriptSig) supplies the signature and public key as its data when the spender wants to redeem it.</p><p><strong>From Script to Address</strong>: An address is basically an easy way of sharing a locking script. It encodes a public key hash or a script hash. When you send someone your address, you’re asking them to lock up your bitcoin to a certain pattern, defined by that address’s script hash or public key hash. Addresses present a much friendlier alternative to handing someone a raw locking script directly, which is where Bitcoin’s various encoding formats come in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlkHqtQ7FwwJsb64dURAPQ.png" /></figure><h3>Bitcoin Encoding</h3><p>Going through the transactions and scripts in Bitcoin, I remember my first thought was: what is CompactSize? What about Script? It turns out Bitcoin relies on several distinct encoding formats, some built for people (wallets and addresses you’ll actually type or scan) and some built for machines (raw data passed between nodes on the network).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xoJEuoQLfZsU-SPanWDSWA.png" /></figure><h3>Wallet and Address Encodings</h3><p>These are the formats you’ll actually see and interact with as a user.</p><p><strong>Base58</strong>: Used for P2PKH and P2SH addresses. Uses 58 characters, including 1–9 and a-z in both lowercase and uppercase, deliberately excluding characters that are easy to misread.</p><ul><li><strong>P2PKH</strong>: Starts with 1. It’s a Base58Check encoding of the public key hash, with a version byte of 00 that makes the address start with 1 and distinguishes it from P2SH.</li></ul><pre>18p3G8gQ3oKy4U9EqnWs7UZswdqAMhE3r8</pre><ul><li><strong>P2SH</strong>: A Base58Check encoding of the 20-byte script hash. The version byte is set to 05 so that the first character of the address is always 3.</li></ul><pre>3CK4fEwbMP7heJarmU4eqA3sMbVJyEnU3V</pre><p><strong>Base58Check</strong>: Adds a checksum to the data before encoding it in Base58, so a typo is caught rather than silently sent to the wrong place.</p><p><strong>Bech32</strong>: Used for P2WPKH and P2WSH wallets.</p><ul><li><strong>P2WPKH</strong>: A Bech32 SegWit address encodes the witness version and witness program. The address’s 42-character length distinguishes it from the similar-looking P2WSH addresses. Starts with bc1q.</li></ul><pre>bc1qssdcp5kvwh6nghzg9tuk99xsflwkdv4hgvq58q</pre><ul><li><strong>P2WSH</strong>: 62 characters, an encoding of the full hex ScriptPubKey with a 32-byte script hash. Also starts with bc1q.</li></ul><pre>bc1qvhu3557twysq2ldn6dut6rmaj3qk04p60h9l79wk4lzgy0ca8mfsnffz65</pre><p><strong>Bech32m</strong>: A variant of Bech32 that fixes a checksum edge case. Used for Taproot addresses.</p><ul><li><strong>P2TR (Taproot)</strong>: A Bech32m encoding of the full hex ScriptPubKey. Made up of 62 characters, starting with bc1p.</li></ul><pre>bc1ppuxgmd6n4j73wdp688p08a8rte97dkn5n70r2ym6kgsw0v3c5ensrytduf</pre><h3>Machine Encodings</h3><p>These formats aren’t meant for a person to read or type. They exist purely so nodes and software can pass raw data around efficiently.</p><p><strong>Hexadecimal (Hex)</strong>: Base 16, 0–9, a–f. Used for raw transaction hex, public keys, and block/transaction hashes; the standard way developers and node software look at raw bytes.</p><p><strong>Base64</strong>: 64-character alphanumeric plus +, /, and = for padding. Used for Partially Signed Bitcoin Transactions (PSBTs), as they move between wallets and hardware devices as text.</p><p><strong>CompactSize (VarInt)</strong>: Used for encoding variable-length data, like field sizes and counts (input count, script size, and so on) inside a raw transaction.</p><p><strong>Reverse Byte Order</strong>: TXIDs are displayed reversed from their raw stored form; a Bitcoin-specific historical quirk carried over from the earliest client software.</p><p><strong>Script</strong>: The actual executable, stack-based language for locking and unlocking outputs (ScriptSig, ScriptPubKey, witness data), as covered above.</p><p><strong>Little-Endian</strong>: Multi-byte integers stored least-significant-byte-first. Used for version, amounts, VOUT, sequence, and locktime fields.</p><h3>Other Concepts</h3><p>Miniscript builds directly on top of Script itself, while Schnorr signatures and key aggregation are a separate, newer pair of building blocks that make Taproot possible.</p><p><strong>Miniscript</strong>: A structured way of representing a subset of Bitcoin Script, picking up on the hint above: because Script is small and predictable, Miniscript can take a script and reason about it automatically, computing the right address, figuring out which signers are needed, and assembling a valid transaction, rather than needing custom, one-off code for every new spending condition like multisig or timelocked policies. Human-readability is a side benefit; the real point is making Script machine-verifiable.</p><p><strong>Schnorr Signatures</strong>: Bitcoin introduced Schnorr signatures with Taproot through BIP340. Schnorr signatures have useful algebraic properties that enable protocols such as MuSig2, where multiple participants can collaboratively produce a signature that verifies against an aggregated public key. Schnorr signatures have strong provable correctness, don’t suffer from the malleability issues older ECDSA signatures had, and are relatively fast to verify. Schnorr signatures also provide useful building blocks for second-layer protocols and multisignature constructions, including MuSig2-based schemes and Taproot-based Lightning designs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBdUvd1NA9K62QVvpkEzOg.png" /></figure><p><strong>Key Aggregation</strong>: Builds directly on Schnorr signatures to combine multiple parties’ keys into a single, aggregated key before a transaction is even constructed, so only one signature ever needs to be checked on-chain. It builds on existing Bitcoin smart contract patterns like Pay-to-Script-Hash (P2SH), but instead of needing separate OP_CHECKSIG or OP_CHECKMULTISIG calls for each signer, key aggregation means only a single signature check is needed on-chain, regardless of how many parties actually signed off-chain.</p><p>Benefits of key aggregation:</p><ul><li>Improves multisig privacy, since an aggregated signature looks like a single-signer transaction from the outside</li><li>Increases transaction efficiency and validation speed</li><li>Improves security</li><li>Makes smart contract solutions like Taproot possible</li></ul><p>I hope this article gives you an idea of how Bitcoin scripts, encoding, and addresses relate in a technical sense.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f97eea8db202" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The WHY Behind Bitcoin’s Design]]></title>
            <link>https://medium.com/@zarahgathoni76/the-why-behind-bitcoins-design-6b56eef7128d?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b56eef7128d</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 07:10:26 GMT</pubDate>
            <atom:updated>2026-09-01T07:11:59.262Z</atom:updated>
            <content:encoded><![CDATA[<p>You have probably already read the<a href="https://chaincode.com/bitcoin.pdf"> Bitcoin whitepaper</a>, or at least heard of it. If you are anything like me, you&#39;re one, confused, and/or two, trying to understand why Satoshi built Bitcoin in the first place and, more importantly, why he built it the way he did.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-K3Nw4XjtjvZNSOhqmacTQ.png" /></figure><p>Before we get into it, it helps to know that most of the concepts used as building blocks of Bitcoin have existed since as early as the 1980s. The genius of Satoshi was bringing these concepts together, and yes, some innovative tweaks (which we’ll talk about) to make them work for Bitcoin. Bitcoin is built on three components: a secure ledger, a valuable currency, and mining power.</p><h4><strong>A secure ledger</strong></h4><p>The whole essence of Bitcoin is to create a way to send money from one party to another without a third party or financial institution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DTtjxzh9Z18mFtxpOogvig.png" /></figure><p>The data structure starts from a ledger, a way to record transactions which dates back to the 1990s. We need a way to make the ledger immutable and digestible in a succinct format at any time, and this creates the need for linked timestamping.</p><p>Digital cash systems already worked well, thanks to digital signatures. Existing ledgers already used hash pointers (links between documents using hashes instead of signatures, as hashes are easier to compute). They also allowed grouping of documents created around the same time to handle volume, and used a binary tree of hash pointers (Merkle tree) to link documents within each block. Satoshi re-engineered this and added proof of work on top; this is where the ledger and mining power start to connect, which we’ll get into next.</p><h4><strong>Mining power</strong></h4><p>The only reason we need financial institutions is to prevent double-spending. While digital signatures can prove payment authorization, they cannot prevent the sender from sending the same payment elsewhere. With financial institutions, we can keep track of transactions and a record of which one arrived first. The way bitcoin solves this is by all of this is by creating a purely peer-to-peer version of an electronic cash system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNQ7VUOAKW4QUgqMXzveRA.png" /></figure><p>To replace third-party institutions, peers run the same network to reconcile transactions, which introduces proof of work, a term coined in 1999. Proof of work simply says that the only way to validate a transaction is by doing intense computational work, and in the process, new bitcoins come into circulation.</p><p>Nodes compete to add transactions into a block, and whoever gets the correct hash first gets paid. The other nodes check that the transactions are valid, and when they reach consensus (a majority of the nodes agreeing that the transactions are valid), the block is added to the chain, and the nodes move on to finding the next block.</p><p>Satoshi also uses proof of work to solve Byzantine fault tolerance(BFT). BFT means that internet currency without a central authority will inevitably face adversaries (different nodes seeing different blocks), and linked timestamping alone cannot resolve this. Bitcoin becomes tolerant of attackers and of nodes joining and leaving the network because proof of work takes a lot of computing power to produce, making it nearly impossible for an attacker to pull it off or benefit from it.</p><h4><strong>A valuable currency</strong></h4><p>This tolerance to attackers is only possible because Bitcoin introduces a valuable currency to reward miners; without that reward, there’d be no reason to expend all that computing power honestly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I6do-uEfXpmHIH0dUhrsnQ.png" /></figure><p>Earlier implementations of proof of work created a catch-22 issue. What this means is that we need a digital currency to create a marketplace, but the whole point of building proof of work is to create that secure, working digital currency in the first place. b-money and BitGold were proposals to sign off on the creation of money through proof of work, and sign off on transfers after the money was created. These proposals, however, lacked a clear way to resolve node disagreements, which exposed them to the Sybil problem (fake accounts becoming the majority of the network). Bitcoin secures against this using proof of work.</p><p>The timestamping and Byzantine researchers did not think to incentivize nodes for being honest or use proof of work to eliminate the need for identities. The authors of hashcash, b-money, and bit gold did not figure out how to solve double-spending using a consensus algorithm. Bitcoin secures the ledger using mining power, and this ensures the currency has value and therefore is enough to reward the miners. Without proof of work, double-spending and Sybil attacks would inevitably happen.</p><p>I hope this sheds more light on your understanding of Bitcoin architecture</p><h4>Sources</h4><p><a href="https://chaincode.com/bitcoin.pdf">The Bitcoin Whitepaper</a></p><p><a href="https://queue.acm.org/detail.cfm?id=3136559">Bitcoin’s Academic Pedigree</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b56eef7128d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web3 market Entry: A comparison Accross Markets]]></title>
            <link>https://medium.com/@zarahgathoni76/web3-market-entry-a-comparison-9fc1ec64ffba?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fc1ec64ffba</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Sun, 03 May 2026 20:25:43 GMT</pubDate>
            <atom:updated>2026-05-03T20:35:23.936Z</atom:updated>
            <content:encoded><![CDATA[<img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fc1ec64ffba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BuilderUptime: Because Therapy is Expensive and AI.., well I don’t trust it]]></title>
            <link>https://medium.com/@zarahgathoni76/builderuptime-because-therapy-is-expensive-and-ai-well-i-dont-trust-it-9b5d9e764bc7?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b5d9e764bc7</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Fri, 05 Dec 2025 06:09:47 GMT</pubDate>
            <atom:updated>2025-12-05T08:10:49.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cIAF_FWiKiugc6Few74Z3w.jpeg" /></figure><p>I sat in my Dubai hotel after one of my worst pitch practices. Everyone got grilled, but it hit me harder than most — it always does. I have this annoying habit of feeling things deeply, which is great for empathy but terrible for survival in startup land where everyone’s supposed to be relentlessly optimistic or at least good at faking it.</p><p>I needed someone to talk to. Not just to vent — I needed someone to reason through my feelings with me, because sometimes I’m being completely unreasonable and I need someone to tell help me see without it turning into a whole thing.</p><p>But here’s the problem: people have their own lives. Like the woman absolutely demolishing her boyfriend on call at the balcony near where I sat, processing my pitch trauma. That argument — ugly, raw, and way too loud — made me realize something: even a partner might not always be available to walk me through my feelings about a “little pitch” when I’d had the audacity to fly halfway across the world for it.</p><p>The human design is too complex for this use case. We’re great at many things, but being consistently available emotional processors? Not our strong suit. We just produce them and deal with then in however we please based on past experience and current information.</p><p>I’d started building BuilderUptime to track founder productivity and mood data. But at 2 AM in that hotel room, I realized: it’s not about output. It’s about whether you can actually carry that output into tomorrow without completely burning out. Some things are out of our control. We’re human. It took four stages of anxiety in one boardroom to figure that out.</p><p>I usually talk to Claude about my thinking process — she’s brilliant. But she keeps forgetting my context, and sometimes I just don’t want to re-explain my entire life story to get decent advice. Plus, data privacy for conversations about why I cried in a pitch meeting is kind of critical.</p><p>Then Dennis from NEAR said something that stuck: their technology makes AI actually decentralized. “Every other one is bullshit,” he said I should not tell you that he said that. And in that moment of defeat, sitting in Dubai feeling like a failure, I found perfect clarity on how BuilderUptime could actually scale.</p><p><strong>What It Does:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPyafvKhj6P7TCpGKo3LGQ.jpeg" /></figure><p>BuilderUptime learns your patterns, analyzes your emotions (including the messy way you communicate them), helps you gain clarity, and makes you better at managing both your feelings and your life.</p><p>As Jane Machuka said on a random tweet in 2021: “If you can’t measure it, you can’t manage it.”</p><p>Builders bring cool stuff to life and forget to iterate on what matters most: their wellbeing, time management, and ability to make decisions that don’t implode their lives. Both personal and business.</p><p>Think of it as a productivity tool, but wholesome. Actually improving you as a human, not just squeezing more output from your rapidly deteriorating mental health. All while maintaining decentralization, because your 3 AM existential crisis shouldn’t be stored on some company’s server.</p><p><strong>Features:</strong></p><ul><li>Private AI chat for emotional processing (no judgment, available 24/7, never tired of your problems)</li><li>Mood tracking that actually helps you spot patterns before you crash</li><li>Notepad for your scattered 3 AM thoughts</li><li>Check-ins with deadline tracking</li><li>Decentralized storage (your breakdowns belong to you)</li><li>Verifiable AI through NEAR’s Shade Agents (because trust issues are valid)</li></ul><p><strong>Why “BuilderUptime”?</strong></p><p>Would I change the name? Maybe. Did I already pay for the domain? Yes. All $20 of it. And I’m getting my money’s worth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b5d9e764bc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Practical Guide to Getting Started in Web3]]></title>
            <link>https://medium.com/@zarahgathoni76/a-practical-guide-to-getting-started-in-web3-92a66286255c?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/92a66286255c</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 19:55:06 GMT</pubDate>
            <atom:updated>2026-11-02T19:33:02.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74irmzNZkwY7tyS2AyvlFg.jpeg" /></figure><p>I finally got the guts to sit down and write this article.</p><p>This is for two types of people:</p><ul><li>Newbies who don’t know anything about coding, fintech, or blockchain</li><li>Techies looking to expand their scope into web3/blockchain</li></ul><p><strong>The Quick Version</strong></p><p>Web3 is simply the future of the internet and finance. Instead of having banks own our money and tech companies own our data, we get to own it. Web3 is the whole decentralization umbrella, blockchain is the technology driving it, and crypto is the incentives layer — the fuel driving the engine.</p><p>That’s all the explanation I’m going to give you because a lot of people have written amazing articles and made videos on the topic, so I don’t have to. As a web3 beginner, I often got lost in resources, jumping from one half-finished tutorial to the next.</p><p>So I’m giving you 5 resources (4 videos and 1 article), all under 10 minutes, to give you all the basics you need. Please don’t be like me — go through all of them. They’re just 5, and under 10 minutes each.</p><p><strong>The Essential 5</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRBfTOXNx4sxj0zBOQZSgg.jpeg" /></figure><p>For a basic explanation of what web3 and blockchain is, here is a short <a href="https://www.youtube.com/watch?v=FExp9YuTzbY">video</a> by SimpleLearn.</p><p>For a more advanced deep dive, check out <a href="https://www.youtube.com/watch?v=FExp9YuTzbY">this</a> video by Fireship (fast, short, and more technical).</p><p>Now that you understand what web3 is, you might want a <a href="https://www.youtube.com/watch?v=93E_GzvpMA0">deeper</a> dive into blockchain and how it works under the hood. Here’s <a href="https://www.youtube.com/watch?v=yubzJw0uiE4">another</a> video that explains how it relates to cryptocurrencies.</p><p>Those four videos should set you straight on the basics of web3 and blockchain. But if you prefer written material, <a href="https://www.mckinsey.com/featured-insights/mckinsey-explainers/what-is-web3">here’s</a> an article that summarizes it all.</p><p><strong>The Exit Ramp</strong></p><p>Now you know what you’ve gotten yourself into, and fortunately, you can go back to the good old internet and enjoy your life. You can now casually mention blockchain at social gatherings and you’ll be fine. Congratulations.</p><p>But if these “boring” resources sparked something bigger in you… you can keep going down the rabbit hole.</p><p><strong>But First, The Devs</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqYtOtewi1iaZ8k7Z9rIVw.jpeg" /></figure><p>If you’re already a dev considering transitioning into Web3, this is a sign to do it. I only started coding to get into web3, and I got in with basic HTML, CSS, and JS. Imagine what Node.js, Python, and MCP servers could do!</p><p>Most developers are building on Ethereum, and for good reason — it’s scalable, has flexible options, and opens up limitless opportunities for what you can build. Whether you decide to build on EVM (Ethereum, btw) or not, I think the <a href="https://github.com/ethereumbook/ethereumbook">Ethereum book</a> gives you all the foundations you need. Once you read it from end to end, it gets easier to understand other chains from there.</p><p>You don’t have to do it all at once — take it step by step. It all comes down to the price you’re willing to pay. That’s just the theory.</p><p><strong>Now The Practice</strong></p><p>You have a couple of options: sign up for a bootcamp (most of them are free). I recommend <a href="https://www.web3bridgeafrica.com/register">Web3Bridge</a> because that’s where I learned the foundations (seriously, I cannot recommend this enough). Or you could go the tutorial route, and <a href="https://www.youtube.com/watch?v=GWLxIYAIMqQ&amp;list=PL2-Nvp2Kn0FPH2xU3IbKrrkae-VVXs1vk">Cyfrin</a> is your guy. That’s all you need — and the docs, of course, for any bumps along the way.</p><p>If you want to build on Bitcoin, <a href="https://www.btrust.tech/">Btrust</a> is a good place to start. If you spend a lot of time on social media, stay on crypto/web3 Twitter to stay updated. I&#39;m not saying these are the only two places to build, but there are multiple chains you can branch to once you learn ethereum and /or bitcoin.</p><p>Once you grasp the basics, hackathons are a good place to start building real projects, and they happen all the time. You can check some of them out on <a href="https://dorahacks.io/hackathon">Dorahacks</a>.</p><p><strong>Final Words</strong></p><p>I understand that not everyone wants to be a builder; here are other areas to explore: trading, content, community, and all other cool stuff. I just kept this dev-focused, but I hope you can navigate from here.</p><p>All the best, and congratulations — you’re still early.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92a66286255c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Solidity Timelocks]]></title>
            <link>https://medium.com/@zarahgathoni76/understanding-solidity-timelocks-af6d4290f1b4?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/af6d4290f1b4</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Sat, 25 May 2024 14:53:35 GMT</pubDate>
            <atom:updated>2024-05-25T14:53:35.124Z</atom:updated>
            <content:encoded><![CDATA[<p>Timelocks are used to set the delays, which are used to control the execution of functions within a contract or in another contract.</p><p>Timelocks set a delay period between when a transaction is triggered and its execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*mdm_p0aUS62QIQyZ" /></figure><p>Some early implementations of timelocks can be traced to bitcoin transactions, preventing users from spending their bitcoins before a certain unix timestamp and block height is reached, a major driver of the lightning network. Using Hashed Time-Locked Contracts (HTLCs), a receiver is required to acknowledge that they have received a payment before a certain deadline for them to claim their payment.</p><p>Solidity timelocks are an essential tool in implementing control flow, security measures, and administrative roles in decentralized applications. They are mostly used for initial coin offerings and vesting, DAOs, scheduling tokens and DEFI security. This article explains how timelocks work and expounds on these use cases.</p><p>As Ethereum continues to scale, developers are coming up with creative ways to make the EVM more secure and efficient and timelocks are one way to achieve this end.</p><h3>Timelock Architecture</h3><p>A smart contract can implement timelocks using time, block numbers, or modifiers. It all depends on the contract architecture and preference.</p><p>There are basic functionalities that are implemented in solidity timelocks.</p><p>These include:</p><p><strong>Queue operations</strong> — A time contract needs to create transactions and set the delay period within which they can be executed.</p><p><strong>Execute operations</strong> — A function that can be called when the execution period is due. It should implement checks to ensure that the delay period requirements are met.</p><p><strong>Cancel operation</strong>s- To cancel operations</p><p><strong>Update timelock</strong> — To modify an existing timelock.</p><p><em>It is important that these functionalities are only callable by admins or people with specified roles.</em></p><p>In the OpenZeppelin TimeController contract, for instance, the cancel operation is only accessible to the canceller role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NY2whbKI07L4G7J3RnrHyA.png" /></figure><p>Governance systems can be as robust as the protocol needs them to be, as long as the implementation is right.</p><p>Advanced timelock contract implementations have governance contracts to control the timelock contracts. Open Zeppelin’s<a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/extensions/GovernorTimelockControl.sol"> GovernorTimelockControl</a> for instance extends the governance contract to perform the Governor’s roles as the executor and the canceller. This plays a major role in ensuring a contract’s security.</p><p>Timelocks should also incorporate the necessary state variables and modifiers to help create and implement functions and conditions.</p><h3>Use Cases of Solidity Timelocks</h3><h3>Decentralized Finance(DEFI)Security</h3><p>DEFI is one of the major applications for solidity timelocks as they play a major role in securing DEFI projects. Major DEFI protocols like compound v2, Aave, Uniswap, and SushiSwap just to mention a few use timelocks to enhance their protocol security.</p><p>Some common attacks that timelocks prevent are malicious protocol changes and Oracle price manipulation. An attacker can make protocol changes for their benefit at the price of users’ funds. Timelocks prevent this by delaying harmful executions, allowing users to move their funds before an attack happens.</p><p>Contract attackers can also manipulate Oracle prices and buy tokens at inflated prices. Since most of these attackers use flash loans to manipulate prices, having delays in flash loans makes it hard for attackers to manipulate prices this way.</p><p>In the case where a contract owner tries to carry out malicious activities, like minting excess tokens that could cause devaluing of the token, the timelock gives enough time for other protocol members to find out and this prevents such attacks from happening.</p><p>In situations where users might inevitably lose their funds, it gives them enough time to exit the protocol before an attack executes. Aave, Uniswap are examples of DEFI projects using timelocks.</p><h3>DAOs</h3><p>Decentralized Autonomous Organizations(DAOs) are a major use case for timelocks. Every DAO relies on an on-chain governance system that allows members to vote for or against a proposal. Timelocks are like an extra layer of security.</p><p>If the timelock is set to 2 days, DAO members will have enough time to react to the suggested proposal. In case of bad actor in the DAO who tries to manipulate the votes, timelock prevents proposals from executing regardless of whether a quorum is reached. This is enough time for community members to notice such mishaps and come up with a mitigation plan.</p><p>Decisions within DAOs can also be set to later dates preventing users from making hasty decisions. DAOs can also create a governance contract to control and adjust timelocks.</p><p>An example of this is the OpenZeppelin TimeController, which takes ownership of the contract and takes in the DAO as the sole proposer. Proposals with controlled timeframes protect the users. DAOs are an essential part of every decentralized governance or anything that requires multiple decision-makers that can be trusted for different roles including but not limited to upgrading contracts.</p><h3>Initial Coin Offerings and Vesting</h3><p>Launching tokens can use timelocks to set a specific time for token distribution. These schedules provide an effective way for tokens to come into the market.</p><p>Token vesting periods also known as token lockup periods are especially important in sustaining a token’s economy. Token vesting ensures that most of the tokens are held by investors instead of selling them out as soon as the sale starts.</p><h3>Timelocks Best Practices</h3><p>Here are some best practices when implementing timelocks:</p><p><strong>Multi-signature approval</strong>: Have several authorities approve vital transactions to ensure contract security.</p><p><strong>Fixed delay periods</strong>. Having a constant delay period prevents the manipulation of lock periods by malicious actors.</p><p><strong>Testing and audit</strong>- Smart contracts should be thoroughly tested and audited to detect any vulnerabilities before sending them on-chain.</p><p><strong>Logging events</strong>- For significant timelock actions like scheduling and cancelling executions.</p><p><strong>Making the timelock upgradeable</strong>- To give room for fixing vulnerabilities and revisiting set conditions.</p><p><strong>Implementing alerts</strong> — to notify users when important actions like executing proposals are taking place.</p><h3>Conclusion</h3><p>Solidity timelocks are an essential tool in implementing control flow, security measures, and administrative roles in decentralized applications. They are mostly used for initial coin offerings and vesting, DAOs, scheduling tokens and DEFI security. This article explains how timelocks work and expounds on these use cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af6d4290f1b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy and Verify Contracts Using Foundry]]></title>
            <link>https://medium.com/@zarahgathoni76/how-to-deploy-and-verify-contracts-using-foundry-61234841b051?source=rss-13fd05408f56------2</link>
            <guid isPermaLink="false">https://medium.com/p/61234841b051</guid>
            <dc:creator><![CDATA[Zarah Gathoni]]></dc:creator>
            <pubDate>Wed, 03 Apr 2024 16:18:58 GMT</pubDate>
            <atom:updated>2024-04-03T16:18:58.789Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Foundry can be daunting at first, at least it was for me, but once I learned how to do it, I realized it was stupidly easy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqhOsdwpKmWvvcp-8unlRQ.png" /></figure><p>I’ll assume you have tried deploying smart contracts using Hardhat or Remix before and if not, that’s still okay, you can start with Foundry as well.</p><h3>Prerequisites:</h3><p>VsCode/ IDE.</p><p>Smart Contract(the one you want to deploy of course).</p><p>Linux/ WSL &amp; GitBash if you are in Windows.</p><h3><strong>Setting up the Environment</strong></h3><p>First things first, let’s <strong>set up </strong>the Foundry environment:</p><p>Skip this part if you have Foundry installed already.</p><p><strong>Step 1: </strong>Install Foundryup, the Foundry toolchain installer by running this command on your terminal:</p><pre>curl -L https://foundry.paradigm.xyz | bash</pre><p><strong>Step 2:</strong> Building Foundry:</p><p>You can use either of these two commands:</p><pre>Foundryup</pre><pre>cargo install — git https://github.com/foundry-rs/foundry — profile local — locked forge cast chisel anvil</pre><p>Congratulations, you now have Foundy installed: A successful installation should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yykZw_Ldjq1Ab1Mcx3b7fQ.png" /></figure><h3>Scaffolding a new foundry project:</h3><p>Initialize a new foundry project by running:</p><pre>forge init your_folder_name</pre><p>Open your newly created folder:</p><pre>cd your_folder_ name<br>code .</pre><p>Your folder is now populated with the default folder layout with <strong>script</strong>,<strong> src</strong>, and<strong> test</strong>.</p><p>src is for your contracts, script for your deployment scripts, and test for testing.</p><p>Create a file outside the folders above name it .env and save your private key, RPC URL, and any other private information you might need.</p><p>In my case, I was using another contract address and a constructor argument so I included it as well:</p><p>If you don’t have an RPC URL, go to<a href="https://chainlist.org/"> Chainlist</a>, select your network, and copy one of the active RPC’s. Remember to tick include testnets if you are deploying to a testnet.</p><p>Here is my sample .env:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*s61dCoONUWzP3OtzHP1vlA.png" /><figcaption>A sample env</figcaption></figure><p>Add 0x to your private key to avoid running into hex errors.</p><p>Copy your contracts in src. Feel free to delete the default counter.sol but you might as well ignore it.</p><p>Once you have your contract ready, create a script for it under scripts using the format in counter.s.sol like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1TFaguP2eO5QvMdUc7DQQ.png" /><figcaption>Deployment script</figcaption></figure><p>Let&#39;s break it down:</p><p>To populate the deployment script import your contract into the script like in <strong>line 5</strong>.</p><pre>import “../src/ChatDapp.sol”;</pre><p><strong>Line 4 </strong>is a default import and you should leave it like so.</p><p>Using the syntax in line 11, create an instance of the private key and pass it using the .envUint cheat code.</p><pre>uint privateKey = vm.envUint(“DEV_PRIVATE_KEY”);</pre><p>Check out <a href="https://book.getfoundry.sh/cheatcodes/"><strong>Foundry Book</strong></a> for more on cheat codes or check them in the <strong>vm</strong> file under <strong>lib.</strong></p><p><strong>Line 12</strong> is not necessary but just for context, I’m getting my constructor address from the env as well.</p><p><strong>Lines 13 and 14</strong> return the account associated with the private key.</p><p><strong>StartBroadcast()</strong> on <strong>line 16 </strong>creates a transaction to be signed and sent to the blockchain</p><p>Create an instance of the contract and pass any constructor arguments in the brackets. If you do not have any constructor arguments, leave it like so:</p><pre>ChatDapp chatDapp = new ChatDapp();</pre><p><strong>stopBroadcast ()</strong> stops collecting on-chain transactions.</p><p>With everything set up like this, you have everything you need to deploy your contract:</p><p>If you have not already run :</p><pre>forge build</pre><p>to ensure your code is error-free.</p><h3>Ready, Set, Deploy</h3><p>In your terminal run the following commands:</p><p><strong>To compile:</strong></p><pre>forge script script/your_script_file.sol:ScriptName</pre><p>Replace your_script_file with the name of your script file and Script name with the script’s contrac name: in this case for instance: In this case, we would write it as:</p><pre>forge script script/chat.s.sol: ChatDappScript — compile</pre><p>Chat.s.sol in the name of my deploy script</p><p>Now let us simulate a transaction before deploying it</p><p><strong>Simulate(optional)</strong></p><p><em>Replace $SEPOLIA_RPC_URL with your RPC URL.</em></p><pre>forge script script/your_script_file.sol:ScriptName — rpc-url $SEPOLIA_RPC_URL</pre><p><strong>Deploy and verify:</strong></p><pre>forge script script/your_script_file.sol:ScriptName — RPC-url $SEPOLIA_RPC_URL — broadcast — verify -vvvv</pre><p>The result of a successful deployment should include the deployed and verified contract address and a link to the explorer, in this case, etherscan sepolia explorer.</p><p>With that, you have successfully deployed and verified your contract on Foundry!</p><p>Check out the<a href="https://book.getfoundry.sh/"> <em>Foundry book </em></a>for more insight.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61234841b051" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>