<?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 Clemens Ley on Medium]]></title>
        <description><![CDATA[Stories by Clemens Ley on Medium]]></description>
        <link>https://medium.com/@clemensley?source=rss-d4d6a6965351------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cP_VXLOpvQacmGTi.jpeg</url>
            <title>Stories by Clemens Ley on Medium</title>
            <link>https://medium.com/@clemensley?source=rss-d4d6a6965351------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 12:23:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@clemensley/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[Can Smart Contracts Scale?]]></title>
            <link>https://coinsbench.com/can-smart-contracts-scale-b495b692e973?source=rss-d4d6a6965351------2</link>
            <guid isPermaLink="false">https://medium.com/p/b495b692e973</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Clemens Ley]]></dc:creator>
            <pubDate>Sat, 22 Feb 2025 22:18:40 GMT</pubDate>
            <atom:updated>2025-02-26T16:20:12.144Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ho1YZYaO-1jfhch83FHZ6g.jpeg" /></figure><h3>Perfect Parallelization Equals Unlimited Scale</h3><p>Parallel algorithms have an almost magical property: If an application depends only on perfectly parallel algorithms, it can scale without limit simply by adding more hardware.</p><p>Conversely, if an application relies on algorithms that cannot be parallelized, its throughput is constrained by the performance of the most powerful processor available at any given moment, and it can only scale when more advanced hardware becomes available.</p><p>It is currently unknown whether all tractable algorithms can be evaluated in parallel (this is known as the <em>P = NC</em> question), but most suspect that this is not the case.</p><h3>Parallelization Might Be The Only Way To Scale In The Future</h3><p>As hardware advanced, parallelization became essential for scaling. In the late 20th century, processor performance improved with smaller transistors that consumed less power and operated faster. This enabled manufacturers to raise clock speeds without increasing power consumption, fueling exponential performance growth and upholding Moore’s Law for decades.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dX7gPUA5KPDNN0Y1.jpeg" /><figcaption><a href="https://x.com/FutureJurvetson/status/1863649174358831312">https://x.com/FutureJurvetson/status/1863649174358831312</a></figcaption></figure><p>When transistors approached atomic scale, “Dennard scaling” began to break down. At this scale, electrons tunnel through closed transistors, causing leakage currents and increased heat generation. These effects raise power consumption and make it difficult to reliably determine whether a transistor is open or closed. As a result, further miniaturization became impractical, prompting a pivotal shift in the industry’s focus from increasing clock speeds to adopting multi-core architectures.</p><p>While single-core performance (referred to as single-thread performance in the image below) has plateaued, the number of cores has risen exponentially. As a result, overall transistor count — and consequently computational power — continues to grow exponentially. However, only parallel algorithms can fully harness this growth in computational power if it continues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*08BQyZTSHE44Z2fq.png" /><figcaption><a href="https://www.researchgate.net/figure/years-of-microprocessor-trend-data-96-57-63_fig1_343096513">https://www.researchgate.net/figure/years-of-microprocessor-trend-data-96-57-63_fig1_343096513</a></figcaption></figure><h3>Can Payments Be Parallel?</h3><p>The degree of parallelization depends on the interactions between participants. For instance, if two users exchange payments, their balances may need to be computed sequentially to ensure neither goes negative. However, with four users — let’s call them Red, Blue, Green, and Yellow — if Red interacts only with Blue and Green interacts only with Yellow, their balances can be computed in parallel on separate cores.</p><p>The difference between the two scenarios is reflected in the transaction graph of a UTXO-based blockchain: In the first example, the transaction graph forms a single connected component. In the second, it consists of two separate components — one for Red and Blue, and another for Green and Yellow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H_Q717aNo2PbW-vv.jpeg" /></figure><p>A transaction graph. Outer boxes are transactions, inner boxes are outputs, arrows are the spending relations of inputs, and colors encode output ownership. The image shows a transaction graph for the second example. The top row shows three coinbase transactions mined by users Red, Yellow, and Green. The second transaction on the left is Red sending 25 Bitcoin to Blue.</p><p>The parallelizability of payments largely depends on the structure of the transaction graph. We conjecture that if the transaction graph is shallow (with all chains being at most poly-logarithmic in the number of transactions), syncing a node falls within the highly parallel class <em>NC</em>. Otherwise, it belongs to <em>P</em> — tractable but not necessarily parallel.</p><p>Evaluating programs in parallel depends on identifying independent operations — those that can be executed simultaneously without affecting the overall outcome. These dependencies are captured in a dependency graph, which is created before execution, without knowledge of the input values. Two operations can only be considered parallelizable if they are independent for <em>all</em> possible inputs.</p><p>A transaction graph, on the other hand, is generated after a program is executed with specific inputs. It reflects the actual dependencies observed during execution, enabling a higher degree of parallelism. Operations can be considered parallelizable if they are independent for the specific inputs used. While originating differently, techniques for parallelizing program execution based on dependency graphs can inspire optimizations for node synchronization within transaction graphs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*thqWuQSqb2HdRB0e.jpeg" /><figcaption><a href="https://gfxcourses.stanford.edu/cs149/fall24/lecture/dataparallel/slide_5">https://gfxcourses.stanford.edu/cs149/fall24/lecture/dataparallel/slide_5</a></figcaption></figure><p>The UTXO model is ideal because the transaction graph contains valuable information about how the node synchronization process can be parallelized.</p><h3>Why Parallelizing Ethereum Is Hard</h3><p>While parts of Ethereum’s syncing process, such as downloading blocks and verifying signatures, can be parallelized, state synchronization presents a significant challenge:</p><ol><li>The state update of one transaction can depend on any preceding transaction, and the Ethereum transaction model provides no indication of which transactions depend on which prior ones.</li><li>The state of the Ethereum Virtual Machine (EVM) is represented as a single, large tree structure known as the state trie. Smaller, disjoint data structures are more conducive to parallel evaluation.</li><li>Smart contracts on Ethereum can call other contracts via their addresses, creating non-local dependencies that are difficult to parallelize.</li><li>The presence of gas introduces the need for complex rollback logic, further complicating the construction of a dependency graph.</li><li>Instead of referring to a specific version of a contract’s state, function calls refer to the latest state on-chain. Since the state can be modified by other transactions before a given transaction is executed, predicting the effect of a transaction becomes impossible.</li></ol><p>Ethereum developers aimed to unlock greater scalability through parallelism by partitioning the state into disjoint shards that could be processed independently. An additional beacon chain was designed to facilitate the crux of parallelization: cross-shard communication. However, the beacon chain became a bottleneck, leading the Ethereum roadmap to shift its focus from sharding to scaling via L2s.</p><h3>Are L2s The Solution Or Bridges To Nowhere?</h3><p>Some L2s achieve high throughput by introducing trusted third parties, thereby forgoing the main benefit of blockchains. Since scaling a trusted system is a fundamentally different problem, we will not address this approach here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pgJXI3wBUDfi4l6o.png" /><figcaption><a href="https://bitcoin.org/bitcoin.pdf">https://bitcoin.org/bitcoin.pdf</a></figcaption></figure><p>Trustless L2s typically rely on Zero Knowledge (ZK) proofs. The idea is that a centralized system performs the computation off-chain, and only a proof of correct computation is verified on-chain. This reduces the computational load on the main chain and overall work, as only one L2 operator needs to perform the computation, rather than multiple L1 validators.</p><p>However, these advantages do not translate to increased throughput per L2. Since most L2s rely on variants of the EVM, which are similarly serial, L2 operators cannot scale beyond the capabilities of the most powerful available hardware. To make matters worse, L2 operators not only need to evaluate the code but also must generate a proof that the computation was executed correctly. This proof generation overhead effectively reduces the throughput per L2.</p><p>Obviously, multiple L2s offer more throughput than a single one, just as multiple shards provide more throughput than one. The key to parallelizing algorithms lies in inter-shard (or inter-L2) communication. This communication is expected to be facilitated by bridges. It remains to be seen whether trustless bridges can perform this crucial task efficiently or if they will become a bottleneck, like the beacon chain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4jV6hdbgfMfgfV8v.jpeg" /></figure><p>We have seen that some blockchains parallelize well but only support payments (the UTXO model), while others support decentralized applications but do not parallelize efficiently (the account model).</p><p><em>The question is: can we achieve the best of both worlds? Can we create blockchains that support decentralized applications while also parallelizing efficiently?</em></p><h3>Meta Protocols Are Likely Parallel</h3><p><a href="https://docs.bitcoincomputer.io/comparison/#meta-protocols">Meta protocols</a> for UTXO-based blockchains (such as Ordinals, Runes, and the Bitcoin Computer) add metadata to transactions and compute values for the outputs based on this metadata. We call a meta protocol to be <em>well-designed</em> if the values computed for the outputs depend solely on the metadata and the values computed for the outputs spent via inputs. Ordinals and the Bitcoin Computer are examples of well-designed protocols.</p><p>What makes well-designed protocols special is that their data flow mirrors the flow of satoshis in the UTXO model. As a result, they naturally support parallelization through their transaction graphs. This approach combines the scalability benefits of the UTXO model with the ability to build decentralized applications through smart contracts.</p><h3>Meta Protocols Can Be Turing Complete</h3><p>Meta protocols have traditionally been designed to support specific use cases; for example, Ordinals support NFTs and Runes support fungible tokens. The Bitcoin Computer, however, uses expressions from a Turing-complete language (JavaScript) as metadata, enabling the creation of general-purpose applications. Values are computed by evaluating the expressions, with the (free) variables substituted by the values computed for the inputs. The transactions are carefully designed to capture the dependencies between these expressions. This approach seamlessly integrates programming capabilities into the UTXO model, creating a Turing-complete protocol. You can find more information on how it works <a href="https://docs.bitcoincomputer.io/how-it-works/">here</a>.</p><p>The image below illustrates two different ways to compute the expression <em>1*1 + 2*2 + 3*3</em> with the Bitcoin Computer. The transaction graph on the left allows a high level of parallelism but requires several transactions. In contrast, the transaction graph on the right uses fewer transactions but permits less parallelism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mpSIGSDo5m-nl6sb.jpeg" /></figure><p>We extend the visual syntax from the last example by adding an expression to each transaction, labelling the output with the value computed by that expression, and lablelling the spending relations with the variables of the expression.</p><p>While the Bitcoin Computer does not perform an analysis to determine how to evaluate an expression effectively in parallel, parallelism often emerges naturally in many examples. For instance, an NFT that is sent from user to user forms its own connected component, which can be evaluated independently of other NFTs. When two NFTs are swapped, their components connect, reflecting the dependency in the computation.</p><p>We did not initially focus on parallelizability; our goal was simply to combine a programming language with the UTXO model in a straightforward way. In doing so, we inadvertently sidestepped the issues that make Ethereum difficult to parallelize:</p><ol><li>The transactions are designed to capture the dependencies of the JavaScript expression they are associated with, enabling parallelization through the transaction graph.</li><li>Instead of storing all data in one giant tree structure, the state is composed of many small graphs that can be evaluated independently.</li><li>To address the issue of non-local access patterns, we use a smart contract language with strong encapsulation, where a function call can only access objects through references. Any two objects can interact, but they must first be “introduced” to one another, such as by passing one object as an argument into a function call on another object. This interaction is captured in a transaction that connects the two components in the transaction graph.</li><li>Because the Bitcoin Computer uses client-side validation, it does not require a notion of gas. In fact, programs of arbitrary complexity can be executed with a low, fixed transaction fee, typically about twice the fee of a payment.</li><li>When a function is called, the user can refer to a specific version of an object’s state. If the state is updated by another call before the transaction is included, the update will fail without incurring any costs. The user can then try again, referring to the updated state. This gives the users complete predictability over the effect of their calls.</li></ol><p>As a consequence, smart contract executions are naturally sharded: Two smart contract instances that do not depend on one another will have disjoint transaction graphs and can be evaluated in parallel. <em>Unlike with shards or L2s, where a prediction must be made in advance about which objects will interact (and thus need to be placed on specific shards or L2s), the parallelization schedule can emerge dynamically from how the system is used.</em></p><p>Additionally, users do not compete for resources: if one user runs a smart contract that requires a large amount of compute, it does not impact other users. In contrast, on the EVM, whether on L1 or L2, if one user runs a compute-intensive smart contract, that user’s activity will increase the cost for others.</p><p><em>If you enjoyed this article, please like it and share it with your friends. The </em><a href="https://bitcoincomputer.io/"><em>Bitcoin Computer</em></a><em> has many unique properties that will interest the broader cryptocurrency community. After quietly building for almost 7 years, we are excited to share more about how the Bitcoin Computer works and what makes it special. If you want to stay updated, follow us for more articles like this.</em></p><p><a href="https://bitcoincomputer.io/">bitcoincomputer.io</a></p><p><a href="https://t.me/BitcoinComputer">Telegram</a></p><p><a href="https://x.com/BTC_Computer/">X</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b495b692e973" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/can-smart-contracts-scale-b495b692e973">Can Smart Contracts Scale?</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build a Token on Bitcoin in Javascript]]></title>
            <link>https://medium.com/@clemensley/how-to-build-a-token-on-bitcoin-in-javascript-c2439cf1b273?source=rss-d4d6a6965351------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2439cf1b273</guid>
            <dc:creator><![CDATA[Clemens Ley]]></dc:creator>
            <pubDate>Fri, 25 Sep 2020 08:12:18 GMT</pubDate>
            <atom:updated>2023-12-10T07:54:27.696Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains a simple and extensible way to build fungible tokens on Bitcoin. We cover how to write a token smart contract in Javascript and how to mint and send tokens.</p><p>We use the <a href="http://bitcoincomputer.io/">Bitcoin Computer</a>, a smart contract system for Bitcoin and Litecoin (available on <a href="https://www.npmjs.com/package/@bitcoin-computer/lib">Npm</a> and <a href="https://github.com/bitcoin-computer/monorepo">Github</a>).</p><h3>The Smart Contract</h3><p>A smart contract for the Bitcoin Computer is a Javascript ES6 class.</p><pre>class Token {<br>  constructor(supply, name, pubKey) {<br>    this.coins = supply<br>    this.name = name<br>    this._owners = [pubKey]<br>  }</pre><pre>  send(amount, to) {<br>    if (this.coins &lt; amount) throw new Error()<br>    this.coins -= amount<br>    return new Token(amount, this.name, to)<br>  }<br>}</pre><p>The constructor of the Token class creates an object that stores the supply and name of the token. The property _owners is a keyword in smart contracts and setting it guarantees that only the holder of the private key corresponding topubKey can send tokens initially.</p><p>The send function checks whether the amount of tokens in the current object is sufficient to cover the number of tokens to be sent. It throws an error if insufficient funds are detected. Otherwise, it reduces the amount of tokens in the current object by <em>number. </em>The method returns a new Token object with amount-many tokens that are owned by the recipient to.</p><h4>Example</h4><p>The image shows the transactions that are broadcast when a token is created and transferred between users. Enclosing boxes represent transactions, colored boxes represent outputs, arrows represent spending relations. The numbers indicate the number of tokens in an output and the color represents the owner of the tokens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7FlEguQXVUiI0yorNVkog.png" /></figure><p>Note that the transactions mimic the way that Bitcoin transfers satoshi between users. Sending tokens this way costs no more than sending Bitcoin.</p><h3>Minting a Token</h3><p>Minting a token means broadcasting a transaction that records the creation of the token. To broadcast the transaction we create a wallet by instantiating the Bitcoin Computer library.</p><pre>import Computer from &#39;bitcoin-computer&#39;</pre><pre>const seed = &lt;some BIP39 seed&gt;<br>const computer = new Computer({ seed }))</pre><p>The object computer that is returned can deploy Javascript objects to the Bitcoin blockchain via its new method. The creation of the new object is recorded in a transaction.</p><pre>import Token from &#39;./token&#39;</pre><pre>const to = &#39;03223d...46d06c8dfe&#39;<br>const supply = 1000000<br>const name = &#39;Bitcoin Token&#39;<br>const token = await computer.new(Token, [supply, name, to])</pre><p>The computer.new method returns an object token that has all the properties and methods of the Token class. We call token a <a href="https://docs.bitcoincomputer.io/key-concepts-1#creating-a-smart-object"><em>smart object</em></a> because its state is backed up on the blockchain. Each smart object has a property _id that remains fixed throughout its lifecycle. It encodes the output where the object was deployed.</p><h3>Sending a Token</h3><p>The send method creates a new smart object sentToken with the given amount of tokens. A function call on a smart object is recorded in a transaction so we have to await on the function call to sign and send it.</p><pre>const amount = 50000<br>const to = &#39;03223d...46d06c8dfe&#39;<br>const sentToken = await token.send(amount, to)</pre><p>The sentToken object is also a smart object owned by to. In addition to the _id property, every smart object also has a property _rev that encodes the output where its latest state is recorded. This _rev can be sent to the recipient of the token transfer through email, a website, or any other means.</p><h3>Receiving a Token</h3><p>The computer.sync method returns the smart object stored at a given output. Receiver can pass the _rev obtained from Sender into computer.sync to compute the state of the object stored at that location.</p><pre>const id = &#39;d2242c...43ffb:0&#39;<br>const receivedToken = await computer.sync(id)<br>// expect.toEqual(receivedToken, sentToken)</pre><p>The object receivedToken has the same state as sentToken but is stored on Receiver’s machine. Receiver can inspect the state to verify that receivedToken contains the expected number of tokens. However, Receiver also needs to check that Sender has sent the correct token. After all, an attacker can deploy a counterfeit token with the same type and state. How can Receiver distinguish the official token <em>A</em> from a counterfeit token <em>B</em>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yr-hPhjGUEeCCv49C-tzww.png" /></figure><p>This problem can be solved by inspecting the _root property of the smart object. The _root property of a smart object is always set to the root of the dependency tree that is built during the evolution of a smart object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vd4FPutjCVGAXd_709BZ-g.png" /></figure><p>All three properties _id, _revand _root encode outputs. Note that the counterfeit token has a different root output than the original token. All Receiver needs to do is to check if the _root is as expected. If so Receiver can safely accept the token.</p><h3>Demo</h3><p>If you want to try it out for yourself you can download the code from <a href="https://github.com/bitcoin-computer/monorepo/tree/main/packages/fungible-token">Github</a>. The app is built to be a starting point for new token projects and to be easy to integrate into existing Javascript wallets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLXvSihImAExtiTsDmtCWQ.png" /></figure><h3>Build Your Own Token</h3><p>You can launch your own token today. No previous knowledge other than Javascript is required. There is more information in the <a href="https://docs.bitcoincomputer.io/">docs</a> and if you have any questions feel free to join our <a href="https://t.me/joinchat/FMrjOUWRuUkNuIt7zJL8tg">Telegram group</a>.</p><p><a href="http://bitcoincomputer.io/">www.bitcoincomputer.io</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2439cf1b273" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>