<?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 Charlie Andrews-Jubelt on Medium]]></title>
        <description><![CDATA[Stories by Charlie Andrews-Jubelt on Medium]]></description>
        <link>https://medium.com/@candrewsjubelt?source=rss-795a163f1fd0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nk1-uKCOmPK67qoSDLlu4w.jpeg</url>
            <title>Stories by Charlie Andrews-Jubelt on Medium</title>
            <link>https://medium.com/@candrewsjubelt?source=rss-795a163f1fd0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:40:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@candrewsjubelt/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[Learning Resilience]]></title>
            <link>https://candrewsjubelt.medium.com/learning-resilience-aabde08b678f?source=rss-795a163f1fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/aabde08b678f</guid>
            <category><![CDATA[bit]]></category>
            <category><![CDATA[resilience]]></category>
            <dc:creator><![CDATA[Charlie Andrews-Jubelt]]></dc:creator>
            <pubDate>Fri, 18 Mar 2022 05:28:44 GMT</pubDate>
            <atom:updated>2022-03-18T05:39:29.943Z</atom:updated>
            <content:encoded><![CDATA[<h4>Surviving TBI for 5 years</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJCfoAcuMtkUmdredec3Ng.jpeg" /><figcaption>me at Spaulding Hospital in 2017. Wonderful people there.</figcaption></figure><p>Five years ago today, I fell to the ground. Hard.</p><p>My life changed in an instant, but I don’t remember it. From a few minutes before, to a day or two later, no memories.</p><p>Instead, I awoke cheerful. I was in pain, but it was just physical. I was injured, but that’s normal for an athlete. I had so much confidence that I would just bounce back.</p><p>I’d follow the same playbook that I’d seen my friends go through on social media — it would start off pretty bleak, but I’d persevere, stick with my PT, push it a little faster than my doctors wanted, soak up some likes on the pictures I posted illustrating my progress, and have a killer comeback story when I returned. It would be #inspiring. This was my unshakable belief.</p><p>Only, there were these weird tubes sprouting out of the back of my head. What was up with those?</p><p>And why was my mom visiting, anyway? Wasn’t she supposed to be in New Mexico? And what were my friends from out of town doing there? And my ex?</p><p>I told them all how excited I was about how I’d done on American Ninja Warrior. They exchanged looks. I paid no mind to it.</p><p>Speaking of ninja warrior, where did the camera crew and producers go? Hadn’t they just been with us for the backstory shoot when it happened?</p><p>There was no single moment when I gained a full appreciation of what happened to me. This was a mercy, because what happened was gory and awful.</p><p>Instead, I learned about it from friends and family, and from the 16 different medical specialists I visited over the following two years. Unexpected and horrifying, I also saw parts of my own accident played on TV. But mostly, I learned from an exhaustive exploration of my own body and mind. A detailed accounting of what skills were dampened, and what I could improve.</p><p>It is difficult, even after five years, to summarize my accident. It was a severe traumatic brain injury. I was given only a few percent chance of survival, let alone a full physical and cognitive recovery. I saw horrors during that time, and lived through some myself.</p><p>One memory that sticks out to me was a waiting room for a surgical followup. This was no ordinary surgeon’s office, it was a neurosurgeon. So when I sat down with a head that looked like a baseball, I didn’t get a second glance from anyone. I sat near a man who was there with his caretaker, seated before a walker and wearing a helmet. Of all these things — the caretaker, the walker, and the helmet — the helmet was the thing that made my stomach lurch. Not because it reminded me that wearing one would have prevented my injury — though I’ve thought about that countless times. No, it was because in a neurosurgeon’s office, wearing a helmet means they left out part of your skull when they stitched you back up, to prevent any swelling from squeezing your brain and re-injuring or killing you. It meant he had it worse than I did — possibly far worse. The man wept openly, and his caretaker continued to read her magazine. He had a long road ahead of him. I hope he made it.</p><p>By contrast, my recovery was miraculous, by all accounts. They thought I’d die, but I didn’t. Then they weren’t sure if I’d be able to see, but I could. They thought I’d be in the ICU for months, but I was out of the hospital in about a week.</p><p>This is not to say it was easy. Anything but. I failed to draw a clock correctly. My hands were clumsy and inarticulate. I walked into things, and lost my balance. I dumped a full glass of milk on my lap when I first tried to drink without a sippy cup. Divided attention was harder than usual. I was quick to anger. I couldn’t smell (still can’t). I looked like a skeleton, could barely walk, my tailbone was broken so I couldn’t sit, and my head hurt so much I couldn’t sleep. Laying down hurt because the back of my head was a zipper. Often, I cried.</p><p>But my community had my back. My mom, who works 7 days a week as a small business owner, dropped everything to come take care of me. My sister kept our mom’s company afloat during that time, which I knew was its own act of love and support for me. Family friends I hadn’t spoken to in years stopped boarding their flight for vacation to come help me in the hospital. Others flew in to help. MIT was fantastic, allowing me to continue at whatever pace I could muster and drop whatever classes I need to with no consequence. They even put us up in an apartment with an elevator that was right near MIT Medical. My living group tried to cover my rent for that semester. Friends visited all the time, including an MIT staff member who visited every single day.</p><p>Gradually, I improved. Not fast enough to finish the season of American Ninja Warrior — that was a fantasy. But quickly enough to shock some doctors and satisfy some ever-competitive part of myself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TH1EG4eyFvCvoyrMsrXQQw.jpeg" /><figcaption>Felt good to exercise again</figcaption></figure><p>At some point they took my sutures out, and it was like unlacing a baseball. Ow. Some time after that, I convinced my mom to go home.</p><p>And then the real work began.</p><p>My doctors had told me “it’s a marathon, not a sprint,” but I didn’t believe them. My life experience had taught me that I could out-work and out-smart or out-talent most problems I’d faced. (Usually academic ones, because I was healthy and privileged.) But severe traumatic brain injury was a new kind of enemy. Working harder could just drive up the headaches — but shying away from the headaches could slow recovery.</p><p>Worse, I continued to look better — my hair grew back, and I put back on some weight I’d lost in the hospital — but not necessarily feel better. So I began to experience TBI as an invisible injury.</p><p>When you’re injured in a visible way, people know how to show up for you. But when your issue is invisible — maybe similar to severe depression or anxiety, though I won’t assume since I’ve yet to face those foes myself — it isn’t as clear to people how to come help you out. Should they ask about it? Should they not ask? The confusion reduces turnout overall. All of a sudden, I was facing 80% of the challenges as before, but with 20% of the support. It got tough.</p><p>Dear reader, you may tire of hearing about the myriad challenges of my injury. Perhaps I belabor the point. But if there’s one thing you internalize before turning away from my meandering article, remember this — an internal injury is no less difficult, and no less support-worthy than a visible one. If your friend has a TBI, show up for them. Offer a couple ideas of how you can help, or just come visit and say hi. Set a reminder on your calendar and visit in a couple weeks. Do something nice for their caretaker. Don’t worry about doing the wrong thing, they won’t care that much. The effort will come through.</p><p>There was one day when I had to leave a playwriting class because it was getting too loud, and my headaches were getting worse. My exit was somewhat obtrusive, since the door was right next to the stage — I had literally made a scene. I laid down on a couch just outside, and thought of how awkward it was to leave at that point. Of how I created a burden for those around me in general, and a very heavy one for those close to me. I then had a very dark thought indeed — I thought of how the best thing for them would be to remove myself from the equation.</p><p>But then, at that moment, another part of me stepped in. A new voice, one of firm resolve and unwavering compassion, said no. I would not remove myself from any equation. However broken I may be, I deserved to live. This was the voice of resilience.</p><p>This voice came from the MIT staff member who visited me every day, even after other friends started assuming I was ok. It came from when I saw my mom crying looking out the window and I realized she’d almost lost a son but she was pushing through.</p><p>But it also came from me. My resilience was not a latent ability; I’d created it. This may sound paradoxical, but I was not someone who could survive severe TBI before I survived severe TBI. I became that person who could survive, by surviving.</p><p>Since then, I’ve had a good five years. Really four years. As you’ve heard, the first was pretty terrible but I got through it.</p><p>I graduated MIT. Wow, that felt good. I met someone I really liked, and we dated for a while. I got a job, and recently I got promoted. I climbed Stand and Deliver, a hard boulder problem. I visited the Himalayas. I ran a marathon for my 26.2th birthday. I got pretty good at coding. I got pretty ok at surfing. I won a hackathon, and I’m turning it into a company.</p><p>It wasn’t about these gold-star things, though. It just feels good to live.</p><p>I wrote this whole damn blog post with a headache, but I’ll say it again — it feels really good to live.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aabde08b678f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Revo]]></title>
            <link>https://medium.com/revo-market/introducing-revo-b9706781a725?source=rss-795a163f1fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9706781a725</guid>
            <dc:creator><![CDATA[Charlie Andrews-Jubelt]]></dc:creator>
            <pubDate>Sat, 19 Feb 2022 00:24:53 GMT</pubDate>
            <atom:updated>2022-03-03T05:32:13.823Z</atom:updated>
            <content:encoded><![CDATA[<h4>The what and why of auto compounding yield farming</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nrvbng76vSyNPPIU" /><figcaption>Photo by <a href="https://unsplash.com/@karsten_wuerth?utm_source=medium&amp;utm_medium=referral">Karsten Würth</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Revo makes it easy to yield farm with compound interest at low fees.</p><p>But what does that mean?</p><p>There’s some DeFi vocabulary in there that makes Revo’s purpose less than obvious to the average person — mainly the “yield farming” part. The goal of this blog post is to explain the problem Revo solves from “first principles” — such that it requires almost no background knowledge in crypto or DeFi to understand.</p><h4>What is yield farming?</h4><p>Whenever I tell someone about Revo, they usually ask me “what is yield farming?”</p><p>Imagine you are creating a new virtual reality video game mobile app. In your game, you want people to be able to design new VR buildings and sell them to other players. You want players to be able to cash out their in-game earnings for real money, to attract top talent architects. You also want to charge a small transaction fee for every exchange, which goes to your development team so you can keep improving on the game.</p><p>In short, you need to bootstrap a new medium of exchange. To that end, you decide to launch a new token (aka cryptocurrency) on Celo, a mobile-first blockchain (since you’re building a mobile app). Call it GAME.</p><p>GAME solves a number of problems for your team out of the gate. It took less than 30 minutes to code, and because transactions all take place on the blockchain you aren’t regulated like a bank.</p><p>However, because nobody owns much GAME yet, it’s really hard for players to “cash out” — a key requirement for your platform. GAME needs more liquidity (transferability).</p><p>You decide to deposit some GAME in a liquidity pool on a Ubeswap, a decentralized exchange, in a “pair” with cUSD. This means that anyone who has cUSD can buy GAME with no intervention from your company (so you’re still not a bank), and vice-versa. Like all liquidity providers on a DEX, you get a small fee when anyone does a swap, a great side benefit that you hope will encourage other people to stake GAME and cUSD too, increasing the liquidity of your new token.</p><p>Except no one does. It takes a while for players to earn GAME on your ..game… and the price of the token is pretty volatile at first, so most people just want to cash out. How can you encourage people to stake their GAME in a liquidity pool?</p><p>The answer, of course, is free money.</p><p>You have access to the money printers for your new token, after all. You launch a “yield farming rewards” contract that sends liquidity providers free GAME as an incentive for helping provide liquidity for your platform.</p><p>Problem solved right?</p><p>Well… not really. It turns out, the rewards contract you launched, despite being an industry standard, is kind of a pain to use. In fact, it takes about two minutes of button hammering for an experienced user to get started. And once they’ve staked their LP (liquidity provider) tokens in the contract, their rewards just sit there — they don’t get reinvested in the liquidity pool automatically. So liquidity doesn’t snowball the way you wanted it to, and users providing liquidity don’t get compound interest on their investment.</p><p>TLDR: yield farms are rewards programs for encouraging liquidity between tokens. Yield farming means providing liquidity and getting rewards. There’s no compound interest by default, and the UX is relatively poor.</p><p>This is yield farming today. Well, yesterday — before Revo.</p><h4>Revo</h4><p>Revo makes it easy to get started with yield farming and earn automatic compound interest at low cost.</p><p>As a DeFi investor, I can use Revo to “zap in” from any token to a yield farm with compound interest, aka “farm bot”. That means if I just bought cUSD with Ramp, I can immediately open Revo and zap into a farm. No trading for the underlying tokens, no staking in a liquidity pool, no depositing my LPs in a rewards contract. Just one swap and I’m in.</p><p>From there, I don’t need to do anything. I can sit back and let Revo’s farm bots do the work of reinvesting my rewards back into the farm for compound interest. For high-interest farms this can double my APY, or better.</p><p>And when I’ve had enough, I can “zap out” to any token, just as easily. (I can even zap to another farm!)</p><h4>Doesn’t this exist already?</h4><p>Yes, sort of. Not really.</p><p>On Celo, there are at least two options for automatic compound interest on yield farming rewards, Autofarm and Beefy. They charge 3.5 and 4.5% interest respectively. We aren’t going to trash talk our competitors here, but that’s highway robbery.</p><p>In our research we discovered that a small portion of those fees were pretty reasonable. If deposits, compounding, and withdrawals in a farm bot were all completely free, a dishonest user could reduce the APY for other users (and increase it for themselves) with exploits known as “sandwich attacks”. These hypothetical exploits on a totally free platform are why Revo has low fees (around the price of a swap), but not zero fees.</p><p>However, the majority of Beefy and Autofarm’s fees go to governance token buybacks, which drives up the price of their governance tokens by inflating demand. We believe this creates a misaligned incentive for governance token holders to keep fees high, at the expense of UX. Why would you vote to lower fees if the fees went straight to your pockets?</p><p>Revo’s other main differentiator is zap-ins from any token. With Beefy you can zap in from one of the underlying tokens in a liquidity pool, but not from any token. So the process of getting started is still fairly painful. Autofarm does not offer zap ins.</p><p>TLDR similar solutions exist, but Revo charges about 10x lower fees and makes it faster to get started.</p><h4>How to start</h4><p>Navigate to <a href="https://revo.market/">https://revo.market</a> to get farming! Note that farming options might be limited at first.</p><p>If you’d like to learn more before you dive in, visit <a href="https://docs.revo.market/">https://docs.revo.market</a></p><p>And if you’d like to say hi, feel free to leave a comment or <a href="https://discord.gg/TBHYqgBnRj">join our discord</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9706781a725" width="1" height="1" alt=""><hr><p><a href="https://medium.com/revo-market/introducing-revo-b9706781a725">Introducing Revo</a> was originally published in <a href="https://medium.com/revo-market">Revo Market</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who Owned That Bitcoin Before You?]]></title>
            <link>https://medium.com/geekculture/who-owned-that-bitcoin-before-you-b8ce66e57a55?source=rss-795a163f1fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8ce66e57a55</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Charlie Andrews-Jubelt]]></dc:creator>
            <pubDate>Thu, 25 Mar 2021 07:02:55 GMT</pubDate>
            <atom:updated>2021-03-25T07:02:55.102Z</atom:updated>
            <content:encoded><![CDATA[<h4>Traversing bitcoin’s public ledger in Python, for beginners</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YSPL2U3DPGhwtpJu" /><figcaption>Photo by <a href="https://unsplash.com/@visuals_by_fred?utm_source=medium&amp;utm_medium=referral">Freddie Collins</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A few weeks ago I was camping in Joshua Tree with my sister and my brother-in-law, and there were three things we talked about:</p><ol><li>cryptocurrency</li><li>learning how to code</li><li>other stuff</li></ol><p>Although my sister greatly preferred #3 from the above list, this blog post is about 1 and 2, cryptocurrencies and learning how to code.</p><h3>Learning how to code is hard</h3><p>It took me several tries to learn how to code, spaced out over 8 years. My first attempt was the book <a href="https://www.amazon.com/Beginning-Programming-Dummies-Wallace-Wang/dp/0470088702">Programming for Dummies</a>, which I checked out from the library when I was in fifth grade. I quickly felt overwhelmed and ashamed, finding that a book written for “dummies” was actually quite challenging for me.</p><p>Every attempt after that, save one, was similar: I wanted to “get into coding,” but didn’t have a clear idea of what I would do with my beginner-level capabilities once I acquired them. As a result, I would always get frustrated and give up, not really seeing the point of the obscure, confusing stuff I was learning anyway.</p><p>Once I had a good motivator, though, everything changed. There was a university class that promised a cool robotics lab, and I could take it if I could just show some basic programming skills. Plus, all my friends were taking it. There was a pre-requisite class, but it looked boring. I tried one more time to teach myself how to code… and it’s my job now, and I love it. (Also, the class was really fun.)</p><h3>This article == self-learning motivation</h3><p>This article is written for people like my brother-in-law — you want to learn how to code, but you need a fun project to help motivate you. Also, for you, blockchain counts as “fun.”</p><h3>This article != Python tutorial</h3><p>There are a LOT of good Python tutorials out there, explaining how to use the basic data structures and tools the language offers. This article doesn’t do that. Instead, I hope to offer an interesting project that people can use to motivate themselves to learn stuff that can otherwise feel kind of dry and boring — like how to access fields on a Python dictionary, for instance.</p><p>Feel free to flip back and forth between this article and a more standard Python tutorial, like <a href="https://www.python.org/about/gettingstarted/">the one on the Python website</a> or <a href="https://www.codecademy.com/learn/learn-python-3">Codecademy</a>. You can read some of this, get to something you don’t know how to do, read some more of the Python tutorial with renewed interest, find the treasure, recite the incantation, feel the magic flow through you … and complete the project! That’s the dream, anyway.</p><h3>The story</h3><p>It’s more fun to work on a “story” than a “problem” or, worse, a “ticket.” (This is a big deal in <a href="https://www.atlassian.com/agile/project-management/user-stories">Agile Development</a>, which I won’t get into right now.) The story of this project is:</p><p>You just sold something on craigslist to a guy who insisted on paying you in bitcoin. You thought sure, why not, so you created a wallet, looked at some app saying he paid you, and drove away feeling trendy. Later though, doubts crept in. Why wasn’t Venmo good enough? Did the buyer have something to hide? You Google it and find out about the Silk Road, and your guilt multiplies. What if that fraction-of-a-bitcoin sitting in your account is dirty money?</p><p>Fortunately, bitcoin is a “distributed public ledger,” meaning that the history of your coin is public information. The wallet your coin came from has all the credits it has ever received encoded in the blockchain for all to see. All you have to do is find an address you’re worried about — this S<a href="https://www.coindesk.com/nearly-1b-in-bitcoin-moves-from-wallet-linked-to-silk-road">ilk Road wallet</a>, for example — and the transaction hash of your incoming payment, and you can verify whether there’s a chain of transactions between them.</p><p>There are a bunch of caveats to this, of course, but whatever. It’s a fun project that you can do with basic Python.</p><h3>Designing a solution</h3><p>One of the hardest parts of designing a technical solution to a real-world problem is knowing where to start. I can help with that.</p><p>You want to traverse bitcoin’s public ledger to prove or disprove that bitcoin from some transaction originated from a sketchy address.</p><p>To do this, you’ll need:</p><ol><li>An <a href="https://en.wikipedia.org/wiki/API">API</a> that you can provide with a transaction hash, and request two things from in return: the sender address, and the “previous transaction(s)” indicating where the sender got the money.</li><li>The ability to parse an API response, store the information, and query the API again to keep traversing the blockchain an arbitrary number of steps.</li></ol><p>That may sound like a lot. If you’re just learning programming, you probably haven’t used a web API before. Don’t give up just yet — I’ll try to break down the solution process further and share my code, which you can use if you get stuck.</p><p>Try to solve each section yourself before reading my code. It feels like a paradox sometimes, but learning how to code requires you to actively write code — just reading other people’s code won’t get you very far.</p><h3>Finding the right API</h3><p>We want an API that not only gives us the “from” addresses, but also gives us the “previous transaction hash,” which is a unique identifier of where the sender got the money to begin with. For example, if Alice paid Bob 1BTC minus fees, we’d expect something like this to show up in the public ledger:</p><pre>{<br> &#39;hash&#39;: &#39;this_transaction_hash&#39;,<br> &#39;total&#39;: 9950000,<br> &#39;fees&#39;: 50000,<br> &#39;inputs&#39;: [{<br>   &#39;prev_hash&#39;: &#39;prev_transaction_hash&#39;,<br>   &#39;output_value&#39;: 10000000,<br>   &#39;addresses&#39;: [&#39;Alice_wallet_address&#39;],<br> }],<br> &#39;outputs&#39;: [{<br>   &#39;value&#39;: 9950000,<br>   &#39;addresses&#39;: [&#39;Bob_wallet_address&#39;],<br>  }]<br>}</pre><p>(Note that the example is simplified. There are actually many more fields in a transaction object, and uglier addresses and transaction hashes. If you’re interested in what they are, or learning more about how Bitcoin works in general, I recommend <a href="https://github.com/bitcoinbook/bitcoinbook">Mastering Bitcoin</a>.)</p><p>I’ll save you the trouble of finding a website that offers the right API— <a href="https://www.blockcypher.com/dev/bitcoin/#transaction-hash-endpoint">Blockcypher</a> gives us what we need. (To find it, I just Googled bitcoin APIs and read the documentation for the top few in the results.)</p><h3>Step Zero: boring installation</h3><p>To code your own solution, you’ll need to <a href="https://www.python.org/downloads/">install Python</a>.</p><p>You should also use <a href="https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/">virtualenv</a> for all your Python projects, though it isn’t strictly necessary for this one.</p><p>Optionally, you can use <a href="https://jupyter.org/install">jupyter</a> if you’re interested in trying out a useful data science tool that lets you run a few lines of Python at a time. Jupyter works with virtual environments — you can add your virtualenv to your jupyter config by running ipython kernel install --user --name=your_env_name from your command line.</p><p>Open up a python file in your preferred IDE (Python comes with IDLE, so you can use that for now, but I prefer <a href="https://www.jetbrains.com/pycharm/">PyCharm</a>), or if you’re justing jupyter, type jupyter notebook from the command line (more detailed jupyter instructions <a href="https://jupyter.readthedocs.io/en/latest/running.html">here</a>).</p><h3>Step One: query the API for one transaction</h3><p>Yay, we get to write some code!</p><p>Remember, the end goal is to walk back in time and figure out where your bitcoin came from. The first step will be to query Blockcypher’s API for information about a single transaction.</p><p>Feel free to try this with your own transaction hash! But if you haven’t actually used bitcoin before, or the transaction hashes are annoying to find with your wallet provider, you can use this transaction hash instead: 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2</p><p>The URL to query is <a href="https://api.blockcypher.com/v1/btc/main/txs/">https://api.blockcypher.com/v1/btc/main/txs/</a>YOUR_TRANSACTION_HASH . (replace YOUR_TRANSACTION_HASH with your transaction hash).</p><p>Take a moment to try querying the API in Python before scrolling past the … below. You may need to Google how to do that, and that’s ok! Googling is part of the coding process.</p><h4>Step One Solution</h4><p>Here’s my code for querying Blockcypher’s API for a single transaction:</p><pre>import requests</pre><pre>EXAMPLE_TRANSACTION_HASH = &#39;0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2&#39;<br>response = requests.get(&#39;<a href="https://api.blockcypher.com/v1/btc/main/txs/&#39;">https://api.blockcypher.com/v1/btc/main/txs/&#39;</a> + EXAMPLE_TRANSACTION_HASH)<br>print(response.json())</pre><p>See, not bad! I imported requests , a Python module for sending HTTP requests. Then I sent a GET request to Blockcypher’s API, and provided the transaction hash for the transaction I am interested in. I printed the “json” of the response, which contains the info sent back from Blockcypher for a successful response.</p><p>Note if you got an error like ModuleNotFoundError: No module named ‘requests’ when you ran this, you need to install requests by typing pip install requests from the command line.</p><p>The result is kinda ugly, but if you paste it into a JSON formatter <a href="https://jsonformatter.curiousconcept.com/#">like this one</a> it’s more readable. For the example transaction hash it looks like this:</p><pre>{<br>   &quot;block_hash&quot;:&quot;0000000000000001b6b9a13b095e96db41c4a928b97ef2d944a9b31b2cc7bdc4&quot;,<br>   &quot;block_height&quot;:277316,<br>   &quot;block_index&quot;:64,<br>   &quot;hash&quot;:&quot;0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2&quot;,<br>   &quot;addresses&quot;:[<br>      &quot;1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK&quot;,<br>      &quot;1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA&quot;<br>   ],<br>   &quot;total&quot;:9950000,<br>   &quot;fees&quot;:50000,<br>   &quot;size&quot;:258,<br>   &quot;vsize&quot;:258,<br>   &quot;preference&quot;:&quot;high&quot;,<br>   &quot;confirmed&quot;:&quot;2013-12-27T23:11:54Z&quot;,<br>   &quot;received&quot;:&quot;2013-12-27T23:11:54Z&quot;,<br>   &quot;ver&quot;:1,<br>   &quot;double_spend&quot;:false,<br>   &quot;vin_sz&quot;:1,<br>   &quot;vout_sz&quot;:2,<br>   &quot;confirmations&quot;:398396,<br>   &quot;confidence&quot;:1,<br>   &quot;inputs&quot;:[<br>      {<br>         &quot;prev_hash&quot;:&quot;7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18&quot;,<br>         &quot;output_index&quot;:0,<br>         &quot;script&quot;:&quot;483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf&quot;,<br>         &quot;output_value&quot;:10000000,<br>         &quot;sequence&quot;:4294967295,<br>         &quot;addresses&quot;:[<br>            &quot;1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK&quot;<br>         ],<br>         &quot;script_type&quot;:&quot;pay-to-pubkey-hash&quot;,<br>         &quot;age&quot;:277298<br>      }<br>   ],<br>   &quot;outputs&quot;:[<br>      {<br>         &quot;value&quot;:1500000,<br>         &quot;script&quot;:&quot;76a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788ac&quot;,<br>         &quot;addresses&quot;:[<br>            &quot;1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA&quot;<br>         ],<br>         &quot;script_type&quot;:&quot;pay-to-pubkey-hash&quot;<br>      },<br>      {<br>         &quot;value&quot;:8450000,<br>         &quot;script&quot;:&quot;76a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac&quot;,<br>         &quot;addresses&quot;:[<br>            &quot;1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK&quot;<br>         ],<br>         &quot;script_type&quot;:&quot;pay-to-pubkey-hash&quot;<br>      }<br>   ]<br>}</pre><p>Printed out in its entirety, it looks intimidating — but remember, all we care about are two things:</p><ol><li>The prev_hash field telling you where the sender got the money, and</li><li>The addresses field telling you who the sender was.</li></ol><h3>Step Two: Get Previous Transaction Hashes from API Response</h3><p>We need to be able to traverse the public ledger backwards in time. So for each transaction, we need to get all the “previous transaction” hashes.</p><h4>What’s a previous transaction again?</h4><p>When Alice pays Bob, the “previous transaction” is the time Alice got the 1BTC from Chris that she is now paying to Bob. She may also have received 0.5BTC from Chris, and 0.5BTC from Diane, that she is combining to pay Bob — in this case there are multiple “previous transactions.”</p><h4>So how do we get previous transaction hashes from the API response?</h4><p>Take a minute to try this on your own before scrolling past the ellipses below. Hint: you’ll need to know something about dictionaries, “for loops”, and lists.</p><p>Ok, here’s my code for getting a list of previous transaction hashes from a Blockcypher transactions API response.</p><pre>transaction_info = response.json()  # Blockcypher api response<br>inputs = transaction_info[&#39;inputs&#39;]<br>prev_hashes = []<br>for elt in inputs:<br>    prev_hashes.append(elt[&#39;prev_hash&#39;])</pre><pre>print(prev_hashes)</pre><p>Note that the word “elt” is short for “element.”</p><p>If you run my codeafter assigning the response variable to a Blockcypher api response, you should see something like this printed to the console:</p><pre>[&#39;7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18&#39;]</pre><p>Woohoo! You traced your bitcoin back one transaction!</p><h3>Step Three: Get Sender Wallet Address from API Response</h3><p>The previous transaction hash is nice and all, but you want to know who the sender was. Otherwise, what’s the point of traversing back through the public ledger if you can’t see whose hands your money passed through?</p><p>For this step, try to get the sender’s wallet address from the API response. Hint: your solution should look pretty similar to the code from Step 2…</p><p>Here’s how I got the sender’s address:</p><pre>transaction_info = response.json()  # Blockcypher api response<br>inputs = transaction_info[&#39;inputs&#39;]</pre><pre>sender_addresses = []<br>for elt in inputs:<br>    sender_addresses += elt[&#39;addresses&#39;]</pre><pre>print(sender_addresses)</pre><p>There’s a small difference in how I did this from how I collected the previous transaction hashes. In particular, instead of using append to add bitcoin senders’ wallet addresses to my list, I used += . To see why, try changing it to</p><pre>sender_addresses.append(elt[&#39;addresses&#39;])</pre><p>and run the code again to see what happens. I won’t give any spoilers here; it would ruin the fun.</p><h3>Step Four: Repeat!</h3><p>This next step is to iterate on the previous three steps, namely:</p><ol><li>Query the Blockcypher API for information about a transaction,</li><li>get the previous transaction hashes from the transaction info</li><li>get the sender addresses from the transaction info.</li></ol><p>Notice that since step 2 gives us previous transaction hashes, we can query the Blockcypher API all over again for each of those transaction hashes, and then we can theoretically repeat the process indefinitely until we reach the beginning of your bitcoin’s lifecycle (when it was “minted”).</p><p>More likely though, we can only repeat our querying until Blockcypher gets annoyed with us for using their API too many times in a short time span. This is called “getting rate limited.” If you’re wondering when exactly this would happen, the answer is <a href="https://blockcypher.github.io/documentation/#:~:text=BlockCypher%20APIs%20can%20be%20used,up%20to%20600%20requests%2Fhr">here</a>. TLDR: don’t call their API more than 5 times per second or 600 times per hour.</p><p>One way you can complete this step is just dump the code from the previous steps into a big loop. I urge you to not do that. It will be a pain to read, and even more painful to debug. Instead, try writing functions for each of the previous steps:</p><ol><li>A function to query the Blockcypher API,</li><li>a function to get the previous transaction hashes from a Blockcypher API response,</li><li>and another function to get the sender addresses from a Blockcypher API response.</li></ol><p>Then you can call those functions from inside a loop (or, if you’re virtuous, another function!) to query the Blockcypher API several times and traverse the public ledger.</p><p>Again, please be respectful of Blockcypher’s <a href="https://blockcypher.github.io/documentation/#:~:text=BlockCypher%20APIs%20can%20be%20used,up%20to%20600%20requests/hr">rules</a> on how often you can query their API without paying for it. You may find this code useful for avoiding querying an API more than 5 times per second:</p><pre>import time</pre><pre>def intentionally_slow_function():<br>    time.sleep(0.2)  # waits for 0.2 seconds<br>    ...  # does other stuff</pre><p>One more hint: you may want to use a “queue” of transaction hashes that you want to query Blockcypher’s API for one at a time.</p><p>Ok, now go give it a shot! Let’s see what you come up with :)</p><p>Alright, here’s how I completed this step, where we traversed the public ledger and collected a list of wallet addresses your bitcoin passed through on its way to you.</p><pre>num_transactions_back = 0<br>addresses_seen = set()<br>transaction_queue = [EXAMPLE_TRANSACTION_HASH]<br>while num_transactions_back &lt; 10 and len(transaction_queue) &gt; 0:<br>    transaction_info = get_transaction_info_blockcypher(transaction_queue.pop(0))<br>    transaction_queue += get_prev_hashes(transaction_info)<br>    sender_addresses = get_sender_addresses(transaction_info)<br>    addresses_seen.update(sender_addresses)<br>    num_transactions_back += 1</pre><p>My algorithm is pretty simple. Inside the loop, I:</p><ul><li>pop a transaction hash off a queue</li><li>query blockcypher’s api</li><li>add the sender addresses to a set</li><li>add previous transaction hashes to a queue to explore next</li></ul><p>I exit the loop as soon as:</p><ul><li>I have queried Blockcypher 10 times, or</li><li>my queue is empty</li></ul><p>I am only traversing the public ledger 10 steps back because I want to be able to run my code several times per hour before I get rate limited by Blockcypher. If my bitcoin went through more than 10 people since it was in a sketchy person’s hands, I guess I’m fine with that. (If I wasn’t fine with it though, I could always pay Blockcypher for the ability to dig deeper, or download the public ledger myself.)</p><p>If you’re wondering where these magical functions like get_transaction_info_blockcypher , get_prev_hashes , and get_sender_addresses come from, good question! I defined them earlier in my code, and I leave their implementation as an exercise to the reader :). (It should be pretty easy to piece together from reading steps 1, 2, and 3 above.)</p><h3>Step Five: Check if payer was sketchy</h3><p>The last step is to use the set (or list) of wallet addresses your money has passed through and compare it to a value of some wallet that you are hoping wasn’t included in that set.</p><p>Since we only went back ten steps in the example, you could theoretically just do this with a visual scan. But, for the sake of argument, let’s say your bitcoin went through MANY wallets before it got to yours, and you cared to check every single one of those against a known “bad wallet” address. You can use 1HQ3Go3ggs8pFnXuHVHRytPCq5fGG8Hbhx as the bad address for this step. (It’s <a href="https://www.coindesk.com/nearly-1b-in-bitcoin-moves-from-wallet-linked-to-silk-road">reportedly linked to the Silk Road</a>.)</p><p>This step should be pretty straightforward if you’ve made it this far. Go ahead, give it a shot!</p><pre>SILK_ROAD_ADDRESS = &#39;1HQ3Go3ggs8pFnXuHVHRytPCq5fGG8Hbhx&#39;</pre><pre>funds_from_silk_road = SILK_ROAD_ADDRESS in addresses_seen<br>print(f&#39;You do {&quot;&quot; if funds_from_silk_road else &quot;not (as far as we know) &quot;}have funds from silk road!&#39;)</pre><p>Ok, I got a bit fancy there and used an “<a href="https://realpython.com/python-f-strings/">f-string</a>” and a <a href="https://docs.python.org/3/reference/expressions.html#conditional-expressions">conditional expression</a>. But the idea was simple: my program checked if a string was in a set of strings, and used that to decide what to print out as a result.</p><h3>What just happened?</h3><p>In this project, we used a few basic Python programming concepts to do something cool: to check whether some bitcoin we received was linked to the Silk Road (at least, within the last few transactions).</p><p>If you enjoyed this project, and you’re hoping to ride the wave of motivation to learn more about coding and/or cryptocurrencies, I see a couple ways to extend it that could be fun:</p><ul><li>Given a pair of wallet addresses, determine whether the two parties ever transacted with each other (via those particular wallet addresses).</li><li>Given a pair of wallet addresses, determine how many “degrees of separation” there are between the wallets. (Oh look, we have the same bitcoin great-grandparent! Did you sell a craigslist item to Tony back in 2018 too?)</li><li>Produce a plot of the “leaky bucket” of bitcoin transaction fees from the last 10 or so transactions tracing back from when your bitcoin arrived in your account.</li></ul><p>I’m sure there are more fun projects in this area that I haven’t thought of — if you think of any, please comment and let me know!</p><p>Additionally, if you had trouble understanding any part of this article, please let me know so I can rethink, revise, and improve it for other learners.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8ce66e57a55" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/who-owned-that-bitcoin-before-you-b8ce66e57a55">Who Owned That Bitcoin Before You?</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>