<?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[frak-defi - Medium]]></title>
        <description><![CDATA[Frak shares value equally between those who create and those who consume content. To create, creators need financing. To get their financing, creators need audiences. Frak is DeFi protocol that enables creators and users to get paid for content usage. - Medium]]></description>
        <link>https://medium.com/frak-defi?source=rss----8e1d9cf58914---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>frak-defi - Medium</title>
            <link>https://medium.com/frak-defi?source=rss----8e1d9cf58914---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 00:47:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/frak-defi" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Cost-Effective Blockchain Infrastructure: A Journey with eRPC and Ponder]]></title>
            <link>https://medium.com/frak-defi/building-cost-effective-blockchain-infrastructure-a-journey-with-erpc-and-ponder-e3866b0c76d7?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/e3866b0c76d7</guid>
            <category><![CDATA[ponder]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[erpc]]></category>
            <category><![CDATA[sst]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 11:55:02 GMT</pubDate>
            <atom:updated>2025-01-07T11:55:02.594Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*DD14czyaEcv4zp54WF-rhQ.png" /></figure><p>Every blockchain project starts with a dream and a limited budget. At <a href="https://frak.id/">Frak</a>, we built a platform for <strong>automated on-chain reward distribution</strong> that powers marketing campaigns through smart contracts. Running entirely on Arbitrum, our infrastructure needs to handle:</p><ul><li><strong>High-frequency events</strong>: Processing ~8 user tx per week per active user</li><li><strong>Complex queries</strong>: Real-time analytics and reward calculations</li><li><strong>Multi-contract indexing:</strong> 8 master contracts and 3 active factories (with, at the time of writing, ~100 contracts deployed).</li></ul><p>When your core business logic lives on-chain, your infrastructure needs to be bulletproof while keeping costs under control. Here’s how we built it using open-source tools.</p><h4>The Challenge</h4><p>Every blockchain application faces three core challenges:</p><ol><li>Reliable and cost-effective RPC access</li><li>Efficient event indexing and data access</li><li>Scalable infrastructure that doesn’t break the bank</li></ol><p>Most teams throw money at the problem. We took a different approach.</p><h3>eRPC: Your Chain’s Traffic Controller</h3><p><a href="https://www.erpc.cloud/">eRPC</a> is like the air traffic controller for your blockchain requests — but one that also has a photographic memory and cost-optimization superpowers. Written in Go for maximum performance, it’s a fault-tolerant EVM RPC load balancer that makes your typical proxy look like a rusty gate.</p><h4>Key Features That Made Us Choose eRPC</h4><p><strong>Intelligent Load Balancing</strong></p><ul><li>Per-method routing (because let’s face it, not all RPCs are created equal)</li><li>Project-specific configurations (different strokes for different folks)</li><li>Automatic fallback handling (because uptime is not just a nice-to-have)</li></ul><p><strong>Smart Caching</strong></p><ul><li>Reorg-aware permanent caching (no more stale data nightmares)</li><li>Method-specific cache rules (cache what matters, ignore what doesn’t)</li><li>Selector-level granularity (because sometimes you only need to cache specific contract calls)</li></ul><p><strong>Developer Experience Superpowers</strong></p><ul><li>Need to scale your dev team? Got smart contract tests hitting your RPC like a MEV bot during an airdrop? eRPC’s project system lets you:</li><li>Create dedicated environments for different teams</li><li>Implement IP-based or wallet signature auth</li><li>Configure aggressive caching for test environments</li><li>Zero config changes for developers (it just works™)</li></ul><h4>Power in Simplicity</h4><p>Want to see how easy it is to do complex things? Here’s an eRPC config that handles multi-provider load balancing, rate limiting, method-specific routing and caching:</p><pre>export default initErpcConfig({<br>    logLevel: &quot;info&quot;,<br>    database: {<br>        // Here you can list every db used (pg, redis, in memory etc), and then config which one are used depending on the type of data, or even the method used<br>        // Frak config here: https://github.com/frak-id/infra-blockchain/blob/6e907c50db2117083a113ee74e2d38d1a6b596ea/packages/erpc/src/storage.ts<br>        evmJsonRpcCache: cacheConfig,<br>    },<br>})<br>    .addRateLimiters({<br>        // Yup, you can even go in depth with per method rate limiting<br>        alchemy: [{ method: &quot;*&quot;, maxCount: 300, period: &quot;1s&quot;, waitTime: &quot;5s&quot; }],<br>        pimlico: [{ method: &quot;*&quot;, maxCount: 100, period: &quot;1s&quot;, waitTime: &quot;5s&quot; }],<br>        drpc: [{ method: &quot;*&quot;, maxCount: 100, period: &quot;1s&quot;, waitTime: &quot;5s&quot; }],<br>        // And yup, rate limits can also be applied to networks, auth strategies, projects, etc<br>        walletProject: [{ method: &quot;*&quot;, maxCount: 1000, period: &quot;1s&quot;, waitTime: &quot;5s&quot; }],<br>    })<br>    // Add a few networks to the config<br>    .decorate(&quot;networks&quot;, {<br>        arbitrum: arbNetwork,<br>        arbitrumSepolia: arbSepoliaNetwork,<br>    })<br>    // Add a few upstreams to the config<br>    // Frak upstreams config: https://github.com/frak-id/infra-blockchain/blob/main/packages/erpc/src/upstreams.ts<br>    .decorate(&quot;upstreams&quot;, {<br>        alchemy: alchemyUpstream,<br>        drpc: drpcUpstream,<br>        pimlico: pimlicoUpstream,<br>    })<br>    .addProject(({ store: { upstreams, networks } }) =&gt; ({<br>        id: &quot;wallet-rpc&quot;,<br>        // Smart routing: Pimlico for AA, Alchemy for everything else, dRPC as fallback<br>        upstreams: [<br>            upstreams.alchemy,<br>            upstreams.pimlico,<br>            upstreams.drpc<br>        ],<br>        networks: [networks.arbitrum, networks.arbitrumSepolia],<br>        // Rate limiting with the budget defined before<br>        rateLimitBudget: &quot;walletProject&quot;<br>    }))<br>    .build();</pre><p>In this example we are using the <a href="https://github.com/KONFeature/erpc-config-generator">erpc-config-generator</a> package that provide the builder pattern, you can also directly use the <a href="https://github.com/erpc/erpc/tree/main/typescript/config">erpc typescript config</a>.</p><h4>Our Production Setup</h4><p>And here’s how eRPC makes blockchain load balancing and multi-RPC routing look easy and helps us achieve virtually no downtime:</p><p><strong>Indexing Projects</strong></p><ul><li>Primary: Envio + dRPC</li><li>Fallback: Alchemy</li><li>Why? Cost optimization for high-volume historical queries</li></ul><p><strong>General Purpose (Frontend + Backend + Foundry)</strong></p><ul><li>Primary: Alchemy + Pimlico</li><li>Fallback: dRPC</li><li>Auxiliary: Free RPCs for non-critical paths</li></ul><h3>Ponder: The Indexer That Sparks Joy</h3><p>If you’ve ever wrestled with The Graph’s hosting service, <a href="https://ponder.sh/">Ponder</a> feels like a warm hug from your favorite dev tool. It’s the indexer that makes you remember why you loved blockchain development in the first place.</p><pre>// Track when a campaign distribute a reward<br>ponder.on(&quot;CampaignBanks:RewardAdded&quot;, async ({ event, context }) =&gt; {<br>    // Try to find a rewarding contract for the given event emitter<br>    const bankingContract = await context.db.find(bankingContractTable, {<br>        id: event.log.address,<br>    });<br>    if (!bankingContract) {<br>        console.error(`Banking contract not found: ${event.log.address}`);<br>        return;<br>    }<br><br>    // Update the total amount of distributed token for the rewarding contract<br>    await context.db<br>        .update(bankingContractTable, {<br>            id: event.log.address,<br>        })<br>        .set({<br>            totalDistributed:<br>                bankingContract.totalDistributed + event.args.amount,<br>        });<br><br>    // Update the current user reward (insert it if not found)<br>    await context.db<br>        .insert(rewardTable)<br>        .values({<br>            contractId: bankingContract.id,<br>            user: event.args.user,<br>            pendingAmount: event.args.amount,<br>            totalReceived: event.args.amount,<br>            totalClaimed: 0n,<br>        })<br>        .onConflictDoUpdate((current) =&gt; ({<br>            pendingAmount: current.pendingAmount + event.args.amount,<br>            totalReceived: current.totalReceived + event.args.amount,<br>        }));<br><br>    // Insert the reward event<br>    await context.db.insert(rewardAddedEventTable).values({<br>        id: event.log.id,<br>        contractId: bankingContract.id,<br>        user: event.args.user,<br>        emitter: event.args.emitter,<br>        amount: event.args.amount,<br>        txHash: event.log.transactionHash,<br>        timestamp: event.block.timestamp,<br>    });<br><br>    // Update the current campaigns stats for the distributed amount<br>    await safeIncreaseCampaignsStats({<br>        productId: bankingContract.productId,<br>        context,<br>        blockNumber: event.block.number,<br>        increments: {<br>            totalRewards: event.args.amount,<br>        },<br>    });<br>});</pre><h4>Real-World Indexing at Frak</h4><p>We’re not talking about toy contracts here. We’re indexing:</p><ul><li>8 master contracts</li><li>3 active factory contracts</li><li>On Arbitrum (hello, short block times 👋)</li><li>Complex marketing campaign tracking</li><li>Real-time statistics generation</li></ul><h4>Why Ponder Won Our Hearts</h4><p><strong>Blazing Fast Indexing</strong></p><ul><li>Reindexing that doesn’t require a coffee break</li><li>Internal caching that makes updates feel instant</li><li>Direct PostgreSQL integration that just works</li></ul><p><strong>Real-world Performance</strong></p><ul><li>Handles complex on-chain marketing campaigns</li><li>Real-time statistics generation</li><li>Shared database with Web2 backend (bye-bye, unnecessary data transfer)</li></ul><p><strong>Developer Experience That Doesn’t Suck</strong></p><ul><li>TypeScript all the way down</li><li>Built-in HTTP server via Hono</li><li>Caching and rate limiting included</li></ul><h3>Deployment: Because YOLOing to Production is So 2017</h3><p><a href="https://sst.dev/">SST</a> v3 orchestrates our entire deployment with the elegance of a perfectly executed flash loan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MsLG-cXUT1he-wl7" /></figure><h4>Infrastructure as Code Benefits</h4><ul><li>Zero-touch deployments</li><li>Version-controlled infrastructure</li><li>Easy environment replication</li><li>Pulumi under the hood (because when we eventually move to k8s, we won’t need therapy)</li></ul><h4>Open Source All The Way Down</h4><p>Every tool in our stack is open source and actively maintained:</p><ul><li><a href="https://github.com/erpc">eRPC</a>: The RPC infrastructure that scales with you</li><li><a href="https://github.com/ponder-sh/ponder">Ponder</a>: The indexer that just makes sense</li><li><a href="https://github.com/sst/sst">SST</a>: Infrastructure as code that doesn’t make you cry</li></ul><p>Want to see how it all fits together? Check out our <a href="https://github.com/frak-id/infra-blockchain">blockchain infrastructure repo</a> for the complete picture.</p><h4>Bootstrap Like a Chad, Spend Like a Bear Market</h4><p>Here’s the secret sauce for launching your blockchain infrastructure without needing a Series A: smart use of free tiers and efficient architecture. Think of it as yield farming cloud credits and RPC calls.</p><h3>The Zero-to-One Infrastructure Stack</h3><p><strong>Cloud Foundation</strong> 🌩️</p><ul><li>AWS Free Tier = 12 months of free t2.micro instances</li><li>GCP = $300 initial credits</li><li>Choose your poison, both work great with our stack</li></ul><p><strong>RPC Strategy</strong> 🔌</p><pre>.addProject({<br>  id: &quot;bootstrap-rpc&quot;,<br>  upstreams: [<br>    // Free RPCs, strategically load balanced<br>    llamaNodes,     // 25k requests/day<br>    publicNodes,    // Variable limits<br>    ankr.free,      // 20k requests/day<br>    // Add more as you grow<br>  ]<br>})</pre><p><strong>Indexing &amp; API</strong> 📊</p><ul><li>Self-hosted Ponder = $0 (runs on your free tier instance)</li><li>PostgreSQL = Free tier on cloud provider</li><li>Hono endpoints = Comes free with Ponder</li></ul><h4>Cost Breakdown for MVP</h4><ul><li>Infrastructure: $0 (cloud credits)</li><li>RPC Calls: $0 (load balanced free tiers)</li><li>Indexing: $0 (self-hosted)</li><li>Your time: Minimal (thanks to these tools)</li></ul><h4>When You’re Ready to Scale 📈</h4><p>Hit the free tier limits? Congratulations, you’ve got traction! When it’s time to graduate from farming free RPCs, check out eRPC’s <a href="https://www.erpc.cloud/aggregator">aggregator service</a>. It’s one unified endpoint for all chains with pre-negotiated provider rates. They’ll even host the eRPC instance for you if infrastructure management isn’t your thing.</p><h3>The Results</h3><p>This setup has allowed us to:</p><ul><li>Start lean (your VCs will thank you)</li><li>Scale smoothly as user base grew</li><li>Maintain high reliability</li><li>Keep infrastructure complexity manageable</li><li>Process complex on-chain marketing campaigns in real-time</li></ul><h3>What’s Next?</h3><p>While our current setup is solid, we’re exploring:</p><ul><li>Kubernetes migration for more deployment flexibility</li><li>On-premise solutions for cost optimization</li><li>Further RPC usage pattern optimization</li></ul><h3>Conclusion</h3><p>Building blockchain infrastructure doesn’t have to feel like solving a Rubik’s cube blindfolded. With <strong>open-source tools</strong> like <a href="https://www.erpc.cloud/">eRPC</a>, <a href="https://ponder.sh/">Ponder</a>, and <a href="https://sst.dev/">SST</a>, you can build a <strong>robust, scalable system</strong> that grows with your needs.</p><p>At Frak, this infrastructure powers a platform that’s revolutionizing brand advocacy:</p><ul><li><strong>Real-time reward distribution</strong> for authentic shares</li><li><strong>Transparent, cost-effective</strong> customer acquisition</li><li><strong>Direct value flow</strong> from brands to advocates</li><li><strong>Scalable word-of-mouth</strong> marketing automation</li></ul><p>The best infrastructure is like a good smart contract — it just works, and you only notice it when something goes wrong. And when <strong>87% of people</strong> read reviews before purchasing and <strong>79% trust</strong> customer reviews like friends’ recommendations, you really can’t afford for things to go wrong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3866b0c76d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/building-cost-effective-blockchain-infrastructure-a-journey-with-erpc-and-ponder-e3866b0c76d7">Building Cost-Effective Blockchain Infrastructure: A Journey with eRPC and Ponder</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Future: WebAuthN Meets ERC-4337 Smart Wallets]]></title>
            <link>https://medium.com/frak-defi/unlocking-the-future-webauthn-meets-erc-4337-smart-wallets-e472b340452b?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/e472b340452b</guid>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[account-abstraction]]></category>
            <category><![CDATA[webauthn]]></category>
            <category><![CDATA[smart-accounts]]></category>
            <category><![CDATA[passkey]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Tue, 26 Mar 2024 10:30:20 GMT</pubDate>
            <atom:updated>2024-03-26T10:30:20.429Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2IJUvzi69i9Lu9BkRjLmg.png" /></figure><p>Hey there, fellow blockchain enthusiasts and developers! 🚀 In this piece, we’re diving deep into the nitty-gritty of leveraging <strong>WebAuthN signatures for validating user operations</strong> within the exciting world of <strong>ERC-4337 smart accounts</strong>.</p><p>You might remember our initial foray into this topic, co-authored with Yoan from the Cometh team. If you haven’t checked it out yet, do yourself a favor and give it a read <a href="https://medium.com/@salvayre.yoan/passkeys-wallet-on-the-evm-69d4930ea4af">here</a>. It sets the stage for what we’re about to explore and showcases some pioneering work in the field.</p><p>Before we jump in, let’s make sure we’re all on the same page. This article assumes you’ve got a good grasp on <strong>ERC-4337</strong>, along with key concepts like <strong>Bundlers, Paymasters, SmartAccounts</strong>, and the broader idea of <strong>account abstraction</strong>. If you’re thinking, “Wait, slow down!” — no worries, we’ve got you covered. Check out these fantastic resources to get up to speed:</p><ul><li><a href="https://www.erc4337.io/docs">ERC-4337 Documentation</a></li><li><a href="https://docs.stackup.sh/docs/erc-4337-overview">ERC-4337 overview by Stackup</a></li></ul><p>Ready? Let’s get started on this adventure together!</p><h3>Context</h3><p>In our journey at <a href="https://frak.id/en">Frak Labs</a>, as we’ve previously touched upon in our collaboration with Yoan, our mission is to create blockchain tools designed with non-crypto natives in mind. One of the biggest hurdles we’ve consistently bumped into? <strong>Friction</strong>. Yep, that old nemesis. Friction is the archenemy of user acquisition. The traditional setup process — getting started with MetaMask, jotting down a seed phrase, and having to purchase tokens just to cover gas fees — can feel like running an obstacle course for newcomers.</p><p><strong>Account abstraction</strong> comes to the rescue, at least for the last bit concerning gas fees. It’s a game-changer, allowing platforms to either sponsor user operations or let users pay for transactions with the platform’s own tokens, smoothing out one significant bump on the road.</p><p>However, the current landscape for smart accounts often leans on the crutch of an existing External Owned Account (EOA), be it through MetaMask, Ledger, or a somewhat “hidden” EOA behind a Multi-Party Computation (MPC) system, like Turnkey or Web3Auth. But here’s the rub: neither option clicked for us. The first scenario still demands users to set up an EOA beforehand — a no-go for true ease of use. The second? It paradoxically forces us to depend on a centralized platform for access to decentralized goodies. Quite the conundrum, right?</p><p>This conundrum led us down a rabbit hole of research until we pioneered a novel solution that seamlessly integrates WebAuthn and account abstraction, enabling a truly frictionless onboarding experience for non-crypto natives. While solutions like Cometh’s also provided a smooth connect experience, our approach was tailored to our ecosystem, especially with our kernel accounts at the core.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*5NZ-_AfbnU63_qDakK6vTw.png" /></figure><h3>The Solution: Simpler on Paper</h3><p>On paper, the solution to our user friction problem sounds straightforward. To execute a user operation, all we need is validation, ideally without the hassle of an External Owned Account (EOA). Enter <strong>WebAuthN</strong>, the hero we’ve been looking for. It offers a neat way to secure a signature from the user for a 32-byte piece of data on the P256 curve, utilizing either their device or an external secure device that supports this curve.</p><p>So, in theory, the process should be as simple as: prepare the user’s operation, get it signed, and voila, send it off with the correct signature attached. Sounds like a dream, right? Well, as we soon discovered, reality had other plans.</p><h3>Trailblazing Integration: Cometh’s WebAuthN Breakthroughs</h3><p>Cometh has been a true <strong>pioneer</strong> in the realm of <strong>WebAuthN and blockchain integration</strong>, their innovative solutions tackling some of the most <strong>formidable challenges</strong> in this space. A pivotal breakthrough was their integration of the <strong>P256 curve</strong> — an essential component of WebAuthN signatures that was previously incompatible with blockchain environments.</p><p>Cometh, collaborating closely with <strong>Renaud Dubois from Ledger</strong> and his talented team, was the <strong>first</strong> to leverage Dubois’ optimized on-chain <strong>P256 verifier</strong>. This ingenious solution enables the blockchain to <strong>validate signatures from the P256 curve efficiently</strong>, overcoming a major compatibility hurdle without incurring prohibitive <strong>gas costs</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*0smbmXqU3N96yj3BV97sNg.png" /></figure><p>At Frak, we have built upon this <strong>groundbreaking work</strong>, introducing our own <strong>innovations</strong> to seamlessly integrate WebAuthN and the P256 curve into our Kernel smart wallet architecture.</p><p>While Cometh paved the way as the <strong>first team</strong> to utilize Dubois’ verifier, our focus has been on <strong>tailoring</strong> and <strong>enhancing</strong> the implementation to meet the unique requirements of our ecosystem. From <strong>optimizing gas costs</strong> to ensuring a <strong>frictionless user experience</strong>, we have developed <strong>novel approaches</strong> that unlock new possibilities for WebAuthN adoption within our kernel accounts and beyond.</p><h3>Navigating the P256 Curve with WebAuthN</h3><p>When it comes to integrating WebAuthN into blockchain operations, the use of the P256 curve presents a unique challenge. Contrary to what one might expect, the standard doesn’t sign the 32 bytes of data you send directly. Instead, what gets signed is essentially a “double” hash of a JSON payload containing the challenge, authenticator data, and additional verification data. This complexity is not for naught; it ensures the integrity and authenticity of the signing process, verifying that the right user, with the right device, signs off on the operation. However, this mechanism also obscures the challenge by embedding it within a JSON structure.</p><p>So, the question arises: <strong>How do we verify that the user operation hash was indeed signed by our user?</strong></p><p>The answer is less straightforward than one might hope. To achieve this, we must embrace the complexity head-on. The process involves forwarding all the relevant data from the WebAuthN signature process (authenticator and verification data) to the blockchain, ensuring the presence of the challenge within the authenticator data, and then proceeding with the “double” hash operation to verify the signature against this computed hash.</p><p>Currently, there are two prominent approaches to this challenge:</p><ul><li><a href="https://github.com/rdubois-crypto/FreshCryptoLib/tree/master"><strong>FCL Method</strong></a> (championed by Renaud Dubois): Favoured by Cometh and us, this method involves encoding the data in base64 to minimize calldata size, followed by a base64 search operation using bytes. This approach not only optimizes on-chain operations but also reduces the amount of calldata transmitted.</li><li><a href="https://github.com/daimo-eth/p256-verifier"><strong>Daimo Approach</strong></a>: This method opts to transmit all data in its original JSON format, performing an on-chain string search to locate the challenge, before reconstructing and verifying the double hash.</li></ul><p>We opted for the FCL method, tweaking it slightly to align with the specifications of our kernel validator and to further reduce gas costs for these specific use cases. This decision was driven by the perceived efficiency of the FCL method in terms of on-chain operations and calldata management. Although we have not conducted extensive benchmarks to confirm our hypothesis (pending the acceptance of a PR for benchmarking different validator types by Kernel), our preliminary analysis suggests this to be the more streamlined approach.</p><h3>Tackling Paymaster Gas Estimation</h3><p>As we peel back the layers of the user operation flow, especially when it’s sponsored, let’s sketch out what this looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTHhw8NhfGXZuSOTRFoTrQ.png" /></figure><p>At first glance, this process might seem straightforward (maybe because I’ve simplified it a bit too much, haha), but there’s a critical step that might trip us up. Not spotting it yet? Let’s take a closer look at the <strong>Paymaster data computing</strong> stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*7p3cI7NYiIVnoGyV5D19wg.png" /></figure><p>Here’s where things get tricky. The Paymaster data computation happens before we request the signature — logical, since we’re signing the entire bundle, including Paymaster data. But, how does the Paymaster predict a transaction’s cost before actually executing it?</p><p>The answer is simpler than you might think: by running a <strong>transaction simulation</strong> with the call data and a dummy signature to validate the user operation. This simulation helps estimate the gas cost, determining if the project can cover it, and then calculates all the necessary Paymaster specifics (like verification gas). The challenge, however, lies in the on-chain <strong>P256 verification</strong> and the signature formatting steps, which are gas-intensive. How do we ensure a dummy signature can navigate through these steps without causing an early exit?</p><p>Creating a dummy signature that doesn’t prematurely exit during the formatting process seemed impossible without designing a custom Paymaster contract and server specifically for this scenario — not the most ideal solution.</p><p>That’s why I introduced a <strong>bypass in the signature formatting step</strong> — yes, the double hash part. When the data is clearly incoherent, this bypass allows the process to continue as if everything were normal, directly returning the provided challenge instead of the double hash value (as you can see <a href="https://github.com/zerodevapp/kernel/blob/78b2a0e965e351c29dd7af9e75280e2f7818183f/src/validator/webauthn/WebAuthnFclVerifier.sol#L49">here</a>).</p><p>However, this bypass alone isn’t enough. We also needed a signature that wouldn’t trigger an early exit during the P256 verification step. After some exploration within the FCL contracts, we found the perfect signature to proceed.</p><p>Just when you think you’ve got it all figured out, there’s another twist. Remember our little double hash bypass? Or the fact that authenticator and verification data can’t be known in advance? Preparing a dummy signature requires packing it with enough calldata — so much so that the calldata and its parsing compensate for the bypass. And that’s how we end up with a dummy signature, brimming with <strong>uint256.max</strong> values, repeated 40 times.</p><h3>Streamlining On-Chain P256 Verification with RIP-7212</h3><p>Alright, we’ve navigated through the intricate world of WebAuthN signatures, tackled the unique challenges of integrating them with blockchain operations, and devised ways to simulate transactions accurately. So, what’s the final hurdle in our journey? The on-chain verification of P256 signatures.</p><p>P256 verification on-chain has always been a tough nut to crack. Despite the brilliant optimization efforts (huge shoutout to Renaud for his exceptional work), we’re still looking at around 200k gas for just verifying a P256 signature.</p><p>Enter <strong>RIP-7212</strong>: a beacon of hope designed to significantly reduce this cost. RIP-7212 proposes adding a pre-compiled smart contract to rollups, specifically for P256 signature verification — akin to the efficiency of <strong>ecrecover</strong> or <strong>sha256</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*k52CDQeuRIrpJpxY8hwUNw.png" /></figure><p>However, as is often the case with cutting-edge solutions, RIP-7212’s recent finalization means its widespread availability is still on the horizon (currently, it’s only operational on Polygon Mumbai). This poses a question: How do we create an immutable validator without forcing our users through a costly migration once RIP-7212 becomes universally available, especially considering we aim to avoid any validator storage access?</p><p>The solution? Introduce a new flag within our signature protocol. This flag allows users to choose between the traditional on-chain P256 verification and the new, more efficient pre-compiled verification method. Of course, attempting to use the pre-compiled verification on a chain that doesn’t support it yet will result in failure. To address this, we’ve added a simple external function to the validator that checks for pre-compile support on the chain. During the initialization of the web2 client, this function is called to verify support; if pre-compile is available, we automatically adjust the signature flag for all subsequent operations.</p><h3>Conclusion</h3><p>And there you have it — a whirlwind tour through the intricacies of integrating WebAuthN with ERC-4337 smart wallets, navigating the P256 curve, and streamlining the process with innovations like RIP-7212. It’s been a journey of discovery, challenge, and ultimately, innovation, showcasing the power of collaboration and the relentless pursuit of making blockchain technology more accessible and efficient.</p><p>If you found this deep dive enlightening, <strong>please give us a clap and share this article</strong> with your network. Your support fuels our continued exploration and sharing of breakthroughs in this exciting domain. Stay tuned for more posts as we further unravel the journey of WebAuthN implementation and its transformative potential in the blockchain ecosystem. Until then, happy coding, and let’s keep pushing the boundaries of what’s possible together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e472b340452b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/unlocking-the-future-webauthn-meets-erc-4337-smart-wallets-e472b340452b">Unlocking the Future: WebAuthN Meets ERC-4337 Smart Wallets</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Idea to Innovation: Unveiling Our WebAuthN Smart Wallet Demo]]></title>
            <link>https://medium.com/frak-defi/from-idea-to-innovation-unveiling-our-webauthn-smart-wallet-demo-4310eae5ae66?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/4310eae5ae66</guid>
            <category><![CDATA[account-abstraction]]></category>
            <category><![CDATA[erc-4337]]></category>
            <category><![CDATA[webauthn]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 15:08:16 GMT</pubDate>
            <atom:updated>2024-02-23T15:09:02.011Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*WRrrKvDmuDGDnkU10Mm3-g.png" /></figure><p>Welcome to an exciting milestone at <a href="https://frak.id/">Frak-Labs</a>! Before we unveil our latest Proof of Concept (POC) and the unique challenge it aims to tackle, let’s take a moment to revisit our roots and the journey that brought us here.</p><p>At the heart of Frak-Labs, our mission emerged from witnessing transformative shifts within the content market, initially inspired by the burgeoning creator economy. However, as we navigated through this evolving landscape, we uncovered a series of persistent challenges. Central to these was the issue of <strong>centralization</strong> — a system where intermediaries disproportionately benefited at the expense of creators and publishers, eroding the profits meant for those who actually create value.</p><p>Moreover, publishers face a slew of emerging hurdles: the impending <strong>end of cookies</strong>, an oversaturated subscription model leading to <strong>subscription fatigue</strong>, and a noticeable decline in household spending on subscriptions. These challenges not only threaten the sustainability of content publishing but also stifle innovation and fairness within the ecosystem.</p><p>Building on the success of our MVP, which introduced a novel revenue stream for content creators by rewarding users for their engagement and investment in content, we’re now setting our sights on addressing a critical question: <strong>How can we revolutionize the content publishing space?</strong></p><p>This ambition led to the creation of our latest POC, leveraging the power of WebAuthN based smart wallets and account abstraction to unlock unprecedented potential within the Frak ecosystem. Stay tuned as we unveil the details of this innovative solution, designed to empower creators and publishers alike, paving the way for a more equitable and decentralized content market.</p><p><strong>Disclaimer:</strong> This is a Proof of Concept (POC), not ready for production and runs on the Polygon Mumbai testnet. Please refrain from transferring real assets to wallet addresses, and be prepared for potential bugs. Your feedback is valuable as we work towards improvement.</p><h3>Why This POC?</h3><p><strong>High churn rates</strong> in the newspaper market sparked our initiative. Users often back away at the sight of a paywall — discouraged by the tedious steps of account creation, entering payment details, and navigating through subscriptions. Not to mention, the <strong>high fees</strong> that companies incur with each subscription add to the dilemma.</p><p>Our journey with the MVP taught us valuable lessons about <strong>user experience</strong>. We’ve been creating numerous wallets, aiming for the simplest UX possible. This experience led us to believe in a better solution.</p><p>Enter the world of <strong>smart wallets</strong> and <strong>account abstraction</strong>. This sector is on fire with innovations. Technologies like <strong>WebAuthN</strong> stand out, promising a future where accessing wallets through <strong>biometrics</strong> is streamlined, yet remains decentralized — no complex setups like MPC needed.</p><p>This sparked an idea: What if we could <strong>eliminate traditional paywalls</strong> by instantly creating wallets for users? Imagine swapping the convoluted subscription process for a quick <strong>biometric check</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*BwT263kA4_-ZMAjKAlj6RQ.png" /></figure><p>That’s the core reason behind our POC. We’re on a mission to show how blockchain technology can meet real-world needs. Imagine unlocking an article or subscribing with a few tokens — all made simple, aiming to <strong>reduce churn rates</strong> for newspapers.</p><p>Using a <strong>smart wallet</strong> for these tasks offers more than convenience. It allows for anonymous tracking of reader preferences — like favorite articles and topics — without invading privacy. As the era of cookies ends, this presents a <strong>privacy-centric solution</strong> for content providers.</p><h3>The Demo Itself</h3><p>Dive into our Proof of Concept (POC) through this hands-on demo. It’s designed to showcase the seamless integration of our technology in real-world scenarios. Here’s what makes up the demo:</p><p><strong>1. Frak-SDK</strong></p><ul><li>A <strong>simple SDK</strong> for content publishers to integrate with the Frak ecosystem easily.</li><li>Provides user-specific information for content, such as <strong>unlock status, pricing</strong>, and <strong>balance checks</strong>.</li><li><strong>Fully offchain</strong> compatibility, perfect for PWA apps distributing content with the Frak wallet installed — ensuring no connectivity issues.</li><li><strong>Secure communication</strong> through various methods including verification hashes, data obfuscation, and origin checks.</li></ul><p><strong>2. Newspaper Website</strong></p><ul><li>A straightforward implementation showcasing an article without any blockchain or external API knowledge.</li><li>Utilizes <strong>Frak-SDK</strong> to obtain real-time access information (user permissions, pricing for unlocks) and initiates the unlock process.</li></ul><p><strong>3. The Wallet Website</strong></p><ul><li>A <strong>Progressive Web App (PWA)</strong>, installable on phones for offline use.</li><li>Built using <strong>account abstraction</strong> (thanks to ZeroDev for the Kernel account, and Pimlico for the bundler and paymaster).</li><li>Account creation and transactions are <strong>WebAuthN</strong> enabled, allowing for biometric operations.</li><li>Soon to support <strong>multiple asset types</strong> and integration with WalletConnect, making it usable on any dApp in the market.</li><li>Handles <strong>Frak-SDK requests</strong>, facilitating communication with the content provider.</li></ul><p><strong>What the Demo Showcases:</strong></p><ul><li><strong>Kernel wallet</strong> creation and recovery using only biometrics — no backend required.</li><li>Wallet interactions solely through biometrics.</li><li><strong>Secure cross-domain communication</strong> client-side, enabling smooth operation on offline devices.</li><li>A glimpse into the <strong>future of content paywalls</strong>, leveraging blockchain for a frictionless user experience.</li></ul><p><strong>Visual Demonstrations:</strong></p><p>This GIF guides new users from clicking the unlock link at the bottom of an article through the intuitive setup and use of the wallet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*Z8lw8dMVfVhTlHaR_xjwNQ.gif" /></figure><p><strong>Experience the Flow Yourself:</strong></p><ol><li><strong>Start by visiting</strong> our FrakDemo Twitter account at <a href="https://twitter.com/FrakDemo">https://twitter.com/FrakDemo</a> to find a selection of article links.</li><li><strong>Click on</strong> “Unlock with FRK” after selecting an article, and then pick a pricing option.</li><li><strong>Simply follow</strong> the prompts — a seamless process requiring no more than three clicks to complete the flow (or just two clicks if you already have a wallet!).</li><li><strong>Dive into</strong> your chosen content and enjoy.</li></ol><p><strong>Additional Tips:</strong></p><ul><li><strong>Checking Your Wallet</strong>: Visit <a href="https://poc-wallet.frak.id/">poc-wallet.frak.id</a> to view your wallet. If you aren’t automatically logged in after an article unlock or purchase — something that might occur on Apple devices due to their specific sandboxing — don’t worry. Simply use the <strong>Recover wallet</strong> feature with the same passkey from the unlocking process to regain access to your wallet.</li><li><strong>What to Expect in Your Wallet</strong>: For now, the wallet page may look a bit sparse, but expect this to change dramatically in the next few weeks. You’ll currently find a <strong>history section</strong> with links to your unlocked articles. In the settings, there’s an option to <strong>acquire test FRK tokens</strong>, allowing for further exploration of the flow. Rest assured, we’re working on enriching the wallet’s functionalities and interface, aiming to significantly enhance your experience shortly.</li></ul><h3>How Does It Work Under the Hood?</h3><p>Got a flair for the technical? If you’re the kind who enjoys puzzles more complex than trying to find your way in a new city without GPS, here’s a treat. Check out our sequence flow diagram — it’s like the blueprint for a secret tech lair, minus the secret handshake: <a href="https://github.com/frak-id/wallet/blob/main/docs/graphs.md">https://github.com/frak-id/wallet/blob/main/docs/graphs.md</a></p><p>Integrating a <strong>smart wallet with a WebAuthN validator</strong> introduces complex challenges, prominently the <strong>domain lock</strong> issue, which significantly influenced our architecture:</p><ul><li><strong>Domain Lock Challenge</strong>: Passkeys are restricted to a specific domain — our case being <a href="http://frak.id/">frak.id</a>. They are only functional within this domain, affecting both their creation and use for signing transactions.</li></ul><p>This challenge led us to develop an SDK that simplifies the interaction between content providers and our wallet, making transaction initiation straightforward:</p><ul><li><strong>SDK Overview</strong>: Our SDK enables content providers to fetch user-specific details like content unlock status, pricing, and balance. Designed for full off-chain functionality, it ensures seamless operation, even in PWA apps, without connectivity issues.</li><li><strong>Secure Transmission</strong>: Data security is paramount, achieved through obfuscation and multiple verification layers. Future updates will incorporate asymmetric signatures or HMAC for even stronger security.</li></ul><p><strong>Transaction Process</strong>: Upon requesting a transaction, users are redirected to their wallet page or app, filled with necessary transaction details. After validation, the user is prompted to authorize the transaction. Thanks to collaboration with Pimlico and their SDK, the transaction is then bundled and sent to the bundler, facilitating a swift user experience without unnecessary wait times on the wallet page.</p><p><strong>Communication Between Content Provider and Wallet</strong>: Maintaining a secure and efficient communication line is crucial. Post-transaction, content providers can query the wallet for the transaction’s status, ensuring a seamless flow of information.</p><p><strong>Implementing Secure and Efficient Communication</strong>: We faced the challenge of ensuring robust communication that supports offline access and is easy for publishers to integrate, regardless of their technology stack. Our solution involves using an iframe for secure, cross-domain communication, establishing a direct and secure channel within the browser environment.</p><p><strong>Security and Accessibility</strong>: Security and user-friendliness are our top priorities. We’ve designed the system to be inclusive, allowing for easy integration across various technology levels while ensuring a secure exchange of information to prevent fraudulent access.</p><p><strong>Future Directions</strong>: We plan to expand the SDK features, including signature requests and external APIs, based on publisher feedback. This POC is a glimpse into a future where digital content is more accessible, potentially eliminating traditional paywalls and introducing new monetization strategies for content providers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*dAJa5H68_H7jyqoAt8tekQ.png" /></figure><h3>What’s Next?</h3><p>As we forge ahead, our team is thrilled to enhance the demo of our wallet with an array of <strong>new functionalities</strong> in the coming weeks:</p><ol><li><strong>Global ERC-20 Asset Management</strong>: Users will soon be able to receive, send, and track a variety of assets directly within the wallet’s UI, making asset management seamless and intuitive.</li><li><strong>Expanded Content Unlocking Demos</strong>: We’re exploring beyond articles — what would you like to unlock next? Cinema tickets? Music streaming access? Let us know your thoughts!</li><li><strong>NFT Asset Handling</strong>: The integration of NFTs is on our roadmap, enabling users to manage their digital collectibles and art within our ecosystem.</li><li><strong>WalletConnect Integration</strong>: To ensure our wallet’s versatility, we’ll introduce WalletConnect support, allowing it to be used on any website.</li></ol><p>Following these updates, our focus will shift towards <strong>developing a production-ready version</strong> of the wallet. In collaboration with our partners, we’ll launch an alpha release to our current users for thorough testing. This phase is crucial for ensuring reliability and user satisfaction.</p><p>Once we’re confident in the wallet’s performance, we’ll roll it out for public use. This means <strong>you</strong> could soon experience the convenience and security of our WebAuthN-based smart wallet firsthand.</p><p>Stay tuned for these updates and more as we continue to innovate at the intersection of blockchain technology and user experience. Together, we’re not just building a wallet; we’re shaping the future of digital interactions and transactions.</p><h3>Acknowledgments</h3><p>We’d like to extend our heartfelt thanks to the teams and individuals who’ve played a crucial role in bringing this POC to life:</p><ul><li><a href="https://twitter.com/slovaye"><strong>Yoan</strong></a><strong> from </strong><a href="https://www.cometh.io/"><strong>Cometh</strong></a>: An expert in the WebAuthN space whose guidance has been indispensable throughout our journey.</li><li><a href="https://zerodev.app/"><strong>ZeroDev</strong></a>: For providing the foundational <a href="https://github.com/zerodevapp/kernel">Kernel smart wallet</a> technology and invaluable support during the custom validator implementation.</li><li><a href="https://www.pimlico.io/"><strong>Pimlico</strong></a>: For their <a href="https://github.com/pimlicolabs/permissionless.js">permissionless SDK</a>, bundler, and paymaster services that have been instrumental in our development process, along with their ongoing support.</li></ul><p>This project stands as a testament to the power of collaboration within the blockchain community. A big thank you to everyone involved for their contributions, insights, and unwavering support.</p><h3>Conclusion</h3><p>As we reach the end of this journey together, we hope you’ve found inspiration and insight in the possibilities that our Proof of Concept opens up — not just for content publishing but for the broader landscape of digital interactions. Our journey is far from over, and your support plays a pivotal role in shaping its direction.</p><p><strong>We warmly invite you to:</strong></p><ul><li><strong>Clap and Share</strong>: If this article resonated with you, please don’t hesitate to applaud it and share it within your networks. Each clap and share not only amplifies our message but also fuels our passion and commitment to innovation.</li><li><strong>Explore the Demo</strong>: Dive into the experience yourself by exploring our demo. Witness firsthand the simplicity and power of our solution, and if it inspires or excites you, we’d be thrilled if you shared it with others who might appreciate it as well.</li></ul><p>This project is a testament to the power of collaboration, innovation, and community support. Together, we’re not just imagining the future — we’re actively building it. So, whether you’re a developer, content publisher or creator, or simply an enthusiast for cutting-edge technology, your engagement, feedback, and shares are invaluable to us.</p><p>Let’s continue to break new ground, challenge the status quo, and reshape the world of digital content together. Thank you for being an integral part of our journey.</p><p><strong>Your voice, your support, and your curiosity are what drive us forward. Let’s make waves, together.</strong></p><h3>Further Reading</h3><p>Dive deeper into our exploration and collaborative insights with this curated list of articles on Medium. These pieces, co-authored with Yoan from Cometh, delve into various facets of blockchain technology, smart wallets, and our journey in developing this POC:</p><ul><li><a href="https://medium.com/@quentin.nivelais/list/webauthn-collaboration-fc06acc0823b">Explore Our Collaborative Articles on Medium</a></li></ul><p>This collection provides a comprehensive look at our collaborative efforts, offering valuable perspectives and insights into the evolving landscape of blockchain technology.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4310eae5ae66" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/from-idea-to-innovation-unveiling-our-webauthn-smart-wallet-demo-4310eae5ae66">From Idea to Innovation: Unveiling Our WebAuthN Smart Wallet Demo</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frak’s Vanguard: Pioneering the Account Abstraction Revolution in the Polygon Ecosystem]]></title>
            <link>https://medium.com/frak-defi/fraks-vanguard-pioneering-the-account-abstraction-revolution-in-the-polygon-ecosystem-77876b8d9d52?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/77876b8d9d52</guid>
            <category><![CDATA[account-abstraction]]></category>
            <category><![CDATA[mpc]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[zerodev]]></category>
            <category><![CDATA[pimlico]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Wed, 13 Dec 2023 14:32:57 GMT</pubDate>
            <atom:updated>2023-12-13T14:32:57.752Z</atom:updated>
            <content:encoded><![CDATA[<h4>Embracing the Future of Blockchain: Frak Leads with Account Abstraction, Redefining User Empowerment and Decentralization on Polygon.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMCE5ZkYXlossnBhpjKMYQ.png" /><figcaption>Generated via DALL-E</figcaption></figure><h3>Hey there, blockchain enthusiasts and savvy developers!</h3><p>Ready to delve into a story of innovation and transformation in the blockchain universe? Today, I’m thrilled to share with you <a href="https://frak.id/"><strong>Frak’s</strong></a><strong> journey</strong>, where we transitioned from the traditional confines of Multi-Party Computation (MPC) to the cutting-edge realm of <strong>Account Abstraction (AA)</strong>. It’s a narrative brimming with challenges, breakthroughs, and a relentless pursuit of progress.</p><p>In our quest for a more dynamic and decentralized blockchain experience, we encountered and partnered with two pivotal players: <a href="https://zerodev.app/"><strong>ZeroDev</strong></a> and <a href="https://www.pimlico.io/"><strong>Pimlico</strong></a>. Their technologies and insights were instrumental in our evolution and reshaping how we interact with the blockchain.</p><p>As Frak gears up for the “<a href="https://jokerace.xyz/contest/polygon/0x317Fc116E3c524316da9e783eB88099f0397ab2E/submission/76584427412783342536093397040981532505068033608056882071147444248795741602076">Village BUIDL on Polygon #1</a>” competition, this story is not just about a tech shift but a stride towards revolutionizing user engagement in the blockchain world. Stay tuned for an insightful exploration of our transition journey, the role of our tech partners, and the impact of AA on our platform.</p><p>Here’s a quick roadmap of our discussion:</p><ul><li><strong>The Initial Phase:</strong> MPC and Its Boundaries</li><li><strong>The AA Advantage:</strong> A New Era for Blockchain</li><li><strong>Partnering with Pimlico and ZeroDev:</strong> A Strategic Move</li><li><strong>Frak at “Village BUIDL on Polygon #1”:</strong> Showcasing Innovation</li></ul><p>Let’s dive into the transformative world of Frak and blockchain technology! 🌐💡</p><h3>1. The Initial Phase: MPC and Its Boundaries</h3><p>In Frak’s early blockchain explorations, we chose <strong>Multi-Party Computation (MPC)</strong> for its security. However, as we grew, we recognized its limitations:</p><ul><li><strong>Centralization Concerns</strong>: Despite its security strengths, MPC’s centralized approach didn’t align well with our vision of a decentralized blockchain ecosystem.</li><li><strong>Scalability Issues</strong>: As Frak expanded, the inflexibility of MPC in scaling to meet our needs became increasingly clear.</li></ul><p>These insights led us to explore other options, and that’s where <strong>Account Abstraction (AA)</strong> caught our attention:</p><ul><li><strong>Flexibility and Control</strong>: AA offered the adaptability and user autonomy that MPC lacked, aligning more closely with our goals.</li><li><strong>Security Plus Innovation</strong>: AA wasn’t just secure; it also brought innovative approaches to user interaction and control within the blockchain space.</li></ul><p>Our journey with MPC was a critical learning curve. It highlighted our needs and paved the way for the adoption of AA, a technology that promised to keep pace with both our and our users’ evolving requirements.</p><p>Up next, let’s take a closer look at AA, exploring how it became a game-changer for us, especially in collaboration with <strong>ZeroDev</strong> and <strong>Pimlico</strong>. 🚀🔧</p><h3>2. AA Demystified: What It Means for Devs</h3><p>With our sights set on Account Abstraction (AA), we embarked on a path that redefined our approach to blockchain. AA, at its core, is about flexibility and user empowerment, and here’s what it brought to the table for Frak:</p><ul><li><strong>User-Centric Control</strong>: AA shifts the control back to the users. It allows for more intricate transaction rules, enabling users to have a say in how their transactions are processed.</li><li><strong>Enhanced Security</strong>: By abstracting away from traditional wallet structures and integrating <a href="https://github.com/zerodevapp/kernel"><strong>Kernel smart accounts</strong></a> from ZeroDev, AA provides a more secure environment. These smart accounts reduce risks associated with key management by allowing multiple validators and introducing the capability for p256 signers.</li><li><strong>Developer Flexibility</strong>: For devs, AA, coupled with Kernel smart accounts, becomes a playground of innovation. It allows for the creation of more complex and efficient smart contracts, offering a wider range of possibilities in contract design.</li><li><strong>Streamlined Interactions</strong>: AA simplifies interactions within the blockchain. It enables smoother transaction processes, making the user experience more intuitive and less technical.</li></ul><p>Our dive into AA was significantly bolstered by our collaborative efforts with ZeroDev and Pimlico:</p><ul><li><strong>ZeroDev’s Expertise and Kernel Accounts</strong>: Their insights helped us navigate the complexities of AA, ensuring that our implementation was both efficient and effective. The Kernel smart accounts from ZeroDev were pivotal in enhancing the security and operational flexibility of our AA implementation.</li><li><a href="https://github.com/pimlicolabs/permissionless.js"><strong>Pimlico’s Permissionless.js</strong></a>: This tool was a game-changer, offering us the flexibility and efficiency we needed in our AA implementation.</li></ul><p>By integrating AA with Kernel smart accounts, we didn’t just upgrade our technology; we opened up a world of possibilities for both our developers and users. It was a step towards a more inclusive, secure, and innovative blockchain ecosystem.</p><p>In the next section, we’ll explore how our partnerships with ZeroDev and Pimlico catalyzed this transformation.</p><h3>3. Partnering with Pimlico and ZeroDev: A Strategic Move</h3><p>Our transition to Account Abstraction (AA) was significantly influenced by our partnerships with <a href="https://www.pimlico.io/"><strong>Pimlico</strong></a> and <a href="https://zerodev.app/"><strong>ZeroDev</strong></a>. These collaborations were pivotal in our successful adoption of AA, offering unparalleled support and invaluable feedback.</p><p><strong>ZeroDev Collaboration:</strong></p><ul><li><strong>Integration and Optimization</strong>: ZeroDev’s expertise was instrumental in seamlessly integrating AA with our Kernel smart accounts into our system. Their guidance helped us efficiently optimize the transition process.</li><li><strong>Exceptional Developer Support</strong>: ZeroDev provided exceptional support, equipping our developers with in-depth insights and effective solutions for implementing AA and maximizing the potential of Kernel smart accounts.</li></ul><p><strong>Pimlico’s Permissionless.js and Support:</strong></p><ul><li><strong>Crucial Flexibility and Efficiency</strong>: Permissionless.js from Pimlico was crucial for our AA implementation. Its flexibility and efficiency were perfect for our specific needs, especially in integrating with the Kernel smart accounts.</li><li><strong>Outstanding Support and Feedback</strong>: Pimlico’s team stood out with their excellent support, rivaling all others we’ve worked with. Their feedback was essential in fine-tuning our approach to AA.</li><li><strong>Active Contribution</strong>: Our team actively contributed to enhancing Permissionless.js, ensuring it aligned perfectly with our platform and the Kernel smart accounts.</li></ul><p>Collaborating with ZeroDev and Pimlico was about more than just adopting new technology; it was about being part of a community-driven process of innovation. These partnerships allowed us to:</p><ul><li><strong>Exchange Ideas and Strategies</strong>: We engaged in a rich exchange of ideas, deepening our understanding of AA, and exploring its potential applications, especially in conjunction with Kernel smart accounts.</li><li><strong>Build a Collaborative Ecosystem</strong>: Working closely with these tech leaders enabled us to contribute to the broader blockchain ecosystem, fostering innovation that extends beyond Frak.</li></ul><p>Our journey with ZeroDev and Pimlico exemplifies the power of collaboration in technology. It underscores the importance of finding the right partners to navigate new technological terrains and achieve collective success.</p><p>Next, let’s explore the specific benefits AA brought to Frak, transforming our platform and user experience in profound ways, especially with the integration of Kernel smart accounts. 🤝🔧🌐</p><h3>4. The Benefits Unveiled: Why AA Makes Sense for Us</h3><p>Embracing Account Abstraction (AA) brought a host of benefits to Frak, aligning perfectly with our vision for a more innovative, user-centric blockchain platform. Here’s a breakdown of the key advantages we gained:</p><ul><li><strong>Enhanced User Experience</strong>: AA allowed us to create a more intuitive and seamless experience for our users. With more control over transactions and simpler interfaces, user interaction with our platform became smoother and more engaging.</li><li><strong>Increased Security and Trust</strong>: The abstraction layer added by AA significantly improved security. By minimizing direct exposure of private keys and enabling more flexible transaction validation rules, we enhanced the overall trustworthiness of our platform.</li><li><strong>Developer Creativity Unleashed</strong>: For our developers, AA was a game-changer. It opened up new avenues for creativity in smart contract design, allowing them to innovate beyond the constraints of traditional wallet structures.</li><li><strong>Scalability and Flexibility</strong>: AA’s architecture provided us with the scalability and flexibility needed to adapt to future blockchain advancements and user needs. This adaptability is crucial for staying at the forefront of blockchain technology.</li><li><strong>Cost-Effective Operations</strong>: Transitioning to AA also meant more cost-effective operations. The efficiency it brought to transaction processing led to reduced costs, making our platform more economical to run.</li></ul><p>Our move to AA was a calculated step towards a future where blockchain technology is more accessible, secure, and user-friendly. It was about creating a platform that not only meets the current demands of our users but is also poised to evolve with the ever-changing blockchain landscape.</p><p>In our final section, let’s explore how our participation in the “Village BUIDL on Polygon #1” is a showcase of this innovative journey and what it signifies for the future of Frak. 🌟👥</p><h3>5. Frak at “Village BUIDL on Polygon #1”: Showcasing Innovation</h3><p>As we prepare for the “Village BUIDL on Polygon #1” competition, our journey with Account Abstraction (AA) and the collaborations with ZeroDev and Pimlico take center stage. This event is more than just a competition for us; it’s a platform to showcase how far we’ve come and where we’re headed. Here’s what our participation signifies:</p><ul><li><strong>Demonstrating Frak’s Innovation</strong>: Participating in “Village BUIDL on Polygon #1” gives us the opportunity to display the innovative solutions we’ve developed with AA. It’s a chance to show how we’re redefining user interaction within the blockchain space.</li><li><strong>Highlighting Collaborative Success</strong>: This event allows us to highlight the successful collaborations with ZeroDev and Pimlico. It’s a testament to the power of teamwork and shared vision in the tech world.</li><li><strong>Engaging with the Blockchain Community</strong>: Being part of “Village BUIDL on Polygon #1” enables us to engage with the broader blockchain community. It’s an opportunity to exchange ideas, gather feedback, and gain new perspectives.</li><li><strong>Setting the Stage for Future Growth</strong>: Our presence at this event is not just about what we’ve achieved but also about setting the stage for future growth. It’s a chance to explore new partnerships, opportunities, and innovations.</li><li><strong>Reinforcing Our Commitment to the Polygon Ecosystem</strong>: By participating in an event focused on the Polygon ecosystem, we reinforce our commitment to this space and its potential for growth and innovation.</li></ul><p>As we step into the “Village BUIDL on Polygon #1” competition, we’re not just showcasing our technological advancements; we’re demonstrating our commitment to continuous innovation and our role as a key player in the blockchain industry. We’re excited to share our journey, learn from others, and continue pushing the boundaries of what’s possible in blockchain technology. 🚀🌐💡</p><h3>Conclusion: Charting the Future with Account Abstraction</h3><p>As we reflect on our journey from Multi-Party Computation to Account Abstraction (AA), our participation in the “<a href="https://jokerace.xyz/contest/polygon/0x317Fc116E3c524316da9e783eB88099f0397ab2E/submission/76584427412783342536093397040981532505068033608056882071147444248795741602076">Village BUIDL on Polygon #1</a>” competition stands as a proud testament to our evolution and innovation in the blockchain space. This journey, enriched by our collaborations with ZeroDev and Pimlico, has transformed our platform and redefined our approach to blockchain technology.</p><p>Here’s what we take away from this transformative journey:</p><ul><li><strong>Innovation at the Core</strong>: Our transition to AA, especially with the integration of ZeroDev’s Kernel smart accounts, underscores our commitment to innovation, ensuring that Frak stays at the forefront of blockchain technology advancements.</li><li><strong>User-Centric Philosophy</strong>: The shift to AA aligns perfectly with our vision of a user-driven blockchain ecosystem. By prioritizing security, control, and an enhanced user experience, we’ve made our platform more intuitive and accessible.</li><li><strong>Collaboration as a Driving Force</strong>: Our partnerships with ZeroDev and Pimlico highlight the significance of collaboration in achieving technological breakthroughs. These collaborations were key in successfully navigating new frontiers in the blockchain realm and maximizing the potential of AA.</li><li><strong>Commitment to the Polygon Ecosystem</strong>: Our active participation in “Village BUIDL on Polygon #1” reinforces our dedication to the Polygon ecosystem. This event is an opportunity to showcase our contributions, learn from fellow innovators, and demonstrate our integrated solutions featuring AA and Kernel smart accounts.</li></ul><p>Looking to the future, we are excited about the endless possibilities that AA opens up for Frak and the broader blockchain community. We’re eager to continue exploring, innovating, and contributing to this ever-evolving landscape. The journey with AA is just the beginning, and we’re enthusiastic about the new horizons it will unveil. Here’s to pushing the boundaries of decentralized technology and shaping the future of blockchain! 🌟🔗🌍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77876b8d9d52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/fraks-vanguard-pioneering-the-account-abstraction-revolution-in-the-polygon-ecosystem-77876b8d9d52">Frak’s Vanguard: Pioneering the Account Abstraction Revolution in the Polygon Ecosystem</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 3]]></title>
            <link>https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-3-f4c8ebf75245?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/f4c8ebf75245</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 13:22:45 GMT</pubDate>
            <atom:updated>2023-04-14T13:22:45.495Z</atom:updated>
            <content:encoded><![CDATA[<h3>ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 3</h3><p><em>Perfecting ERC-2612: Boost Your DeFi Skills with Solidity Unit Testing in Hardhat and Forge</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CEzMT4wFwiiYPxB6po13Lw.png" /><figcaption>Generated via mid journey, prompt : A small robot spending coins on a machine</figcaption></figure><p>Hello everyone, and welcome to the third article in our series on ERC-2612! In the <a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-2-9c90c01eb69d">previous articles</a>, we’ve discussed the general overview of ERC-2612 and its implementation in Solidity using EIP-712, which enhances user experience and interactions with DeFi platforms like <a href="https://frak.id/">Frak</a>.</p><p>Now, it’s time to dive into the essential aspect of ensuring the <strong>reliability</strong> and <strong>security</strong> of your smart contracts: <strong>unit testing</strong>.</p><p>In this article, we’ll explore how to create comprehensive unit tests for your ERC-2612 implementation using popular development tools like <a href="https://hardhat.org/">Hardhat</a> or <a href="https://github.com/foundry-rs/foundry/tree/master/forge">Forge</a>.</p><p>Here’s a recap of our article series:</p><ul><li><a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-2cd32ddee534">Part 1: General overview of ERC-2612 (March 13, 2023)</a></li><li><a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-2-9c90c01eb69d">Part 2: Solidity development of ERC-2612 (March 23, 2023)</a></li><li><em>Part 3: Unit testing with Hardhat or Forge (this article)</em></li><li>Part 4: Implementation with Ether.js and Fireblocks (coming soon)</li></ul><p>By the end of this article, you’ll be familiar with the best practices for unit testing ERC-2612 and EIP-712 implementations, ensuring the robustness and security of your ERC-20 tokens and their integration with DeFi platforms.</p><p>So, let’s jump into the world of unit testing!</p><h3>Prerequisites</h3><p>Before diving into unit testing with Hardhat and Forge, there are a few prerequisites to ensure a smooth learning experience:</p><ul><li>Solid understanding of Solidity and ERC-2612 implementation: Since this article focuses on unit testing the ERC-2612 and EIP-712 implementation, it’s essential to have a good grasp of Solidity and the concepts covered in the previous articles of this series. If you haven’t already, we highly recommend reading <a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-2cd32ddee534">Part 1: General overview of ERC-2612</a> and <a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-2-9c90c01eb69d">Part 2: Solidity development of ERC-2612</a> before proceeding.</li><li>Familiarity with unit testing in the context of smart contracts: This article assumes that you have basic knowledge of unit testing concepts and experience with either Hardhat or Forge for testing smart contracts. If you’re new to unit testing or need a refresher, consider checking out some introductory resources on <a href="https://hardhat.org/hardhat-runner/docs/guides/test-contracts">Hardhat testing</a> or <a href="https://book.getfoundry.sh/forge/tests">Forge testing</a> before diving in.</li><li>Required tools and environment setup: To follow along with the examples, make sure you have the necessary tools and environment set up for either Hardhat or Forge.</li></ul><p>Now that we’ve covered the prerequisites, we’re ready to delve into unit testing our ERC-2612 and EIP-712 implementation with Hardhat and Forge. Let’s get started!</p><p><em>Disclaimer: In this article, we will primarily focus on successful unit test cases. It is essential to implement unit tests for every error and edge case to ensure the robustness and security of your smart contract. Make sure to thoroughly test all possible scenarios when developing your own contracts.</em></p><h3>Unit Testing with Hardhat</h3><p>In this section, we’ll walk through the process of setting up and executing unit tests for your ERC-2612 and EIP-712 implementation using Hardhat.</p><h4>Setting up variables for the hash (value, nonce, deadline)</h4><p>To start, we’ll define the variables necessary for generating the hash, including the value to be approved, the nonce to prevent replay attacks, and the deadline to ensure the approval is time-limited.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEwuZqq-KLYjAvdQtJHVwQ.png" /><figcaption>Define each variable</figcaption></figure><h4>Building the domain data, types, and values for the hash</h4><p>Next, we’ll construct the EIP-712 domain data, types, and values required for hashing and signing the permit function. This step ensures that our hash conforms to the EIP-712 standard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCkzMJfrHT2t8MGtoTHUew.png" /><figcaption>Build every typed data we will sign</figcaption></figure><h4>Signing the hash and extracting the r, s, and v values</h4><p>With the hash properly constructed, we can now sign it using the private key of the approver. After signing the hash, we’ll extract the r, s, and v values from the signature, which are necessary for calling the permit function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VCZbY87_d6aUWKBqOXU5qw.png" /><figcaption>Sign the message and extract each signature part</figcaption></figure><h4>Calling the permit function, ensuring allowance, and executing a transfer</h4><p>With the r, s, and v values in hand, we can now call the permit function in our smart contract. After calling the permit function, we’ll check the allowance to verify that the approval has been successfully recorded.</p><p>Then, with the approval in place, we can then call the transfer function on behalf of the approver. We’ll verify that the transfer was successful by checking the updated token balances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euBf_eV1k3D4xUML4RlnDQ.png" /></figure><p>By combining these steps, we efficiently test the permit and transfer functions together, ensuring a seamless approval and transfer process in our ERC-2612 and EIP-712 implementation using Hardhat. This approach helps verify the proper functioning of your smart contracts and enhances their overall security and reliability.</p><h3>Unit Testing with Forge</h3><p>In this section, we’ll walk through the process of setting up and executing unit tests for your ERC-2612 and EIP-712 implementation using Forge.</p><h4>Set up variables for the hash (value, nonce, deadline)</h4><p>Just like with Hardhat, we’ll start by setting up the variables needed for the EIP-712 hash. You’ll need to define the value, nonce, and deadline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S8EG7ZW-t_Q5Q9yA6R_2cQ.png" /><figcaption>Define each variable</figcaption></figure><h4>Build the domain data, types, and values for the hash</h4><p>Next, build the domain data, types, and values required for the EIP-712 hash. This process remains the same as in the Hardhat example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OuZzGa3ZxVzDA08N-w0GGQ.png" /></figure><h4>Sign the hash and extract the r, s, and v values</h4><p>To sign the hash using Forge, you can use the vm.sign(). Extract the r, s, and v values as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aF0PqXl7_0v_Ka97C7cTVg.png" /></figure><h4>Call the permit and ensure allowance, then execute the transfer and ensure its success</h4><p>Finally, call the permit function, check the allowance, and execute the transfer using the Forge testing framework. The code snippet is the same as in the Hardhat example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DYYv2YdGNmZfYOeEq8XAmQ.png" /></figure><p>By following these steps, you can successfully implement unit testing for your ERC-2612 and EIP-712 implementation using Forge.</p><h3>Comparing Hardhat and Forge</h3><p>When it comes to unit testing smart contracts, Hardhat and Forge are both popular choices. However, there are some notable differences between the two that can impact your development experience. In this section, we’ll compare the two frameworks, highlighting their <strong>strengths</strong> and <strong>weaknesses</strong>.</p><h4>Code Complexity and Readability</h4><p>In my opinion, Hardhat’s testing syntax is more complex and less readable compared to Forge.</p><p>Hardhat relies on JavaScript for writing tests, whereas Forge allows you to write tests directly in Solidity. As a result, Forge tests tend to be cleaner and more focused on the Solidity code itself, making it easier to reason about the contract logic.</p><h4>Performance</h4><p>Forge has a clear advantage when it comes to test execution speed. In our experience, Hardhat tests took 40ms to run, while Forge tests were significantly faster, taking only 9.03ms.</p><p>This difference can be crucial when working on large projects with many tests, where faster test execution can save valuable time.</p><h4>Flexibility and Ease of Use</h4><p>Forge’s Solidity-based testing approach makes it much easier to test all edge cases, ensuring comprehensive coverage of your smart contracts.</p><p>This is because you can leverage the full power of Solidity when writing your tests, keeping your repository solely focused on the language you’re working with.</p><h4>Advanced Testing Capabilities</h4><p>Forge offers some advanced testing features that can enhance the security of your smart contracts.</p><p>With Forge, you can easily perform fuzz testing, invariant testing, and even test your contracts against mainnet data using the Cast feature.</p><p>These advanced testing capabilities can help you uncover hidden vulnerabilities and ensure the robustness of your smart contracts.</p><p>In conclusion, both Hardhat and Forge are powerful unit testing frameworks with their own strengths and weaknesses. While Hardhat may be more familiar to some developers, Forge offers a clean, Solidity-centric approach to testing, along with advanced testing features that can significantly improve the security of your smart contracts. Ultimately, the choice between the two will depend on your personal preferences and requirements.</p><h3>Conclusion</h3><p>Congratulations on completing the third instalment of our series on ERC-2612! You’ve gained valuable insights into unit testing with Hardhat and Forge, and now understand their differences, strengths, and weaknesses. By choosing the right testing framework for your needs, you can ensure the robustness and security of your ERC-20 tokens and DeFi protocols.</p><p>But we’re not done yet! The final article in this series will cover the implementation of ERC-2612 using Ether.js and Fireblocks, demonstrating how to make your smart contracts even more powerful and accessible.</p><p>If you found this article helpful, please give it a <strong>clap</strong>, <strong>share it</strong>, and <strong>follow me</strong> for more in-depth articles on Solidity, DeFi, and the blockchain world.</p><p>Are you ready to take the next step? Let’s continue our journey into the world of DeFi together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4c8ebf75245" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-3-f4c8ebf75245">ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 3</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Step-by-Step Guide to Onboarding with the Frak Protocol]]></title>
            <link>https://medium.com/frak-defi/a-step-by-step-guide-to-onboarding-with-the-frak-protocol-7a0d13056dd4?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/7a0d13056dd4</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[invest-in-cryptocurrency]]></category>
            <category><![CDATA[earn-money-online]]></category>
            <category><![CDATA[youtube]]></category>
            <category><![CDATA[creator-economy]]></category>
            <dc:creator><![CDATA[Matthieu Viala]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 16:03:21 GMT</pubDate>
            <atom:updated>2023-04-13T16:03:21.160Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>The Frak Protocol is an innovative DeFi platform designed to align creators’ interests with their communities. It empowers users to invest in content-linked assets and benefit from their favorite content’s growth, while creators maintain control over their IPs. If you’re excited to join the Frak community, this step-by-step guide will walk you through the seamless onboarding process.</p><h3>Step 1: Download the Chrome Extension</h3><p>To get started, you’ll need to download the Frak Chrome extension. Visit the <a href="https://chrome.google.com/webstore/detail/frak-beta/jlhmjkajbdaelbnigkpegbkcnbpmggab">Frak page</a> on the Chrome Web Store then click “Add to Chrome” and confirm the installation. The Frak Protocol icon will now appear in your browser’s extension bar.</p><figure><a href="https://chrome.google.com/webstore/detail/frak-beta/jlhmjkajbdaelbnigkpegbkcnbpmggab"><img alt="Click to install the Chrome extension" src="https://cdn-images-1.medium.com/max/1024/1*OYJwPXWVkep1KY6Lk4hCEw.png" /></a><figcaption><a href="https://chrome.google.com/webstore/detail/frak-beta/jlhmjkajbdaelbnigkpegbkcnbpmggab">Frak page</a> on the Chrome Web Store</figcaption></figure><p>Don’t forget to pin the extension to follow your rewards in real time. <br>At this step, the icon is grey.</p><figure><img alt="Not logged grey Frak icon" src="https://cdn-images-1.medium.com/max/72/1*hVwdb9rfMUb3X0wpy7UMQA.png" /><figcaption>Grey colored icon when you are not logged in yet</figcaption></figure><h3>Step 2: Sign Up for an Account</h3><p>Click on the Frak icon in your browser’s extension bar to open the sign up screen in the dashboard space. You’ll be prompted to sign up for an account. Provide your email address and create a strong password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qV2HDZ7vZdQiKEdMkeQ7qQ.png" /><figcaption>Sign up screen</figcaption></figure><p>You must now enter the code you’ve just received in your mailbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*ww3SwtvrfN9B5QuP2ZOG-w.png" /><figcaption>Enter the confirmation code</figcaption></figure><p>Once you’ve successfully signed up, you’re ready to experience the power of the Frak Protocol. You can notice that the extension icon is now colored with the beautiful Frak gradient. 🤗</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/70/1*L9bmTDDJd1liPXAT7xjDmg.png" /><figcaption>Gradient colored icon once you signed up</figcaption></figure><p>You can expand the extension quickly with the following shortcut :</p><ul><li>Alt + Maj + F (Windows)</li><li>Option + Maj + F (Mac)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fl-vDoinYXEQ3BdBGVnsNA.png" /></figure><h3>Step 3: Watch a first Video on YouTube to create your wallet</h3><p>Head over to YouTube and find a video from one of the +20k Youtube channels already registered in the Frak Protocol. To create your own wallet in the Frak Protocol and start being rewarded, you’ll need to watch this video for at least 1 minute (this allows the platform to avoid bots) and until the end of the video.</p><p>You can now see that the Frak icon is green 🟢</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/74/1*jw1r-aFfmuEPH-B7SW1Zog.png" /></figure><p>For more convenience, we advise you to watch directly the video presentation of Frak. In addition, you will have a global overview of the protocol !</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FiLCNnpI3Gos%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiLCNnpI3Gos&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FiLCNnpI3Gos%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d80978f23ced6a191b50e0e4009e00c/href">https://medium.com/media/6d80978f23ced6a191b50e0e4009e00c/href</a></iframe><h3>Step 4: Let the Extension Create Your Wallet</h3><p>Once the video is completed, The Frak Protocol Chrome extension will automatically create a wallet for you. You can also navigate away from the YouTube page to trigger the wallet creation. You can find now your wallet address in the header of the extension (just click on it if you need to copy it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*I4uQbnzc8GMN4f40oI3M9w.png" /><figcaption>Wallet address</figcaption></figure><p>This wallet will store your Frak assets, including any content-linked investments (Fraktions) and rewards you earn (FRK token).</p><blockquote>Congratulations! You are now a part of the Frak Protocol community. You can start being rewarded by watching Youtube videos, investing in your favorite content, and enjoying a more equitable, transparent, and community-driven content ecosystem.</blockquote><h3>Conclusion:</h3><p>The Frak Protocol’s onboarding process is designed to be user-friendly and efficient. By following these simple steps, you can quickly become a part of the Frak community and enjoy the benefits of a platform that empowers creators, users, and advertisers alike. Install <a href="https://chrome.google.com/webstore/detail/frak-beta/jlhmjkajbdaelbnigkpegbkcnbpmggab/related">the Frak Protocol Chrome extension</a> and start investing in the content you love today!</p><blockquote>Please feel free to share any comments about this onboarding in order to help us to improve the protocol!</blockquote><p><strong><em>If you want to continue the conversation, you can connect with me </em></strong><a href="https://twitter.com/mviala"><strong><em>@MViala</em></strong></a><strong><em> on Twitter or on </em></strong><a href="https://t.me/frak_community"><strong><em>Telegram</em></strong></a><strong><em>.<br>Be informed when a new article is published by following us on </em></strong><a href="https://medium.com/frak-defi"><strong><em>Medium</em></strong></a><strong><em>. If you liked this article, please clap for it (up to 50x) to let us know you enjoyed it. It’ll mean a lot to us. Thank you !</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a0d13056dd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/a-step-by-step-guide-to-onboarding-with-the-frak-protocol-7a0d13056dd4">A Step-by-Step Guide to Onboarding with the Frak Protocol</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solidity Gas Efficiency Unleashed: Revert with Error vs Revert with String — A Deep Dive]]></title>
            <link>https://medium.com/frak-defi/solidity-gas-efficiency-unleashed-revert-with-error-vs-revert-with-string-a-deep-dive-248f2cf6bcf2?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/248f2cf6bcf2</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[yul]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 10:56:56 GMT</pubDate>
            <atom:updated>2023-04-11T10:56:56.635Z</atom:updated>
            <content:encoded><![CDATA[<h3>Solidity Gas Efficiency Unleashed: Revert with Error vs Revert with String — A Deep Dive</h3><p>Revert with finesse: Maximize your gas savings with this simple trick!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9DAATdK6k0PP6CZlLOFtQ.png" /><figcaption>Generated via mid journey, prompt : A sleek Ethereum logo combined with a fuel gauge</figcaption></figure><p>Hi there, fellow DeFi enthusiasts! Buckle up for another exciting article that will have you rethinking your Solidity code for maximum gas efficiency.</p><p>This time, we’ll explore the fascinating world of revert with error messages and dive into the specifics of why it’s better to use revert with error instead of revert with a string.</p><p>My experience at <a href="https://frak.id/">Frak</a>, a DeFi protocol, has given me a front-row seat to the challenges and opportunities that come with optimizing smart contracts for efficiency.</p><p>So, what’s in store for you? We’ll take a closer look at revert with error in assembly, and even discuss the low EVM implication, contract size implication, and why it’s more efficient even if the transaction doesn’t revert. And, of course, we’ll provide you with some juicy code snippets to compare and contrast the different techniques.</p><p>Ready to make your smart contracts leaner and meaner? Let’s dive in!</p><h3>Revert with String</h3><p>In the early days of Solidity, developers used the revert function with a string parameter to handle errors. This provided a human-readable error message when things went haywire. Feast your eyes on this code snippet of a simple function that reverts with a string:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*L9woPU8N4hdNSf5b99clvw.png" /><figcaption>Revert with string code sample</figcaption></figure><p>As nifty as descriptive error messages can be, this method is a gas glutton. But fear not, for there is a better way!</p><h3>Revert with Error</h3><p>Enter Solidity 0.8.4, armed with custom errors and a thirst for gas efficiency.</p><p>By opting for revert with an error instead of a string, we can keep the advantages of expressive error messages without draining our gas reserves. Check out the same function as before, but now with a revert error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*nFXIigfMyhbyn5Ilpi89Hw.png" /><figcaption>Revert with error in Solidity</figcaption></figure><h3>Revert with Error in assembly</h3><p>Finally, we have the king of gas efficiency, revert with an error code in assembly. This method is the most gas-efficient, but it’s also the most complex. Use it wisely!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*i-BT2xGaaMt_u1X4ugguEA.png" /><figcaption>Revert with error in Solidity Assembly</figcaption></figure><h3>Why the Gas Differences?</h3><p>Now that we’ve seen the magic tricks, let’s dive into the “why.” There are three primary reasons for the gas differences between the three methods:</p><ol><li><strong>Low EVM Implication</strong>: When you revert with a string, the EVM has to store the string in memory, which consumes more gas than simply using an error code. In contrast, error codes are more efficient for the EVM, resulting in lower gas consumption.</li><li><strong>Contract Size Implication</strong>: Contracts with larger strings take up more space on the Ethereum blockchain, resulting in a larger contract size. A larger contract size means more gas is consumed for deployment and execution. Using error codes instead of strings keeps your contract size smaller and more efficient.</li><li><strong>Efficiency Even Without Revert</strong>: Even if your transaction doesn’t revert, using error codes over strings is still more efficient. The EVM has to parse the error string, regardless of whether the transaction reverts or not. By using error codes, you’re saving gas on every transaction!</li></ol><h3>Benchmark Comparison</h3><p>To showcase the gas efficiency of revert with error over revert with string, let’s examine a benchmark comparison of the three code snippets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxE8v9eNAATQe5Jzu4R21Q.png" /><figcaption>Result for revert with string</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UhTUhofw79mLrBYpYiSnBg.png" /><figcaption>Result for revert with error</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C91puNDa5Pd1yN_ny7jZdg.png" /><figcaption>Result for revert with error in assembly</figcaption></figure><p>In this benchmark, you can clearly see the differences in contract size and gas consumption between the three methods. The gas savings are substantial, especially when using revert with an error in assembly.</p><p>You can find the snippet and the gas usage test <a href="https://gist.github.com/KONFeature/d35e7278b37443ff286a0d3b73acad36">here</a>, test done with foundry.</p><h3>Conclusion</h3><p>Kudos! You’ve now unlocked the secret to optimizing gas efficiency in Solidity by choosing revert with error over revert with string. Small changes like these can have a significant impact on your DeFi protocols, just like we did at <a href="https://frak.id/">Frak</a>.</p><p>If this article fueled your passion for gas efficiency, don’t hesitate to give it a <strong>clap</strong>, <strong>share</strong> it, and <strong>follow</strong> me for more witty and engaging articles on Solidity and the DeFi universe.</p><p>Our journey into the world of DeFi is far from over! Stay tuned, and together, we’ll continue to explore the fascinating realm of decentralized finance. Let the adventure continue!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=248f2cf6bcf2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/solidity-gas-efficiency-unleashed-revert-with-error-vs-revert-with-string-a-deep-dive-248f2cf6bcf2">Solidity Gas Efficiency Unleashed: Revert with Error vs Revert with String — A Deep Dive</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 2]]></title>
            <link>https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-2-9c90c01eb69d?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/9c90c01eb69d</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[erc20]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 07:44:42 GMT</pubDate>
            <atom:updated>2023-03-23T07:44:42.503Z</atom:updated>
            <content:encoded><![CDATA[<h3>ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 2</h3><p><em>A deep dive into the Solidity code of gasless ERC-20 approvals ERC-2612</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d73bfBrfgkwqNMlshB0fPw.png" /><figcaption>Generated via mid journey, prompt : A person who handles a contract to a machine ethereum</figcaption></figure><p>Hi everyone, welcome back to the second article of my series on ERC-2612! If you missed the <a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-2cd32ddee534">first article</a>, we covered the general overview of ERC-2612, an ERC-20 token extension that leverages EIP-712 signatures for approving spenders.</p><p>This ingenious combination simplifies and streamlines user interactions with DeFi platforms, like the one I worked on at <a href="https://frak.id/">Frak</a>.</p><p>Today, we’re diving into the nitty-gritty of implementing ERC-2612 in Solidity while incorporating EIP-712. We’ll explore the domain separator, the Permit type, the permit function, and the implementation intricacies, such as nonce management and deadlines.</p><p>Here’s a breakdown of the article series:</p><ol><li><a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-2cd32ddee534">Part 1: General overview of ERC-2612 (March 13, 2023)</a></li><li><em>Part 2: Solidity development of ERC-2612 (this article)</em></li><li>Part 3: Unit testing with Hardhat or Forge (coming soon)</li><li>Part 4: Implementation with Ether.js and Fireblocks (coming soon)</li></ol><p>By the end of this article, you’ll be well-equipped to implement ERC-2612 and EIP-712 in Solidity and fully leverage their benefits for your own ERC-20 tokens, enhancing user experience, flexibility, and integration with other DeFi protocols.</p><p>So let’s dive in!</p><h3>1. Adding EIP-712 Support</h3><p>To implement EIP-712 in our existing ERC-20 token contract, we’ll first define the required domain separator type hashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqOETe2hVw_OmBEGmCRJGg.png" /><figcaption>EIP712 domain type hash</figcaption></figure><blockquote>You can add a “bytes32 salt” at the end of the domain typehash, if you’re protocol contain multiple implementation.</blockquote><blockquote>The chainId is optional, we use it at Frak since we are planning on bridging our FrkToken to multiple chain.</blockquote><p>Next, we need to store the domain separator itself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*iFmw6e2rp_hvkiV8w9PDlg.png" /><figcaption>Contract variable that hold the domain separator</figcaption></figure><p>Initialize the DOMAIN_SEPARATOR in the constructor of your ERC-20 token contract, by calling a function similar to this one (<a href="https://github.com/frak-id/frak-id-blockchain/blob/68f6ffcea83b5333839cc0daec11bdcedac3fe33/contracts/utils/EIP712Base.sol#L53">github</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*_wl6r8L2QmrOY3Qzs1BNiw.png" /><figcaption>EIP712 Domain separator creation</figcaption></figure><p>The getChainId() method is just a simple helper function that return the current chainId. If you are using solidity 0.8+ you can simply use block.chainid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*pRtw5_EH9YDZBm_2D2I6aQ.png" /><figcaption>Small helper to retrieve the chainId</figcaption></figure><h3>2. Adding ERC-2612 Support</h3><p>Now, let’s add support for ERC-2612 by creating the Permit type hash and adding the nonces mapping:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJAVxBGInkxyvGNv8w8hlg.png" /><figcaption>Permit typehash</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*yfuZAuTSBSYwHHtrpXZb-A.png" /><figcaption>Contract variable that hold user nonces</figcaption></figure><p>Next, implement the permit function (<a href="https://github.com/frak-id/frak-id-blockchain/blob/68f6ffcea83b5333839cc0daec11bdcedac3fe33/contracts/tokens/FrakTokenL2.sol#L124">github</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6NgBqYMarAjBVV-zNAD4w.png" /><figcaption>Permit function in the ERC20</figcaption></figure><p>The permit function constructs the EIP-712 typed data structure, hashes it, and verifies the signer&#39;s address using the ecrecover function. If the signature is valid and the deadline has not expired, it calls the internal _approve function to update the allowance mapping.</p><p>For the error, we are using assembly and error to be more gas efficient (less memory used and no need to send a string)</p><p>Here we are using a small helper function toTypedMessageHash() , that help us create EIP-712 typed data hashes (<a href="https://github.com/frak-id/frak-id-blockchain/blob/68f6ffcea83b5333839cc0daec11bdcedac3fe33/contracts/utils/EIP712Base.sol#L72">github</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x5vcOTb8LGtMpydeprADOg.png" /><figcaption>Creation of typed message hash</figcaption></figure><p>We are using assembly here to be more gas efficient.</p><p>With these changes in place, your ERC-20 token contract now supports both ERC-2612 and EIP-712. Users can approve spenders via signatures instead of transactions, making interactions with your token contract more efficient and user-friendly.</p><h3>3. Some pitfalls of implementation</h3><h4>3.1 Deadlines and Time Synchronization</h4><p>When implementing the permit function, it&#39;s essential to manage deadlines effectively. Using block.timestamp for deadline comparisons can help prevent attacks related to manipulating block time. However, it&#39;s worth noting that the block.timestamp value is determined by miners and can be off by a few seconds, so take this into account when setting deadlines for permit signatures.</p><h4>3.2 Signature Security</h4><p>Always be cautious about the security aspects of signature handling. For example, ensure that your implementation properly validates the recovered address to avoid potential vulnerabilities. Additionally, be aware that the ecrecover function returns the zero address if the signature is invalid, so always check for this scenario in your implementation.</p><h4>3.3 Gas Costs</h4><p>While using signatures for approvals can reduce gas costs for users, the actual permit function itself might be gas-intensive due to the cryptographic operations involved, such as keccak256 and ecrecover. It&#39;s crucial to analyze and optimize gas costs during the development process to ensure that your implementation remains efficient and cost-effective.</p><h4>3.4 Chain ID Changes</h4><p>The EIP-712 domain separator includes the chain ID to prevent replay attacks across different networks. However, it’s essential to remember that the chain ID can change in certain situations, such as during a network upgrade or a hard fork. When this occurs, the domain separator must be updated accordingly. One solution is to implement a function that allows the contract owner to update the domain separator when a chain ID change occurs.</p><h4>3.5 Debugging Signature Issues</h4><p>During the implementation process, you may encounter issues related to signature verification. Debugging these issues can be challenging, as cryptographic functions tend to be less intuitive and harder to trace. To help overcome this pain point, it’s crucial to become familiar with the EIP-712 specification, understand the expected input format for the ecrecover function, and use test cases to verify the correctness of your signature generation and verification code.</p><p>From my personal experience, I highly recommend setting up Foundry unit tests and emitting numerous events at each step of the process to confirm the accuracy of your implementation. Utilizing a Foundry test case with a high verbosity output (e.g., -vvvv) will allow you to monitor all events, making it much easier to identify and resolve potential issues that may arise.</p><p>By keeping these potential pitfalls in mind, you can ensure a robust and secure implementation of ERC-2612 and EIP-712 in your ERC-20 token contract.</p><h3>Conclusion</h3><p>Congratulations! You’ve now unlocked the full potential of ERC-2612 and EIP-712 in Solidity. By combining these standards, your ERC-20 tokens will enjoy improved user experience and seamless integration with the ever-evolving DeFi ecosystem.</p><p>But don’t stop here! Keep an eye out for the next articles in this series, where we’ll cover unit testing with Hardhat or Forge and implementing ERC-2612 using Ether.js and Fireblocks. If you found this article helpful, please give it a clap, share it, and follow me for more insightful articles on Solidity and the DeFi world.</p><p>Ready for the next adventure? Let’s continue our journey into the world of DeFi together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c90c01eb69d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-part-2-9c90c01eb69d">ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 2</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals]]></title>
            <link>https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-2cd32ddee534?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/2cd32ddee534</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 14:54:04 GMT</pubDate>
            <atom:updated>2023-03-23T08:06:32.870Z</atom:updated>
            <content:encoded><![CDATA[<h3>ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals — part 1</h3><p>How to use EIP-712 signatures to save gas, batch approvals and increase security for your ERC-20 tokens.</p><figure><img alt="A futuristic cityscape with Ethereum logo" src="https://cdn-images-1.medium.com/max/1024/1*vLvlrzsOeqOin6rx9uXKCg.png" /><figcaption>Generated via mid journey, prompt : A futuristic cityscape with Ethereum logo</figcaption></figure><p>If you are a developer or a user of ERC-20 tokens, you probably know how annoying and costly it is to approve a spender contract before it can transfer tokens on your behalf. You have to send a transaction, pay gas fees, wait for confirmation and hope that nothing goes wrong.</p><p>But what if I told you that there is a better way to do approvals? A way that is <strong>faster</strong>, <strong>cheaper</strong>, <strong>safer</strong> and more <strong>user-friendly</strong>? A way that uses EIP-712 signatures instead of transactions?</p><p>I’ve discovered that <a href="https://eips.ethereum.org/EIPS/eip-2612"><strong>ERC-2612</strong></a> was the solution to those issues. It’s an extension for <a href="https://eips.ethereum.org/EIPS/eip-20"><strong>ERC-20</strong></a> tokens that allows users to approve spenders via <a href="https://eips.ethereum.org/EIPS/eip-2612"><strong>EIP-712</strong></a> signatures instead of transactions. EIP-712 is a standard for hashing and signing typed structured data as opposed to just bytestrings.</p><p>In this article, I will explain what is ERC-2612 and how it can improve the <strong>user experience</strong> and <strong>security</strong> of ERC-20 approvals. I will also show you how to implement it in Solidity contracts and how to test it with <a href="https://hardhat.org/"><strong>Hardhat</strong></a> or <a href="https://github.com/foundry-rs/foundry"><strong>Foundry</strong></a>. Finally, I will demonstrate how to use it with <a href="https://github.com/ethers-io/ethers.js"><strong>Ether.js</strong></a> and <a href="https://www.fireblocks.com/"><strong>Fireblocks</strong></a> libraries.</p><p>By implementing ERC-2612 at Frak, we makes it easier and cheaper for users to interact with our platform and other DeFi protocols.</p><p>This will be a series of articles divided into four parts:</p><ul><li><em>Part 1: General overview of ERC-2612 (March 13, 2023)</em></li><li><a href="https://medium.com/p/9c90c01eb69d">Part 2: Solidity development of ERC-2612</a></li><li>Part 3: Unit testing with Hardhat or Forge</li><li>Part 4: Implementation with Ether.js and Fireblocks</li></ul><p>By the end of this series, you will be able to use ERC-2612 for your own ERC-20 tokens or interact with existing ones that support it. You will also learn how <a href="https://frak.id/"><strong>Frak</strong></a> leverages ERC-2612 to enable gasless token transfers and frictionless DeFi interactions.</p><p>Let’s get started!</p><h4>How does ERC-2612 work?</h4><p>ERC-2612 introduces a new function called <strong>permit</strong> that takes an <strong>EIP-712 signature</strong> as an input and updates the allowance mapping accordingly. The signature must contain the following fields:</p><ul><li><strong>owner</strong>: The address of the token owner who signed the message</li><li><strong>spender</strong>: The address of the spender contract who can transfer tokens on behalf of the owner</li><li><strong>value</strong>: The maximum amount of tokens that can be transferred by the spender</li><li><strong>nonce</strong>: A unique number that prevents replay attacks</li><li><strong>deadline</strong>: A timestamp after which the signature is invalid</li><li><strong>v, r, s: </strong>The components of the EIP-712 signature that proves the owner’s consent</li></ul><p>The signature must follow a specific format defined by <strong>EIP-712</strong>. It must include a <strong>domain separator</strong> and a <strong>type hash</strong> that identify the token contract and the permit function. It must also encode and hash the parameters according to a <strong>specific schema</strong>.</p><p>In our case, the parameter for the signature are the following:</p><figure><img alt="Permit struct : (address owner, address spender, uint256 value,uint256 nonce,uint256 deadline)" src="https://cdn-images-1.medium.com/max/382/1*bBueyoHdmADcTTl8BVjU6Q.png" /><figcaption>Permit signature format, following the ERC-2612</figcaption></figure><p>The token contract then verifies that the signature is valid and matches the parameters. If so, it <strong>updates the allowance</strong> mapping accordingly.</p><p>This means that the token contract performs <strong>two checks</strong> before updating the allowance mapping:</p><ol><li>It checks that the signature is valid. This involves <strong>hashing</strong> the parameters using EIP-712 and <strong>recovering</strong> the signer’s address from the signature using ‘<em>ecrecover’</em>. Then it compares the recovered address with the owner address provided in the parameters. If they match, it means that the owner has signed the message and consented to approve the spender. Otherwise, it means that someone else has forged or tampered with the signature and it should be rejected.</li><li>It checks that the parameters are valid. This involves checking that the <strong>deadline</strong> has not expired, that the <strong>value</strong> is not greater than the owner’s balance, and that the <strong>nonce</strong> is the current one for the owner (to prevent replay attack’s). If these conditions are met, it means that the approval is still valid and can be executed. Otherwise, it means that something has changed since the owner signed the message and it should be rejected.</li></ol><p>If both checks pass, then it means that everything is in order and there is no reason to deny or delay the approval. Therefore, it updates the allowance mapping.</p><p>This allows the <em>spender</em> to transfer up to <em>value</em> tokens on behalf of <em>owner.</em></p><p>This way, the owner does not have to send a transaction to approve the spender. They can sign a message offline and send it to anyone who can submit it to the token contract. They can also revoke or change their approval at any time by signing a new message with a different value.</p><p>ERC-2612 has been adopted by many popular ERC-20 tokens, such as <strong>DAI</strong>, <strong>UNI</strong>, <strong>COMP </strong>etc. It has also been integrated with many DeFi protocols and platforms, such as <a href="https://uniswap.org/"><strong>Uniswap</strong></a>, <a href="https://compound.finance/"><strong>Compound</strong></a>, <a href="https://aave.com/"><strong>Aave</strong></a>, <a href="https://frak.id/"><strong>Frak</strong></a> etc. It has become a de facto standard for gasless ERC-20 approvals and transfers.</p><h3>What are the benefits of ERC-2612?</h3><p>In my experience, using EIP-712 signatures for approvals has several <strong>advantages</strong> over using <strong>transactions</strong>.</p><ul><li><strong>Gas savings</strong>: Users don’t have to send any transactions or pay any gas fees to approve spenders. They can simply sign a message with their private key and send it to the spender contract or a third-party service that can relay it to the contract.</li><li><strong>Batching</strong>: Users can approve multiple spenders with one signature by using different <strong>nonces</strong> or <strong>values</strong>. This <strong>reduces friction</strong> and <strong>complexity</strong> for users who want to interact with multiple contracts or services. In my experience with Frak, where we have custodial wallets and pay for a lot of user gas fees, batching has been particularly important.</li><li><strong>Security</strong>: Users can include additional parameters such as expiry time or maximum amount in their signatures. This gives them more control and flexibility over their approvals and prevents replay attacks or unlimited spending.</li></ul><h3>Pain points of implementing ERC-2612</h3><p>While ERC-2612 offers many benefits for ERC-20 approvals, it also comes with some <strong>challenges</strong> and <strong>trade-offs</strong> that you should be aware of before implementing it.</p><p>One of the main pain points is the <strong>complexity</strong> of EIP-712 signatures. EIP-712 is a standard for hashing and signing typed structured data as opposed to just bytestrings. This means that you have to define a domain separator and a type hash for your permit function, as well as encode and hash the parameters according to a specific format.</p><p>This can be tricky and error-prone, especially if you are not familiar with EIP-712 or low-level Solidity operations. Fortunately, there are some <strong>libraries</strong> and <strong>tools</strong> that can help you with this task, such as OpenZeppelin contracts, Hardhat EIP-712 plugin, Ether.js utils, Fireblocks SDK, etc.</p><p>Another challenge I have encountered is ensuring compatibility with different wallets and providers. Not all wallets support EIP-712 signatures natively which may require workarounds or fallbacks to make your permit function work with them. For example, some wallets may require a signature prefix (such as “<em>\x19Ethereum Signed Message:\n32”</em>) or a different chain id than expected. (I’ve lost a day or two with this !)</p><p>You also have to consider how your users will sign their permits. Will they use MetaMask, WalletConnect, Ledger, Trezor, etc.? Will they sign on-chain or off-chain? Will they sign using their private key or a smart contract (such as EIP-1271 )? These factors may affect how you implement and test your permit function.</p><p>Finally, you have to be careful about security issues and edge cases when using permits. For instance, you have to prevent replay attacks by using nonces and validating chain ids . You also have to handle expiration dates and invalid signatures gracefully. You may also want to add some extra checks or events for debugging purposes.</p><p>As you can see, implementing ERC-2612 is not trivial and requires some attention to detail.</p><p>However, once you get it right, you will enjoy the benefits of gasless ERC-20 approvals for yourself and your users. Stay tuned for the second part of this article series where I will cover the <strong>Solidity implementation</strong> of ERC 2612.</p><p>I hope this article has provided valuable insights into its <strong>benefits</strong> and <strong>challenges</strong>. If you found it helpful, please don’t hesitate to <strong>follow</strong> me and give this article a <strong>clap</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cd32ddee534" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/erc-2612-the-ultimate-guide-to-gasless-erc-20-approvals-2cd32ddee534">ERC-2612: The Ultimate Guide to Gasless ERC-20 Approvals</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximizing Quality and Reliability in Solidity: Our Journey from Hardhat to Foundry]]></title>
            <link>https://medium.com/frak-defi/maximizing-quality-and-reliability-in-solidity-our-journey-from-hardhat-to-foundry-52e0504d11c6?source=rss----8e1d9cf58914---4</link>
            <guid isPermaLink="false">https://medium.com/p/52e0504d11c6</guid>
            <category><![CDATA[foundry]]></category>
            <category><![CDATA[hard-hat]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Quentin Nivelais]]></dc:creator>
            <pubDate>Tue, 10 Jan 2023 11:07:03 GMT</pubDate>
            <atom:updated>2023-01-10T11:07:03.784Z</atom:updated>
            <content:encoded><![CDATA[<h4>Evaluating the performance difference of Hardhat and Foundry for Solidity contract unit testing &amp; reason behind the switch</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cBOlK6WR818Q6-Nb" /><figcaption>Photo by <a href="https://unsplash.com/@flowforfrank?utm_source=medium&amp;utm_medium=referral">Ferenc Almasi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As the head of smart contract at Frak, a web3 company that is working to create a new revenue model for content creators and users using blockchain technology, I know firsthand the importance of ensuring the quality and reliability of our code.</p><p>One of the key tools we use to achieve this is unit testing, which allows us to validate the behavior of individual units of code and catch any issues early on in the development process.</p><p>In this article, I’ll be sharing our experience with switching from Hardhat to Foundry for unit testing in Solidity. By sharing our journey, I hope to provide valuable insights and guidance for other Solidity developers who are considering a similar switch.</p><h3>Hardhat vs Foundry</h3><p>I won’t go into details here about what <strong>Hardhat</strong> and <strong>Foundry</strong> are, but briefly, Hardhat is the most widely used framework for Solidity development, deployment, and testing, mainly using JavaScript to perform all of these tasks, while Foundry is a new framework, written in Rust, that performs the same tasks but using Solidity code for everything.</p><p>Under the hood, Hardhat deploys a local blockchain and uses <strong>ether.js</strong> to communicate with the contract and Mocha for unit testing, while Foundry uses <strong>Forge</strong> and <strong>Anvil</strong> (a local blockchain) to deploy the Solidity test contract, run the tests, and interpret the results.</p><p>You can already see where we are going with this. On one hand, a JavaScript script will talk to our local chain for each one of our tests, possibly making multiple calls to the local chain, on the other hand, the test contract is completely deployed on a local chain, and a script will only execute the test methods.</p><h3>Benchmark</h3><p>I will run benchmarks on our <strong>FrakTreasuryWallet</strong> contract. It’s a really simple contract (upgradeable and with roles) but it only has one method to perform a transfer from our treasury to a given address.</p><p>A test is quite interesting on this contract, since we need to ensure that we won’t exceed the amount planned for our treasury (in our case, 330 million tokens), but the contract only mints tokens in chunks of 1 million. So, we need to call the contract a tremendous number of times to perform all the transfers and empty the contract, and to make sure that no more transfers can be made from an empty treasury.</p><p>Here are the results of the unit tests, using both Hardhat and Forge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*CUgH2J4Fu6bcRttU4o4z_Q.png" /><figcaption>Hardhat test run (13sec)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tdzvqEsGm1hYd8qkXLQwQ.png" /><figcaption>Forge test run (102ms)</figcaption></figure><p>You can see that Hardhat took <strong>13 seconds</strong> to execute all the tests, and almost 9 seconds for the test where we need to empty the treasury. Meanwhile, Forge only took <strong>102 milliseconds </strong>to perform the same thing.</p><p>And with Forge, we also got a <strong>fuzzed</strong> test that has run 256 times (which is not currently possible with Hardhat), so it ran 256 more executions of our contract, over 100 times faster. This provides a much better gas estimation and a lot more reliability since we have random input values.</p><h3>Benefits</h3><p>Since the tests are written in Solidity, we can also use <strong>inheritance</strong> to have some test helpers, and some generic tests (for the upgradeability, roles management, or pause system). In our case, we use it to deploy our contract under a <strong>UUPS proxy</strong>, with some modifiers to ‘prank’ the address in use for the tests to be the deployer (you can find it <a href="https://github.com/frak-id/frak-id-blockchain/blob/main/test/foundry/UUPSTestHelper.sol">here</a>).</p><p>The reason for the switch is quite obvious now, it allows us to test our code much faster, perform some gas optimization tests and see the impact on the whole ecosystem in less than a second (post compilation, so around <strong>5 seconds</strong> in our case).</p><h3>Caveat</h3><p>Since Foundry is purely <strong>Solidity-based</strong> (for deployment scripts and tests), it required us to rewrite all of our unit tests in the Solidity form. Nonetheless, it allows us to incorporate some <strong>fuzzing</strong> tests for all of our contracts, giving us better <strong>gas estimation</strong> for their execution.</p><p>We also needed to do some research around the testing framework (for the upgrade part, the assertions, log fetching and accessing some data returned by our functions, etc.) to understand how it works, especially the various <strong>“cheat codes”</strong> available. But, if you are familiar with Solidity, the learning curve is relatively quick.</p><p>If you’re not familiar with “cheat codes”, they help you manipulate the VM in some ways (change the current execution address, fetch logs emitted by an event), I will cover that in more detail in an article about how we set up Foundry for all of our unit tests.</p><p>We decided to go with <a href="https://github.com/paulrberg/prb-test">PRBTest</a> instead of the original Foundry test library, since it provides versioning and more assertions, while remaining compatible with all the original VM cheat codes provided by Foundry.</p><h3>Conclusion</h3><p>In about <strong>a week</strong>, we managed to set up Foundry and migrate the majority of our unit tests to it. We encountered a few things that were not well-documented, but they remained easily solvable.</p><p>Since the tests ran approximately <strong>100 times faster</strong>, it helped us a lot with our research on gas optimization, and it will help us in the future to add new features to our system, test them, and optimize our code even further.</p><p>Stay tuned for another article where I will explain how we set up Foundry in our existing Hardhat project and how we set up base unit tests for our upgradeable contract!</p><p>In the meantime, you can check out our <a href="https://github.com/frak-id/frak-id-blockchain">github repository</a> :)</p><p><strong><em>If you want to continue the conversation, you can connect with us </em></strong><a href="https://twitter.com/frak_defi"><strong><em>@frak_defi</em></strong></a><strong><em> on Twitter or on Telegram.<br>Be informed when a new article is published by following us on </em></strong><a href="https://medium.com/frak-defi"><strong><em>Medium</em></strong></a><strong><em>. </em>If you liked this article, please consider giving it a “clap”<em> (up to 50x) to let us know you enjoyed it. It’ll mean a lot to us.</em></strong></p><p><strong><em>Thank you :)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52e0504d11c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/frak-defi/maximizing-quality-and-reliability-in-solidity-our-journey-from-hardhat-to-foundry-52e0504d11c6">Maximizing Quality and Reliability in Solidity: Our Journey from Hardhat to Foundry</a> was originally published in <a href="https://medium.com/frak-defi">frak-defi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>