<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>hatem.eth</title>
        <link>https://paragraph.com/@hatem</link>
        <description>undefined</description>
        <lastBuildDate>Sat, 04 Apr 2026 05:43:48 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>hatem.eth</title>
            <url>https://storage.googleapis.com/papyrus_images/e7a818ad414e5d1d3490b590139069df68784ac4386bca6bbcc4fb52fbea500a.png</url>
            <link>https://paragraph.com/@hatem</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Solana Notes]]></title>
            <link>https://paragraph.com/@hatem/solana-notes</link>
            <guid>odMjBn0ICIoQSZJoAKH2</guid>
            <pubDate>Thu, 16 May 2024 03:17:09 GMT</pubDate>
            <description><![CDATA[Notes I put together on Solana in 2022. Lots of the ecosystem stuff is outdated now.Overviewover 60,000 tps$0.00025 transaction fees800 ms blocktimeSets of validators called clusters work together to validate client transactions. Different clusters may coexist and are identified by their genesis block. Two clusters that share the same genesis block will attempt to merge, otherwise they will ignore each other. Differs from traditional blockchains in that actions across nodes can be synchronize...]]></description>
            <content:encoded><![CDATA[<p><em>Notes I put together on Solana in 2022. Lots of the ecosystem stuff is outdated now.</em></p><h2 id="h-overview" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Overview</h2><ul><li><p>over 60,000 tps</p></li><li><p>$0.00025 transaction fees</p></li><li><p>800 ms blocktime</p></li></ul><p>Sets of validators called clusters work together to validate client transactions. Different clusters may coexist and are identified by their genesis block. Two clusters that share the same genesis block will attempt to merge, otherwise they will ignore each other.</p><p>Differs from traditional blockchains in that actions across nodes can be synchronized using proof of history (PoH).</p><ul><li><p>leader creates cryptographic proof with entries that some duration has passed since the last proof</p></li><li><p>leader shares new entries with validator nodes which verify those proofs</p></li><li><p>verifiable timestamps allow entries to arrive at validators in any order since the validators can reconstruct their order</p></li><li><p>&quot;blocks&quot; are a set of entries that have been confirmed together.</p></li><li><p>validator nodes optimistically process transactions in entries and roll back changes in the event that consensus wasn&apos;t achieved.</p></li></ul><h3 id="h-miscellaneous" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Miscellaneous</h3><ul><li><p>end users can create atomic transactions to multiple programs. On Ethereum this is only possible through a smart contract router.</p></li><li><p>account model was designed to be easily parallelized</p><ul><li><p><em>programs</em> are <em>completely immutable</em> accounts that store executable byte code. Programs store their state in non-executable accounts.</p></li><li><p>Accounts can specify an owner which is the only program allowed to make modifications to the account</p></li><li><p>to parallelize transactions, transactions specify all the accounts they will read from or write to so that validators know ahead of time which transactions can be parallelized and which conflict. Enabling programs to store data in different accounts allows devs to optimize for parallelization so that as many transactions can be parallelized as possible.</p></li></ul></li><li><p>transaction signatures</p><ul><li><p>an array of signatures is passed to solana transactions so if on chain programs are looking for more than one signature (say for a multisig wallet), all the signatures can efficiently be verified by a GPU instead of within a program</p></li></ul></li><li><p><code>recentBlockhash</code> vs <code>nonce</code></p><ul><li><p>solana transactions sign a recent blockhash and old transactions cannot be verified. This solves the same problem as an Ethereum nonce while also ensuring old transactions can&apos;t be run</p></li></ul></li><li><p>sol transfers</p><ul><li><p>there&apos;s a solana program, the system program, which allows users to transfer sol</p></li></ul></li><li><p>transactions roughly have a fixed cost and there is a limit to the compute cost a transaction can use</p></li><li><p>solana <code>instructions</code> (think Ethereum tx data) are commands for on chain programs. Transactions can include multiple instructions (executed atomically). The encoded size of a transaction is 1232 bytes so instructions cannot become too large.</p></li><li><p>solana has special programs for deploying programs and transferring sol.</p></li><li><p>account ownership</p><ul><li><p>all accounts have an owner. By default their owner is the system program. When a program owns an account it is able to change its data. When an program does not own an account, it can merely read the account&apos;s data</p></li></ul></li></ul><p><strong>Terminology</strong></p><ul><li><p>Account: record on the ledger that holds data or is an executable program</p></li><li><p>Bank State: state of all programs on the ledger at a given tick height</p></li><li><p>entry: an entry on the ledger which is either a tick or a transaction entry. Blocks consist of entries which are smaller smaller batches of transactions.</p></li><li><p>tick: an entry that estimates wallclock duration (timestamp)</p></li></ul><h3 id="h-usage-notes" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Usage Notes</h3><ul><li><p>super fast, feels basically instant</p></li></ul><h3 id="h-smart-contract-development-developer-tools" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Smart Contract Development + Developer Tools</h3><ul><li><p>programs compiled via <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://llvm.org/">LLVM compiler infrastructure</a> to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Executable_and_Linkable_Format">Executable and Linkable Format</a> (standard binary file format for Unix) containing <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Berkeley_Packet_Filter">Berkeley Packet Filter (BPF)</a> bytecode</p></li><li><p>smart contracts can be written in any language that can be compiled down to solana&apos;s backend. Rust is popular.</p></li></ul><h3 id="h-depositswithdrawals" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Deposits/Withdrawals</h3><ul><li><p>FTX</p></li><li><p>Coinbase</p></li></ul><h3 id="h-loginwallets" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Login/Wallets</h3><ul><li><p>magic.link</p></li><li><p>phantom</p></li></ul><h2 id="h-existing-smart-contract-infrastructure" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Existing Smart Contract Infrastructure</h2><h3 id="h-conditional-token-contracts" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Conditional Token Contracts</h3><h3 id="h-amms" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">AMMs</h3><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/solana-labs/solana-program-library/tree/master/token-swap">Token Swap Program</a></p></li></ul><h3 id="h-order-book" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Order Book</h3><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.projectserum.com/">Serum</a></p></li></ul><h3 id="h-gas-station-network" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Gas Station Network</h3><ul><li><p>we&apos;d have to create our own custom solution</p></li></ul><h3 id="h-proxy-wallets" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Proxy Wallets</h3><ul><li><p>Solana uses a proxy-wallet like architecture by default for their tokens because user token data is stored in an Account that is controlled by the program</p></li></ul><h3 id="h-oracles" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Oracles</h3><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://solana.com/ecosystem/bandprotocol">https://solana.com/ecosystem/bandprotocol</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://solana.com/ecosystem/chainlink">https://solana.com/ecosystem/chainlink</a></p></li></ul><h3 id="h-blockchain-indexers" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Blockchain Indexers</h3><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://aleph.im/#/">https://aleph.im/#/</a></p></li></ul><h3 id="h-cross-chain-communication-with-ethereum" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Cross Chain Communication with Ethereum</h3><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wormholenetwork.com/en/">https://wormholenetwork.com/en/</a> whose docs can be found <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/certusone/wormhole/blob/dev.v2/design/0001_generic_message_passing.md">here</a>.</p><ul><li><p>wormhole allows for generic message passing between solana and ethereum</p></li><li><p>network of (currently 19) guardians watches wormhole contracts. When enough guardians sign an observation, the message is then posted on the destination chain</p></li></ul></li></ul><p>Resources:</p><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.solana.com/">https://docs.solana.com/</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://2501babe.github.io/posts/solana101.html">https://2501babe.github.io/posts/solana101.html</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://solana.wiki/zh-cn/docs/ethereum-comparison/">https://solana.wiki/zh-cn/docs/ethereum-comparison/</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://dev.to/cogoo/solana-teardown-walkthrough-of-the-example-helloworld-program-18m4">https://dev.to/cogoo/solana-teardown-walkthrough-of-the-example-helloworld-program-18m4</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/solana-labs/solana-program-library">https://github.com/solana-labs/solana-program-library</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.solana.com/developing/on-chain-programs/developing-rust">https://docs.solana.com/developing/on-chain-programs/developing-rust</a></p></li></ul><h2 id="h-dev-notes" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Dev Notes</h2><h3 id="h-spl-token" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">SPL Token</h3><h3 id="h-state" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">State</h3><p>Separate accounts for</p><ul><li><p>Mint info</p><ul><li><p>defines total supply, decimals, who can optionally mint, and who can optionally freeze</p></li></ul></li><li><p>Account for each address with a token balance</p><ul><li><p>defines the owner, mint, and amount held by the account among other things</p></li></ul></li><li><p>Multisig</p><ul><li><p>struct enables many diff</p></li></ul></li></ul><h3 id="h-life-cycle" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Life Cycle</h3><ul><li><p>create an account for the new token&apos;s Mint storage. This includes creating a new key pair or passing in an existing key pair for the new account. This key pair will be one of signers of the transaction. The address of the spl token will be the owner of the account. Importantly, there is one piece of code that manages how many different tokens operate.</p><ul><li><p>creating the account includes transferring the minimum balance the account needs for 2 years of rent exemption</p></li><li><p>client specifies a fixed storage size preallocated to the account</p></li></ul></li><li><p>initialize_mint to define the account that can mint new tokens</p></li><li><p>initialize the user&apos;s account</p><ul><li><p>use <code>create_associated_token_account</code> to deterministically create an account for the user&apos;s token data</p></li><li><p>initialize the account. Write the initial data to the account.</p></li></ul></li><li><p>mint tokens to the users account</p><ul><li><p>update Mint account with the updated supply</p></li><li><p>update Account account with it&apos;s updated token amount</p></li></ul></li><li><p>transfer tokens</p><ul><li><p>if the recipient account isn&apos;t created, create an associated token account for the recipient</p><ul><li><p>use <code>create_associated_token_account</code> to create the account</p></li></ul></li><li><p>process the transfer</p><ul><li><p>ensure the Mint account of both Accounts is the same (i.e. it is the same token) and a bunch of other checks</p></li><li><p>update the balances in both accounts</p></li></ul></li></ul></li><li><p>approve an account to spend your tokens</p></li></ul>]]></content:encoded>
            <author>hatem@newsletter.paragraph.com (hatem.eth)</author>
        </item>
        <item>
            <title><![CDATA[Becoming an EVM Expert]]></title>
            <link>https://paragraph.com/@hatem/becoming-an-evm-expert</link>
            <guid>udsBj4A0My06XeDr5WZU</guid>
            <pubDate>Thu, 16 May 2024 03:12:13 GMT</pubDate>
            <description><![CDATA[Becoming an EVM Expert - The Hard WayThere’s a large learning curve to learning blockchain development because it’s so different than web2 programming paradigms. Instead of writing code that runs on one computer, you’re writing and interacting with code that runs on a distributed network To deeply understand blockchain development, we’ll want to look at the virtual machine (VM) that’s used. There’s a couple different virtual machines that different blockchain’s use including Sealevel (Solana)...]]></description>
            <content:encoded><![CDATA[<h1 id="h-becoming-an-evm-expert-the-hard-way" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Becoming an EVM Expert - The Hard Way</h1><p>There’s a large learning curve to learning blockchain development because it’s so different than web2 programming paradigms. Instead of writing code that runs on one computer, you’re writing and interacting with code that runs on a distributed network</p><p>To deeply understand blockchain development, we’ll want to look at the virtual machine (VM) that’s used. There’s a couple different virtual machines that different blockchain’s use including <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/solana-labs/sealevel-parallel-processing-thousands-of-smart-contracts-d814b378192">Sealevel</a> (Solana), <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://cosmwasm.com/">CosmWasm</a> (Cosmos), <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wiki.polkadot.network/docs/learn-wasm">Wasm</a> (Polkadot), Move VM (created by Facebook for Diem and will be used by <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://sui.io/resources-move/why-we-created-sui-move/">Sui</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://aptos.dev/guides/move-guides/move-on-aptos/">Aptos</a>).</p><p>The most popular virtual machine, though, is the Ethereum Virtual Machine or EVM. It has the largest number of applications and support from some of the largest blockchains including Ethereum, Polygon, Avalanche, Near, Optimism, and Arbitrum to name a few.</p><p>This guide is designed to get you up to speed on advanced concepts extremely quickly. It should take about 10 hours of deeply focused work to get through but you’ll come out of it with a great knowledge of the EVM.</p><h1 id="h-1-the-basics" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">1. The Basics</h1><p><em>Some of the basics to understand on Ethereum</em></p><p>For a deeper dive into most of these topics you can go to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/intro-to-ethereum/">https://ethereum.org/en/developers/docs/intro-to-ethereum/</a></p><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Public-key_cryptography"><strong>Public Key Cryptography</strong></a>: Blockchains rely on public key cryptography to prove ownership of assets and to create transactions. Public key cryptography uses a key pair which consists of a public key and a private key. The private key is kept secret and is used to digital signatures and can derive the public key.</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Cryptographic_hash_function"><strong>Hash</strong></a><strong> Function</strong>: a cryptographic function which creates a unique digital identifier (hash) for a piece of data.</p></li><li><p><strong>ether (ETH)</strong>: The native token on Ethereum which is required to pay for transaction fees.</p><ul><li><p>wei: the smallest denomination of ETH. <code>1 ETH = 10e18 wei</code></p></li><li><p>gwei. <code>1 ETH = 10e9 gwei</code>.</p></li></ul></li><li><p><strong>Ethereum Account</strong>: An entity that can send transactions. Accounts are either external owned (EOA) and controlled by a private key or they have code associated with them (i.e. it is a smart contract)</p></li><li><p><strong>Ethereum Address</strong>: The public identifier of an ethereum account is it&apos;s address. The address is the keccak256 hash of an account</p></li><li><p><strong>Walle</strong>t: a wallet is a piece of software that controls a user&apos;s private key. More advance wallets like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://metamask.io/">MetaMask</a> provide an easy way to connect to dapps and send transactions.</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/transactions/"><strong>Transaction</strong></a>: A signed instruction from an account</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/transactions/"><strong>Block</strong></a>: A batch of transactions that includes a hash of the previous block in the chain.</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/gas/"><strong>Gas</strong></a>: a unit of measure for how computationally intensive an operation is on Ethereum. The amount of gas a transaction requires is used to calculate the transaction fee a user must pay to execute a transaction.</p></li><li><p><strong>Gas Price</strong>: The amount of ETH a user pays per unit of gas to execute a transaction. Gas Price is typically measured in gwei.</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/nodes-and-clients/"><strong>Ethereum Node</strong></a>: a computer running the software for the Ethereum protocol</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.org/en/developers/docs/apis/json-rpc/"><strong>Json-RPC</strong></a>: A lightweight remote procedure protocol (RPC). Ethereum nodes an expose their json rpc api so that clients can query the state of the blockchain.</p></li></ul><p>Token Decimals: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.openzeppelin.com/contracts/2.x/erc20#a-note-on-decimals">https://docs.openzeppelin.com/contracts/2.x/erc20#a-note-on-decimals</a></p><h1 id="h-2-your-first-smart-contract" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">2. Your First Smart Contract</h1><p>We’re going to use <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://book.getfoundry.sh/">Foundry</a> to create your first smart contract. Foundry is a rust-based smart contract development toolchain created by <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/gakonst">Georgios Konstantopoulos</a> that’s new but very well liked. There’s other smart contract development environments which I’ll split into 2 categories:</p><ol><li><p>Pure Solidity: Tests are written in Solidity</p><ol><li><p>Foundry</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://dapp.tools/">DappTools</a></p></li></ol></li><li><p>Javascript Based: Tests are written in JS/TS</p><ol><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://hardhat.org/">Hardhat</a></p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://trufflesuite.com/">Truffle</a></p></li></ol></li></ol><p>For your first smart contract, we’re going to create an <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-20">ERC20</a> token which is the standard interface for fungible tokens on EVM blockchains. You won’t be expected to understand a lot of what’s happening under the hood, which is fine because we’re just trying to quickly expose you to a bunch of different concepts in EVM development.</p><h2 id="h-pre-requisites" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Pre Requisites</h2><p>Go to the Foundry <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://book.getfoundry.sh/getting-started/installation">installation page</a> and follow its directions to install Foundry. If you’re successful you should be able to run the following command.</p><pre data-type="codeBlock" text="$ forge --version
# Output should be something like
# -&gt; forge 0.2.0 (60b1919 2022-07-24T00:08:10.658215Z)
"><code>$ forge <span class="hljs-operator">-</span><span class="hljs-operator">-</span>version
# Output should be something like
# <span class="hljs-operator">-</span><span class="hljs-operator">></span> forge <span class="hljs-number">0</span><span class="hljs-number">.2</span><span class="hljs-number">.0</span> (60b1919 <span class="hljs-number">2022</span><span class="hljs-operator">-</span>07<span class="hljs-operator">-</span>24T00:08:<span class="hljs-number">10</span>.658215Z)
</code></pre><p><code>forge</code> and <code>cast</code> are the two binaries that <code>foundryup</code> installs and running <code>forge version</code> only returns the version of forge if forge is successfully installed.</p><h2 id="h-setting-up-the-project" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Setting up the Project</h2><h3 id="h-create-the-project" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Create the Project</h3><p>Follow the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://book.getfoundry.sh/getting-started/first-steps">instructions</a> in the Foundry docs to set up your first project.</p><h3 id="h-install-dependencies" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Install Dependencies</h3><p>We’re going to use <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/transmissions11">transmissions11’s</a> <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/transmissions11/solmate">Solmate</a> repo as a dependency. Solmate is a collection of common smart contracts that are helpful for using as building blocks. Solmate is gas-optimized (a.k.a. it’s written so people spend as little as possible on transaction fees) and already audited which reduces the surface area for a vulnerability and the cost of an audit for your project.</p><pre data-type="codeBlock" text="$ forge install transmissions11/solmate
"><code><span class="hljs-meta prompt_">$ </span><span class="bash">forge install transmissions11/solmate</span>
</code></pre><h3 id="h-create-the-token" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Create the Token</h3><p>Rename <code>src/Counter.sol</code> to <code>src/FirstToken.sol</code>. Open up src/FirstToken.sol in your editor and copy in:</p><pre data-type="codeBlock" text="// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

import { ERC20 } from &quot;solmate/tokens/ERC20.sol&quot;;

contract FirstToken is ERC20 {
    constructor(uint256 totalSupply) ERC20(&quot;First Token&quot;, &quot;FT&quot;, 18) {
        _mint(msg.sender, totalSupply);
    }
}
"><code><span class="hljs-comment">// SPDX-License-Identifier: UNLICENSED</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> 0.8.13;</span>

<span class="hljs-keyword">import</span> { <span class="hljs-title">ERC20</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"solmate/tokens/ERC20.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">FirstToken</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC20</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> totalSupply</span>) <span class="hljs-title">ERC20</span>(<span class="hljs-params"><span class="hljs-string">"First Token"</span>, <span class="hljs-string">"FT"</span>, <span class="hljs-number">18</span></span>) </span>{
        _mint(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span>, totalSupply);
    }
}
</code></pre><p>Let’s quickly go over what is happening in the contract.</p><ul><li><p>Line 2: The <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Directive_(programming)">pragma</a> statement specifies which version of the Solidity compiler we need to use. In this case we’ll only accept the compiler version 0.8.13</p></li><li><p>Line 4: We import the Solmate <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol">ERC20 token contract</a>. This contract is what’s doing all the work under the hood. Refer to that contract if you’re interested in how the token is implemented.</p></li><li><p>Line 6: We define our contract <code>FirstToken</code> and that it inherits from the Solmate <code>ERC20</code> contract. Contracts in Solidity are similar to classes in object-oriented languages and can inherit from one another.</p></li><li><p>Line 7: We define the constructor of the contract and call the constructor of the ERC20 contract.</p><ul><li><p>Solidity is unique in that a contract can extend multiple other contracts, and thus the atypical syntax of calling the ERC20 constructor in the constructor definition, not in a <code>super</code> call.</p></li><li><p>Our constructor accepts 1 argument <code>totalSupply</code>. The ERC20 constructor accepts 3 arguments: <code>name</code>, <code>symbol</code> and <code>decimals</code>. <code>name</code> and <code>symbol</code> are straightforward. <code>decimals</code> is the number of decimals to use in the numbers representation. Ethereum and all other blockchains I know of have no concept of floating point numbers so for more granular accuracy they just stick a bunch of zeros behind each number and refer to those as decimal points. ETH and most ERC20 tokens have 18 decimals. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48">USDC</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/token/0xdac17f958d2ee523a2206206994597c13d831ec7">USDT</a> both have 6 decimals (because fiat?) and Wrapped Bitcoin (WBTC) has 8 decimals because Bitcoin has 8 decimals.</p></li></ul></li><li><p>Line 8: We mint the <code>totalSupply</code> of tokens to the <code>msg.sender</code>, which is the account that is sending the message to create the contract.</p></li></ul><h2 id="h-deploy-the-smart-contract" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Deploy the Smart Contract</h2><p>Now that we’ve created the smart contract, we need to deploy it.</p><h3 id="h-wallet-creation" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Wallet Creation</h3><p>Before we can deploy the smart contract, we’ll have to create a wallet that we can deploy the contract from.</p><p>The simple way to create a wallet with foundry is running:</p><pre data-type="codeBlock" text="cast wallet new
"><code>cast wallet <span class="hljs-keyword">new</span>
</code></pre><p>But if you want to get creative you can run:</p><pre data-type="codeBlock" text="cast wallet vanity --starts-with &lt;prefix&gt;
"><code>cast wallet vanity <span class="hljs-operator">-</span><span class="hljs-operator">-</span>starts<span class="hljs-operator">-</span>with <span class="hljs-operator">&#x3C;</span>prefix<span class="hljs-operator">></span>
</code></pre><p>This command will search for a private key that matches an address that starts with <code>&lt;prefix&gt;</code>. Not that <code>&lt;prefix&gt;</code> must be valid hex (i.e. valid characters include 0-9 and a-f only). Note that the longer the prefix is, the more attempts it will take the script to find a valid address that fulfills your vanity requirements. From my experience, anything under 4 characters will return instantly, 5 characters will take about 20-40s and each successive character will take an order of magnitude longer (it’s 16x harder to be exact). The exact times you’ll see will depend on the specs of the machine you run this on.</p><p> 💡 Keep your private key safe. Anyone with access to this private key can access any funds in your wallet. It’s recommended to not keep a lot of funds in a hot wallet like this.</p><h3 id="h-fund-the-wallet" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0"><strong>Fund the Wallet</strong></h3><p>We’ll need to fund the wallet before we can send a transaction to it. To accomplish this, we’ll use a “faucet” which see send us testnet tokens. Go to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://faucet.paradigm.xyz/">https://faucet.paradigm.xyz/</a> and claim tokens from the faucet to the wallet you created in the previous step.</p><p><strong>Check the wallet is funded</strong></p><p>We’re going to deploy the contract on Ethereum’s Goerli testnet so go to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerli.etherscan.io/">https://goerli.etherscan.io/</a> and search for the wallet address you previously created. After claiming tokens from the faucet you should see that it has an Ether balance.</p><p>You should also run:</p><pre data-type="codeBlock" text="cast balance --rpc-url https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161 \
    &lt;your_address&gt;
"><code>cast balance <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rpc<span class="hljs-operator">-</span>url https:<span class="hljs-comment">//goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161 \</span>
    <span class="hljs-operator">&#x3C;</span>your_address<span class="hljs-operator">></span>
</code></pre><p>You should notice that there are a lot more 0s behind your ETH balance when running this CLI command.</p><h3 id="h-deploy" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Deploy</h3><p>Now let’s deploy the contract. Run the following command:</p><pre data-type="codeBlock" text="forge create --rpc-url &lt;your_rpc_url&gt; --private-key &lt;your_private_key&gt; \ 
    src/FirstToken.sol:FirstToken \
  --constructor-args 1000000000000000000000000
"><code>forge create <span class="hljs-operator">-</span><span class="hljs-operator">-</span>rpc<span class="hljs-operator">-</span>url <span class="hljs-operator">&#x3C;</span>your_rpc_url<span class="hljs-operator">></span> <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-keyword">private</span><span class="hljs-operator">-</span>key <span class="hljs-operator">&#x3C;</span>your_private_key<span class="hljs-operator">></span> \ 
    src<span class="hljs-operator">/</span>FirstToken.sol:FirstToken \
  <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-function"><span class="hljs-keyword">constructor</span>-<span class="hljs-title">args</span> 1000000000000000000000000
</span></code></pre><p>Replace <code>&lt;your_rpc_url&gt;</code> with <code>https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161</code> and with the private key you previously created. This will create a token with a total supply of 100,000 (assuming I counted correctly). If you go to the etherscan link for your account that deployed the contract, you’ll notice your balance is shown under the “Erc20 Token Txns” Tabs (e.g. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://goerli.etherscan.io/address/0x8404a542298827022bf4441afef0a96766be7201#tokentxns">https://goerli.etherscan.io/address/0x8404a542298827022bf4441afef0a96766be7201#tokentxns</a> for account <code>0x8404A542298827022bf4441Afef0a96766Be7201</code> on Goerli) <strong>Peeking Under the Hood</strong> Let’s take a look at what’s happening under the hood. Go back to Goerli etherscan and look up the transaction you just sent. Find the parameter on the transaction called “Input Data” (often just called “data” or “input”). You may have to expand more properties on the transaction to see it. Now open up the <code>out/FirstToken.sol/FirstToken.json</code> file in your repo. The “Input Data” on the transaction should look similar to the <code>bytecode.object</code> field in the file. Next, look up the address of the contract you just created. Click on the “Contract” tab and you should see the deployed bytecode of the contract. This value should look similar to the <code>deployedBytecode.object</code> property within the FirstToken.json file. Interacting with your Contract Now that you’ve deployed your first contract, let’s interact with it. <strong>Checking Your Balance</strong> First we need to get the calldata to check your balance cast calldata &quot;balanceOf(address)&quot; &lt;your_eoa_address&gt;
If you look closely at the calldata, you’ll notice that there’s 8 digits after the “0x” prefix at the start of it and the last 40 characters are from your address. Now that we have the calldata run: cast call --rpc-url https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161 \
    &lt;your_contract_address&gt; &lt;call_data&gt;
The output of the previous command is a bunch of hex jargon so let’s make it a little easier to read: cast --to-dec &lt;hex_output&gt;
You should see the same number you passed into the constructor when creating the contract. <strong>Transferring the Token</strong> Let’s now transfer some of your token to another address. Run the following command: cast send --rpc-url https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161 \ 
    --private-key  &lt;your_private_key&gt; \
   &lt;your_contract_address&gt; \
   &quot;transfer(address,uint)&quot; 0x6666664c7d32A5577070EB846f7dFa5f962e5e6a 1000000000000000
This will transfer tokens to my address <code>0x6666664c7d32A5577070EB846f7dFa5f962e5e6a</code>. Replace this address with an address you control if you want to keep all the tokens for yourself. 3. Read Up on EVM Read the Ethereum <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ethereum.github.io/yellowpaper/paper.pdf">Yellow Paper</a>. The Ethereum Yellow Paper is the technical specification for Ethereum and is probably the quickest way to understand how the EVM works at a granular level. The yellow paper is super dense but understanding sections 4-7 are super useful to understand. Feel free to skim/skip all the proofs. 4. Analyzing ERC20 Contracts Lastly, we’ll analyze 2 different implementations of the ERC20 standard. The first is the Solmate contract that we used in part 2. The second is a contract written entirely in <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.soliditylang.org/en/v0.8.15/yul.html">Yul</a>, which is a low-level EVM language. Yul is often used for highly optimized contracts in terms of gas efficiency. Analyzing the contract will help us understand what’s happening under the hood when looking at a Solidity contract. Solmate: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol">https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol</a> ERC20 in Yul: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.soliditylang.org/en/v0.8.15/yul.html#complete-erc20-example">https://docs.soliditylang.org/en/v0.8.15/yul.html#complete-erc20-example</a></p>]]></content:encoded>
            <author>hatem@newsletter.paragraph.com (hatem.eth)</author>
        </item>
        <item>
            <title><![CDATA[Bringing Web3 to the Masses: Account Abstraction]]></title>
            <link>https://paragraph.com/@hatem/bringing-web3-to-the-masses-account-abstraction</link>
            <guid>PxO6cyEhLXF6udzkPGwB</guid>
            <pubDate>Tue, 26 Sep 2023 15:12:29 GMT</pubDate>
            <description><![CDATA[In a decade we are going to look back on Externally owned accounts (EOAs), blockchain accounts controlled by a private key, as primitive. With an EOA, if you lose your private key, all your assets are lost. You’ll need a native token on every chain you use to pay for gas, and many transactions require multiple steps (e.g. submitting an approval transaction before a swap). The user experience is clunky. Account abstraction (AA) has been hot recently because it’s an order of magnitude improveme...]]></description>
            <content:encoded><![CDATA[<p>In a decade we are going to look back on Externally owned accounts (EOAs), blockchain accounts controlled by a private key, as primitive. With an EOA, if you lose your private key, all your assets are lost. You’ll need a native token on every chain you use to pay for gas, and many transactions require multiple steps (e.g. submitting an approval transaction before a swap). The user experience is clunky.</p><p>Account abstraction (AA) has been hot recently because it’s an order of magnitude improvement over plain-old EOAs. Yet, even with all its hype, it is often misunderstood. AA is often referred to synonymously with smart contract wallets and gasless transactions which has been a great marketing play although a little misleading. Let’s dive into what AA and smart contract wallets are and then explore the benefits and challenges of each.</p><h3 id="h-whats-what" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">What’s What</h3><p>Before we can understand AA, we’ll need to go over the two types of accounts on EVM blockchains. First, there are EOAs which include the wallets of most existing crypto users. When users sign up for a wallet like MetaMask or Phantom, they’ll write down a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">seed phrase</a> which is used to derive their private keys. Those private keys can sign transactions, which the wallet submits to a blockchain.</p><p>The other type of account is a contract account, an account with associated code. Examples of contract accounts include NFTs and DeFi protocols, which are often composed of multiple contract accounts.</p><p>Both EOAs and contract accounts have limitations. EOAs cannot have code associated with them and contract accounts cannot initiate transactions. Account Abstraction, in its pure form, will remove the limitations of each. EOAs will have code and contract accounts will be able to submit transactions, hence the name “account abstraction.”</p><p>Account abstraction is often referred to synonymously with smart contract wallets and gasless transactions due to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-4337">EIP4337</a>, but as previously mentioned, it is sometimes misleading. Let’s define each:</p><ul><li><p>Smart Contract Wallet: A contract account that is used as a wallet. The code in the associated account will define the wallet’s policy for sending transactions which often requires a signed message from a user.</p></li><li><p>Gasless transaction: The technical term here is <em>meta-transaction</em> which is a signed instruction from a user that is executed on-chain by another account. The transaction still includes gas, but from the user’s perspective it is gasless because the user is not the one dealing with gas.</p></li></ul><p>Smart contract wallets and gasless transactions have been around for years and are yet to have widespread adoption. We’ll cover gasless transactions further in the next article, but let’s go over the benefits of drawbacks of smart contract wallets before looking at how AA can improve upon plain old smart contract wallets.</p><h3 id="h-smart-contract-wallet-scorecard" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Smart Contract Wallet Scorecard</h3><h4 id="h-benefits" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Benefits</h4><h5 id="h-gasless-transactions" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Gasless transactions</h5><p>Most smart contract wallets support gasless transactions where a user can sign a message authorizing a transaction and then another entity can submit that transaction for the user.</p><h5 id="h-batch-transactions" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Batch transactions</h5><p>Send multiple transactions at once. For instance, instead of sending an approval transaction, waiting, and then finally submitting a swap, you can send both transactions at once.</p><h5 id="h-social-recovery" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Social Recovery</h5><p>A decentralized &quot;forgot your password&quot; flow. If you lose access to a private key, a few trusted friends, family or institutions can help you recover your account. Most people will likely opt for a trusted institution similar to how people use iCloud and Dropbox to back up their data, or how people use LastPass and 1Password to back up their passwords.</p><h5 id="h-session-keys" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Session Keys</h5><p>Traditionally you need to sign every transaction sent from a wallet like MetaMask. Session keys allow a user to authorize an entire session of transactions with one single click. Instead of signing a message for every transaction, you’ll authorize X amount of a token to be spent by a temporary private key living on the user’s device within a specified timeframe.</p><h5 id="h-upgrading-key-management" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Upgrading Key Management</h5><p>Users can upgrade their key management when they are ready. A user may start with a wallet controlled by 1 key that lives on their device. Then, when they are ready, they may upgrade to MPC or a hardware wallet.</p><h4 id="h-drawbacks" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Drawbacks</h4><h5 id="h-high-onboarding-cost" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">High onboarding cost</h5><p>It costs about 250k gas to deploy most smart contract wallets* on EVM blockchains. At the time of writing (gas cost is 42 gwei/gas), that’s $20 on Ethereum mainnet to onboard a user which is prohibitive for everyday users.</p><p>Onboarding costs are feasible on layer 2s and sidechains, though. It only costs about $0.02 to create a smart contract wallet on Polygon for instance.</p><p><em>*Technical note: This figure is based on the deployment cost of a minimal upgradeable proxy like the </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/safe-global/safe-contracts/blob/main/contracts/proxies/SafeProxy.sol"><em>SafeProxy</em></a><em> contract which is one of the smallest contracts you can deploy to create a new smart contract wallet.</em></p><h5 id="h-signing" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Signing</h5><p>Smart contract wallets do not have associated private keys to sign messages which makes smart contract wallets incompatible with applications that require user signatures like many on-chain order books. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-1271">EIP1271</a> was created as standard for compatibility with signature-verifying protocols, but EIP1271 is not yet well supported.</p><p>Inability to sign messages also adds complexity for applications that use off-chain signatures for web2 authentication flows like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-4361">Sign-In with Ethereum</a>.</p><p>These problems will go away over time as smart contract wallets gain adoption and smart contract wallet compatibility becomes a requirement. In the meantime, though, these problems do add friction to smart contract wallet adoption.</p><h5 id="h-different-wallets-on-different-chains" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Different Wallets on Different Chains</h5><p>Users will expect their wallet to be the same on every chain but wallet addresses and implementations may differ between different chains. Due to nuances between different EVM implementations (e.g. support for both <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a> transactions and pre-EIP-155 transactions), smart contract wallets may have different addresses on different chains if developers do not set them up correctly*.</p><p>Furthermore, smart contract wallet logic may differ across different chains. Most smart contract wallets can be upgraded (e.g. upgrading key management, upgrading the code of the contract) which will need to be kept consistent across different chains.</p><p>I suspect this problem will be solved off-chain. A potentially clean, decentralized solution for this would be to track upgrades to wallets on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.arweave.org/">Arweave</a>, a permanent storage ledger, and then upgrade wallet logic on specific chains as needed. All wallets would stay up to date without users paying for upgrades on dormant wallets.</p><p><em>*Technical note: contracts can be deployed on the same address on different chains using the </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-1014"><em>create2 opcode</em></a><em> which deploys contracts to a deterministic address based on the sender’s address, a salt (i.e. arbitrary data), and the to-be-deployed contract’s bytecode. If the sender’s address or bytecode are different on different chains, then the smart contract wallet will have a different address.</em></p><p><em>Typically contract deployments use a </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/safe-global/safe-singleton-factory"><em>singleton factory</em></a><em> to deterministically deploy contracts, which must be deployed at the same address on every chain to keep the sender address consistent. Some </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/Arachnid/deterministic-deployment-proxy"><em>singleton factories</em></a><em> use pre-EIP-155 transactions so that a single signed transaction can be submitted on any chain, but some EVM implementations do not support pre-EIP-155 transactions. The downside of the first mentioned singleton factory is that projects must trust the Safe team to properly safeguard their private key used to deploy it.</em></p><h3 id="h-why-aa" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Why AA</h3><p>Pure AA, allowing EOAs to upgrade into contract accounts, has the potential to solve the two main drawbacks of smart contract wallets: onboarding costs and signing. Users will be able to create a wallet without the friction of an expensive contract deployment and then upgrade to a smart contract wallet when they are ready.</p><p>Regarding signing, if a smart contract wallet has a private key associated with its public address, that private key can be used. There are potential issues in this case if a user transitions control of their wallet to another key, but it would still lead to compatibility with more protocols while EIP1271 gains adoption.</p><p>Lastly, pure AA solves the potential issue with different addresses on different chains because the public address on different chains would be derived from the original private key.</p><h3 id="h-the-current-state-of-smart-contract-wallets" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">The Current State of Smart Contract Wallets</h3><p>Smart contract wallets have been around for a while. They have traditionally been used as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.coindesk.com/learn/what-is-a-multisig-wallet/">MultiSig</a> wallets where the wallet is controlled by multiple private keys and transactions are authorized in distinct steps. Signing transactions in distinct steps makes sense when the private keys are controlled by different individuals which is the case when the MultiSig is used to hold the funds of an organization, but it’s a clunky experience for advanced users that want improved security.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://safe.global/">Safe</a> has historically been the most popular MultiSig. Smart contract wallets need to be trusted and Safe’s long history of safety and security makes it the best option. There is some risk to using an early smart contract wallet given that some have been hacked in the past (*cough cough* <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://blog.openzeppelin.com/on-the-parity-wallet-multisig-hack-405a8c12e8f7">Parity MultiSig hack</a>). New smart contract wallets will need to prove themselves over a long time period before they can reach wide adoption.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.argent.xyz/">Argent</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/authereum/an-end-and-a-new-beginning-ae0e2e596e1b">Authereum</a> were two of the earliest attempts to bring smart contract wallets mainstream but both teams have since pivoted because the deployment costs on Ethereum mainnet were (and still are) prohibitive for everyday users. Argent pivoted to focusing their wallet on Layer 2s, specifically <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.starknet.io/en">Starknet</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://zksync.io/">zkSync</a>, while the Authereum team is now behind the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://hop.exchange/">Hop bridge</a>.</p><p>Recently wallets like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://waymont.co">Waymont</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://sequence.app">Sequence</a> have created much cleaner user-experiences around MultiSigs. The former is targeted at high net worth individuals and the latter is targeted for everydays users. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://polymarket.com/">Polymarket</a> also uses smart contract wallets under the hood to offer their users gasless and batched transactions.</p><h4 id="h-eip4337" class="text-xl font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">EIP4337</h4><p>An article on smart contract wallets and account abstraction wouldn’t be complete without discussing EIP4337. EIP4337 is a standard for smart contract wallets and a design for a decentralized relayer (“bundler” in EIP4337 jargon) network.</p><p>Creating a standard for smart contract wallets is great, but I’ve long been critical of EIP4337 for <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/sam__hatem/status/1686046529008680967?s=20">creating a decentralized bundler network</a>, making the standard more complicated without an immediate benefit to users or developers. With that said, EIP4337 will help Ethereum transition to native AA. If it gains enough adoption, blockchain validators will become bundlers and vice versa.</p><p>There are a number of companies building smart contract wallets on top of EIP4337 including <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://fun.xyz/">Fun</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://zerodev.app/">ZeroDev</a>, and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.biconomy.io/">Biconomy</a>.</p><h3 id="h-looking-forward" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Looking Forward</h3><p>I expect smart contract wallets to gain significant adoption in the next couple years due to their benefits and eventually become the status quo for wallets when account abstraction is adopted in the protocol. There is an opportunity now for wallets like Metamask, Phantom, Rainbow, etc. to offer users a more secure and seamless experience by being early consumer smart contract wallets for users able to pay for their own onboarding costs.</p>]]></content:encoded>
            <author>hatem@newsletter.paragraph.com (hatem.eth)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/b39505752dd8580da50b72d87b561184dc673dec01c9adc080dc32b72de0acda.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Unlocking Web3 for the Masses: Private Key Management]]></title>
            <link>https://paragraph.com/@hatem/unlocking-web3-for-the-masses-private-key-management</link>
            <guid>dBQfHcIPzeyzeVn2OxUF</guid>
            <pubDate>Mon, 26 Jun 2023 18:59:36 GMT</pubDate>
            <description><![CDATA[To enable the average person to hold cryptoassets, we need solutions to manage private keys that are easier to use and more secure. The current solutions offer easy-to-use key management but make concessions on security and privacy. Fortunately new technology will enable private key management solutions that are still seamless but without the drawbacks of legacy solutions.Legacy SolutionsA handful of private key management solutions have been around for years including Magic Link, Web3Auth, V...]]></description>
            <content:encoded><![CDATA[<p>To enable the average person to hold cryptoassets, we need solutions to manage private keys that are easier to use and more secure. The current solutions offer easy-to-use key management but make concessions on security and privacy. Fortunately new technology will enable private key management solutions that are still seamless but without the drawbacks of legacy solutions.</p><h1 id="h-legacy-solutions" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Legacy Solutions</h1><p>A handful of private key management solutions have been around for years including <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://magic.link/">Magic Link</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://web3auth.io/">Web3Auth</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.venly.io/">Venly</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.bitski.com/">Bitski</a>. They allow users to sign in with email or OAuth (i.e. Sign in with Google) and manage private keys for users under the hood. These legacy private key management solutions offer a slick user experience and have helped onboard millions of web3 users.</p><p>These offerings do come with tail risk, though. The aforementioned services take advantage of legal gray areas to argue they are non-custodial while being able to access or lose users’ private keys. Legacy private key management services generally work by using a user’s web2 login methods to back up their private key so that on subsequent logins a user can retrieve their backed-up private key. If these services disappear or turn out to be malicious, users will lose all their assets. Yet, they can claim to be non-custodial using the guideline that users can access their private key.</p><p>A common-sense, more restrictive guideline is whether someone else has access to the user&apos;s private key. Magic Link, Bitski and Venly are all custodial under this classification–there&apos;s folks at their companies with the ability to access users’ keys. Depending on how decentralized the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://tor.us/">Torus</a> network is, which Web3Auth uses under the hood, there may be folks able to recreate Web3Auth keys as well.</p><p>An even better guideline to determine whether a service is custodial or non-custodial is whether someone else can lose the user’s private key. All four key management solutions are custodial with this guideline. For example, if Magic Link, Venly, or Bitski lost access to their AWS account (assuming they all use AWS as their cloud provider), all their users would lose access to their private keys, assuming they did not back them up prior (unlikely). As for Web3Auth, if enough Torus nodes go down, all Web3 auth users would lose their private keys (again assuming that users did not back them up prior).</p><p>State-by-state money transmission guidelines in the United States are generally created to protect consumers. When regulators look at private key management closely, they may consider the aforementioned solutions to be custodial. There’s a risk that companies providing these private key management solutions will be required to be money services businesses in the future and need to implement burdensome know your customer (KYC) processes when onboarding users.</p><p>Given risks associated with legacy private key management solutions, they are unlikely to be adopted by crypto-natives who are serious about security and censorship resistance.</p><h1 id="h-new-solutions" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">New Solutions</h1><p>There are newer solutions for private key management that look more promising. These solutions are using a combination of multi-party computation (MPC) signature schemes and secure enclaves like Intel SGX or AWS Nitro to create solutions that improve user experience and security for everyday users and cryptonatives alike. Let’s break down MPC and secure enclaves to better understand how they help.</p><p>With MPC, private keys are essentially split into multiple shares and then a predefined threshold of shares must sign a message for the signature to be valid. Imagine a 2-of-3 MPC scheme where:</p><ul><li><p>1 share is on the user’s device,</p></li><li><p>1 backup share is emailed to the user in case they ever need to recover their key, and</p></li><li><p>1 share is kept with a trusted third party who can help provide a slick user experience.</p></li></ul><p>With such a scheme, users get a slick user experience and no third party is capable of accessing or losing a user’s keys; the trusted third party only has 1 share which they can’t do anything with on their own.</p><p>Secure enclaves are isolated compute environments designed to process highly sensitive data like private keys (or private key shares). They support remote attestations which is a fancy way of saying that people can verify that the enclave is running the software they expect it to. (Remote attestations do require trusting that the server is running a secure enclave in the first place.)</p><p>Secure enclaves reduce trust assumptions. Imagine in the MPC scheme we discussed that the trusted third party is using secure enclaves. Even if an attacker was able to access 1 of a user’s shares, it’d be nearly impossible for them to hack the trusted third party.</p><p>In short, MPC removes the central point of failure that exists with legacy key management solutions (i.e. someone else can access or destroy a private key) and secure enclaves help reduce trust assumptions. Some key management solutions to look out for include <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.turnkey.io/">Turnkey</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://usecapsule.com/">Capsule</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.portalhq.io/">Portal</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://utila.io/">Utila</a>, and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.coinbase.com/cloud/products/waas">Coinbase&apos;s WaaS</a>. As these solutions are proven out, existing wallets will incorporate their tech to increase their security and user experience.</p><h1 id="h-conclusion" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h1><p>Key management options that are more secure with a great user experience are nearby. In many cases these solutions will be paired with smart contract wallets which we’ll discuss in the next post.</p><h2 id="h-technical-appendix" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Technical Appendix</h2><h3 id="h-private-keys" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Private Keys</h3><p>Private keys are random codes that can prove ownership over a public key. In most use cases, a computer generates a random private key and then uses the 3 algorithms provided by a digital signature scheme to use it.</p><ol><li><p>Get the public key for a given private key. The public key is sometimes the user’s blockchain address.</p></li><li><p>Sign a piece of data with a private key</p></li><li><p>Get the public key that signed a piece of data</p></li></ol><h3 id="h-multi-party-computation" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Multi-party Computation</h3><p>Multiparty computation (MPC) is a branch of cryptography for doing computation among untrusted parties. The term MPC is often used synonymously in web3 which threshold signature schemes, which are schemes to split up private keys among untrusted parties as we discussed above.</p><p><em>Thank you to </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/shekarramaswamy"><em>Shekar Ramaswamy</em></a><em> for the feedback on this post.</em></p>]]></content:encoded>
            <author>hatem@newsletter.paragraph.com (hatem.eth)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/ba0d43555dc61a956ff617a0544068b62eb8344c7c2004d93f840acc05dab947.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Unlocking Web3 For the Masses: Fiat-to-Crypto]]></title>
            <link>https://paragraph.com/@hatem/unlocking-web3-for-the-masses-fiat-to-crypto</link>
            <guid>MSDf5hp6jLBwZ1roWPOx</guid>
            <pubDate>Mon, 01 May 2023 15:11:39 GMT</pubDate>
            <description><![CDATA[To use web3 applications, users need an easy way to get money from their bank account or credit card into crypto. Many applications send users to exchanges like Coinbase to buy their first crypto, but moving back and forth between an app and an exchange is clunky and confusing for users. Only highly motivated users make it.Crypto On-rampsCredit card on-ramps like Moonpay, Transak, Ramp and Wyre solve onboarding for some users but have low approval rates. These can be very lucrative businesses...]]></description>
            <content:encoded><![CDATA[<p>To use web3 applications, users need an easy way to get money from their bank account or credit card into crypto. Many applications send users to exchanges like Coinbase to buy their first crypto, but moving back and forth between an app and an exchange is clunky and confusing for users. Only highly motivated users make it.</p><h3 id="h-crypto-on-ramps" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Crypto On-ramps</h3><p>Credit card on-ramps like<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.moonpay.com/"> Moonpay</a>,<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://transak.com/"> Transak</a>,<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ramp.network/"> Ramp</a> and<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.sendwyre.com/"> Wyre</a> solve onboarding for some users but have low approval rates. These can be very lucrative businesses, but many issuing banks will deny all card transactions to purchase crypto because of high historical fraud.</p><p>Local payment rails like ACH in the United States can help solve the low approval rates with card transactions. Local payment rails won&apos;t automatically deny crypto purchases, but each comes with its own nuances and development teams would need to individually integrate local fiat rails in every region they want to support.<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.sardine.ai/"> Sardine</a> and<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ratio.me/"> Ratio</a>, who have launched ACH on-ramps in the last year, can be great options to onboard users within the United States.  </p><p>On-ramps can also leverage decentralized exchanges and cross chain bridges to scale to more chains and more tokens. Currently, most on-ramps use companies like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://zerohash.com/">ZeroHash</a> or <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.primetrust.com/">Prime Trust</a> under the hood for their exchange infrastructure and as their liquidity provider so on-ramps themselves are limited by the tokens and chains their underlying exchange supports. Using decentralized exchanges and cross chain bridges can allow on-ramps to scale to new tokens and new chains quicker, giving on-ramps that do so a competitive advantage.</p><h3 id="h-nft-checkout" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">NFT Checkout</h3><p>High card decline rates for crypto on-ramps created an opportunity for NFT Checkout products, allowing people to purchase NFTs with a credit card. Card companies classify NFTs under a different merchant category code so when an issuing bank needs to approve the transaction, they see a digital good purchase, not a cryptocurrency purchase. NFT Checkout products have acceptable approval rates as a result, but they are limited to only NFTs. NFT Checkout products include <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://withpaper.com/">Paper</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.crossmint.com/">Crossmint</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wert.io/">Wert</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.usewinter.com/">Winter</a>.</p><h3 id="h-fraud" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Fraud</h3><p>Fraud is a major challenge for on-ramps and NFT checkout products. If a fraudster has someone&apos;s card information or banking details, the best opportunity for them is to cash out in an irreversible, highly liquid financial system. Due to consumer protections, the on-ramp or NFT checkout provider will be left holding the bag, making it a risky business.</p><p>Fraud is a cat-and-mouse game where fraudsters will find a new loophole and then on-ramps will need to find and patch it. It&apos;s a tough business but the companies that can successfully manage fraud will end up big winners. Helping other companies manage fraud is a great business in itself, and the best companies at managing fraud will be able to build great on-ramps.</p><p>** **</p><p>Allowing applications to easily onboard users from their credit card or bank account remains one of the toughest challenges for user experience in crypto. There isn’t a path anytime soon for a completely seamless experience going from fiat to crypto and vice versa, but the businesses that make this experience marginally better will continue to thrive.</p><p><em>Thank you to </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/demonopolize?lang=en"><em>Jack Jia</em></a><em> for his feedback on this post.</em></p>]]></content:encoded>
            <author>hatem@newsletter.paragraph.com (hatem.eth)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/137891b335ddb56d66789b89874fa33270a2081936df97e4fc81d2c49200b380.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Unlocking Web3 for the Masses: Introduction]]></title>
            <link>https://paragraph.com/@hatem/unlocking-web3-for-the-masses-introduction</link>
            <guid>1mmPjRQBFR7mqeVsZIfB</guid>
            <pubDate>Mon, 10 Apr 2023 19:32:00 GMT</pubDate>
            <description><![CDATA[Innovators have started building NFT marketplaces, prediction markets, web3 gaming applications, etc. for everyday users, but these applications are held back by the complexity of using web3. Before using a web3 application, users must set up an exchange account, buy crypto, set up a wallet, write down their seed phrase, transfer crypto to their wallet, figure out how to bridge between chains, hold a native token on every chain to pay transaction fees, and more. It&apos;s an intimidating and ...]]></description>
            <content:encoded><![CDATA[<p>Innovators have started building NFT marketplaces, prediction markets, web3 gaming applications, etc. for everyday users, but these applications are held back by the complexity of using web3. Before using a web3 application, users must set up an exchange account, buy crypto, set up a wallet, write down their seed phrase, transfer crypto to their wallet, figure out how to bridge between chains, hold a native token on every chain to pay transaction fees, and more. It&apos;s an intimidating and error-prone experience.</p><p>Having spent significant time working on web3 user experience at Slide, a company I co-founded backed by top web3 investors, and at Polymarket, where I led their gas-less transaction infrastructure, I have a deep understanding of this frontier and will be sharing my thoughts in an upcoming series of posts.</p><p>There are many exciting products and solutions emerging to improve the user experience of crypto. I&apos;ll explore these efforts across five key areas:</p><ol><li><p>Fiat to Crypto</p></li><li><p>Private Key Management</p></li><li><p>Smart Contract Wallets (Account Abstraction)</p></li><li><p>Gasless Transactions</p></li><li><p>Transaction Simulation and Security</p></li></ol><p>At a high level, user experience in crypto comes down mainly to wallets. Standalone wallets will slowly incorporate new tech in these areas, and consumer-focused applications will incorporate embedded wallets and drive new crypto users to them. Embedded wallets can be broken into two categories: end-to-end embedded wallets and application-specific wallets. </p><p>End-to-end embedded wallets are out of the box replacements for standalone, browser wallets like MetaMask and come with a UI. They are great for getting an easy to use wallet integration off the ground quickly or for an existing application to better support new web3 users without needing to build and maintain an application-specific wallet. They can also be used across different web3 applications, giving a successful end-to-end embedded wallet a powerful network effect. End-to-end embedded wallets included <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://sequence.xyz/">Sequence</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://magic.link/connect">Magic Connect</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.peaze.com/">Peaze</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.ramper.xyz/">Ramper</a>.</p><p>Application-specific wallets are wallets siloed to a specific web3 application. They provide a familiar, integrated experience for users that will boost an application&apos;s onboarding rates. Many web apps will also enjoy the control over the user experience from building their own wallet. Application-specific wallets can’t be used across many different applications like you can with MetaMask, but that’s not a benefit when onboarding new crypto users. Application specific wallets include <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.coindesk.com/web3/2022/10/19/reddit-users-open-25-million-crypto-wallets-after-launch-of-nft-marketplace/">Reddit’s wallet</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://polymarket.com/">Polymarket’s</a> login-with-email wallet.</p><p>With both of these embedded wallet options, users will log in using their email or OAuth, and a private key is generated and managed for them behind the scenes. As these wallets become more popular, mobile and browser wallets will develop ways for users to transition from embedded wallets to standalone mobile or browser wallets.</p><p>In the long term, we can expect wallets to be built into devices like mobile phones and laptops by default. Although large tech companies are beginning to explore crypto, they will probably wait for startups to prove the technology and demand before experimenting with wallets themselves. Startups have the opportunity now to build a moat before the big tech corporations jump in.</p><p>The future of web3 depends on creating a seamless and user-friendly onboarding experience. In the next post I’ll explore fiat-to-crypto in depth. Follow me on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/sam__hatem">twitter</a> to stay up to date.</p><p>** **<em>Thank you to </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/shekarramaswamy"><em>Shekar Ramaswamy</em></a><em> and </em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/Pavel_Asparagus"><em>Pavel Asparouhov</em></a><em> for the feedback on this post.</em></p>]]></content:encoded>
            <author>hatem@newsletter.paragraph.com (hatem.eth)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/c0a4e3bdaef87b3d97a7b0526a56686fbc452cc563ff0992606d86fbf8c1c7d0.png" length="0" type="image/png"/>
        </item>
    </channel>
</rss>