<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Pinata</title>
        <link>https://paragraph.com/@pinatacloud</link>
        <description>The easiest way for Developers to build on IPFS with Pinning and Dedicated Gateways</description>
        <lastBuildDate>Tue, 01 Dec 2026 05:57:21 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[How to Mint an NFT on TON]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-mint-an-nft-on-ton</link>
            <guid>CA1SBHDKbAn9irvBDCer</guid>
            <pubDate>Thu, 11 Jul 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[In this guide, we’ll show you how to do just that by building an app that uploads the NFT assets securely to Pinata and mints an NFT on TON.]]></description>
            <content:encoded><![CDATA[<p>TON is not a new Layer 1 Blockchain by any means, but it has seen exponential growth in the first half of this year. Daily transactions are climbing upwards of 5+ million per day with no signs of stopping anytime soon.</p><p>If you’re not familiar with TON, it’s a proof of stake network that is heavily integrated with Telegram; most of the people building Telegram are also building TON. This level of integration poses a unique approach to consumer crypto by tapping into a well used social platform in Web3, allowing wallets, dApps, and more without leaving Telegram. Not only that, but TON also has an interesting multi-chain approach, where there is a master chain that handles critical information and then uses work-chains for different transactions. This model enables high performance and low fees. If you’re a developer looking to start building on TON, there’s no better way to start than to mint an NFT! In this guide, we’ll show you how to do just that by building an app that uploads the NFT assets securely to Pinata and mints an NFT on TON.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-ton-vs-ethereum-nfts"><strong>TON vs Ethereum NFTs</strong></h2></div><p style="text-align: start">Before we dive into the main tutorial, it might help to explain how TON differs from Ethereum when it comes to NFTs. With Ethereum, or other EVM chains, you typically have a single smart contract with many NFTs. This has proven to cause unpredictable gas prices which trickle down to the end user. TON NFTs, on the other hand, have a contract for each NFT that are linked to a collection contract, which results in a more stable model for minting.</p><p style="text-align: start">Since TON takes this approach, the developer tooling also looks very different. Instead of writing a smart contract that imports OpenZeppelin standards, deploying, testing, etc., we can just use TON’s libraries to create the collection on the fly. All we have to do is pass in the right metadata, then make additional calls to the master collection for each NFT we mint. That’s exactly what we’ll do in our app!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-setup"><strong>Setup</strong></h2></div><p style="text-align: start">In order to start building the TON app we’re gonna need a few things first.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-pinata-account-and-api-key"><strong>Pinata Account &amp; API Key</strong></h3></div><p style="text-align: start">Like with most other blockchains, we need a way to store the token URI of our NFTs offchain, and IPFS fits the bill. To use IPFS, we’ll need to make a free Pinata account <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://app.pinata.cloud/register?ref=pinata.cloud"><strong><u>here</u></strong></a>. Once we’ve created the account, we’ll want to make an API key that we can use to upload content from our TON app. You can do so by following <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/account-management/api-keys?ref=pinata.cloud"><strong><u>these instructions</u></strong></a>, ensuring careful attention to copy down the API key somewhere safe. We’ll be using the longer JWT in particular.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-telegram"><strong>Telegram</strong></h3></div><p style="text-align: start">Since TON is so heavily integrated with Telegram I would recommend making an account, if you haven’t already, as well as downloading the desktop client as we build through the app. There will be several setup points that require interacting with bots through Telegram, and it’s probably the easiest way to walk through those parts.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-ton-wallet"><strong>TON Wallet</strong></h3></div><p style="text-align: start">The next thing you’re gonna need is a TON wallet, as an EVM wallet like MetaMask isn’t going to work here. For this tutorial, we’ll use the official <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://chromewebstore.google.com/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd?ref=pinata.cloud"><strong><u>TON Wallet extension</u></strong></a>, as our code will be able to plug right into it. Once you’ve created the wallet and followed the steps to secure it, we’ll need to put it into testnet mode. To do this, you’ll want to click on the three dots in the top right, then shift+click on the version listed. This will trigger a modal for switching to testnet.</p><p style="text-align: start"><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://ton-wallet.mp"><strong><u>ton-wallet.mp</u></strong></a><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://prod-files-secure.s3.us-west-2.amazonaws.com/9cc5b8bb-075e-4435-b1fb-c3d115d21d00/ff391dbe-92b0-46bc-a8ec-0515be3273f1/ton-wallet.mp4?ref=pinata.cloud"><strong><u>4</u></strong></a></p><p style="text-align: start">Now that we’re in testnet mode, we need to get testnet funds! You can do this by following <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://t.me/testgiver_ton_bot?ref=pinata.cloud"><strong><u>this link</u></strong></a> which will open a new chat in Telegram with the faucet bot. Just follow the steps, provide your wallet address, and you’ll get some testnet funds!</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-ton-api-key"><strong>TON API Key</strong></h3></div><p style="text-align: start">Our app is going to use some of the TON libraries, which will send requests to an RPC node on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://toncenter.com"><strong><u>toncenter.com</u></strong></a> and, because of that, we’ll need an API key to access it. You can get one by following <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://t.me/tonapibot?ref=pinata.cloud"><strong><u>this link</u></strong></a> which will, again, open a new Telegram chat with a bot that can give you the API key.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-nextjs"><strong>Next.js</strong></h3></div><p style="text-align: start">Just for simplicity, we’ll be using Next.js as our stack, as we need a way to secure our Pinata API key. To kick off, run the following command in the terminal and select all the defaults.</p><pre data-type="codeBlock"><code>npx create<span class="hljs-operator">-</span>next<span class="hljs-operator">-</span>app@latest ton<span class="hljs-operator">-</span>minting<span class="hljs-operator">-</span>tutorial</code></pre><p>Once it’s done installing dependencies, run the following command to move into the project and install the TON library.</p><pre data-type="codeBlock"><code>cd ton<span class="hljs-operator">-</span>minting<span class="hljs-operator">-</span>tutorial <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> npm install tonweb uuid</code></pre><p>Now we can start building this thing out!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-building-the-app"><strong>Building the App</strong></h2></div><p style="text-align: start">As stated, we’ll be building an app that does the following:</p><ul><li><p>Lets users connect their wallet</p></li><li><p>Create an NFT collection</p></li><li><p>Mint an NFT in the collection</p></li></ul><p style="text-align: start">Pretty simple! To start, let’s handle our API keys by creating an <code>.env.local</code> file and fill in the variables below:</p><pre data-type="codeBlock"><code><span class="hljs-selector-tag">PINATA_JWT</span>= <span class="hljs-comment">// Pinata JWT from when we made our API key earlier</span>
<span class="hljs-selector-tag">NEXT_PUBLIC_TON_API_KEY</span>= <span class="hljs-comment">// TON API key we made through the bot</span></code></pre><p>After we have those keys in place, you will want to make a new file in the root of the project called <code>constants.config.ts</code> and put in the following code.</p><pre data-type="codeBlock"><code><span class="hljs-comment">/**
 * Change url to access the network
 * &lt;https://testnet.toncenter.com/api/v2/jsonRPC&gt; — testnet
 * &lt;https://toncenter.com/api/v2/jsonRPC&gt; — mainnet
 *
 */</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> <span class="hljs-variable constant_">TEST_NETWORK</span> = <span class="hljs-literal">true</span>;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> <span class="hljs-variable constant_">NETWORK</span> = <span class="hljs-variable constant_">TEST_NETWORK</span>
  ? <span class="hljs-string">"&lt;https://testnet.toncenter.com/api/v2/jsonRPC&gt;"</span>
  : <span class="hljs-string">"&lt;https://toncenter.com/api/v2/jsonRPC&gt;"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> <span class="hljs-variable constant_">EXPLORER_URL</span> = <span class="hljs-variable constant_">TEST_NETWORK</span>
  ? <span class="hljs-string">"&lt;https://testnet.tonscan.org&gt;"</span>
  : <span class="hljs-string">"&lt;https://tonscan.org&gt;"</span>;
<span class="hljs-comment">/**
 * Create your API_KEY in your Telegram account:
 * <span class="hljs-doctag">@tontestnetapibot</span> — for testnet
 * <span class="hljs-doctag">@tonapibot</span> — for mainnet
 *
 */</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> <span class="hljs-variable constant_">API_KEY</span> = <span class="hljs-string">`<span class="hljs-subst">${process.env.NEXT_PUBLIC_TON_API_KEY}</span>`</span>;</code></pre><p>One other small thing we will need to do is make a custom type exception for <code>window.ton</code>, just like we do for Ethereum. Make a file called <code>new-types.d.ts</code> in the root of your project and put in the following contents.</p><pre data-type="codeBlock"><code>interface <span class="hljs-keyword">Window</span> {
  ton: <span class="hljs-keyword">any</span>;
  tonProtocolVersion: <span class="hljs-keyword">any</span>;
}</code></pre><p>To make sure the new types are included in our project build settings you will want to add the filename to the array in <code>tsconfig.json</code></p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">"compilerOptions"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
    <span class="hljs-attr">"lib"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"dom"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"dom.iterable"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"esnext"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"allowJs"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"skipLibCheck"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"strict"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"noEmit"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"esModuleInterop"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"module"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"esnext"</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"moduleResolution"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"bundler"</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"resolveJsonModule"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"isolatedModules"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"jsx"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"preserve"</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"incremental"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"plugins"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
      <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"next"</span>
      <span class="hljs-punctuation">}</span>
    <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"paths"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"@/*"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"./*"</span><span class="hljs-punctuation">]</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">"include"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"next-env.d.ts"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"new-types.d.ts"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"**/*.ts"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"**/*.tsx"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">".next/types/**/*.ts"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
  <span class="hljs-attr">"exclude"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"node_modules"</span><span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span></code></pre><p>Now, we can navigate to our main app page <code>app/page.tsx</code>, clear out the boiler plate, and import some dependencies.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">constants</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../constants.config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">TonWeb</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"tonweb"</span>;

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
     
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>To start using the TonWeb library, we’ll import a constants, as well as create a new <code>TonWeb</code> instance.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">constants</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../constants.config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">TonWeb</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"tonweb"</span>;

const { NftCollection, NftItem } <span class="hljs-operator">=</span> TonWeb.token.nft;

const tonweb <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> TonWeb(
  <span class="hljs-keyword">new</span> TonWeb.HttpProvider(constants.NETWORK, {
    apiKey: constants.API_KEY,
  }),
);

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
      
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>With that completed, we can create a function that allows users to connect their wallet with us by adding the following code:</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">constants</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../constants.config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">TonWeb</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"tonweb"</span>;

const { NftCollection, NftItem } <span class="hljs-operator">=</span> TonWeb.token.nft;

const tonweb <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> TonWeb(
  <span class="hljs-keyword">new</span> TonWeb.HttpProvider(constants.NETWORK, {
    apiKey: constants.API_KEY,
  }),
);

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  const [walletAddress, setWalletAddress]: any <span class="hljs-operator">=</span> useState(<span class="hljs-string">""</span>);

  const connectWallet <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">if</span> (window.tonProtocolVersion <span class="hljs-operator">|</span><span class="hljs-operator">|</span> window.tonProtocolVersion <span class="hljs-operator">&gt;</span> <span class="hljs-number">1</span>) {
        <span class="hljs-keyword">if</span> (window.ton.isTonWallet) {
          console.log(<span class="hljs-string">"TON Wallet Extension found!"</span>);
        }

        const provider <span class="hljs-operator">=</span> window.ton;
        const accounts <span class="hljs-operator">=</span> await provider.<span class="hljs-built_in">send</span>(<span class="hljs-string">"ton_requestWallets"</span>);

        const walletAddress <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> TonWeb.utils.Address(accounts[<span class="hljs-number">0</span>].<span class="hljs-built_in">address</span>);

        console.log(<span class="hljs-string">"Connected accounts:"</span>, accounts);

        console.log(
          <span class="hljs-string">"Connected wallet address:"</span>,
          walletAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>),
        );

        setWalletAddress(walletAddress);
      } <span class="hljs-keyword">else</span> {
        alert(<span class="hljs-string">"Please update your TON Wallet Extension 💎"</span>);
        location.href <span class="hljs-operator">=</span>
          <span class="hljs-string">"&lt;https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd&gt;"</span>;
      }
    } <span class="hljs-keyword">catch</span> (e) {
      console.error(e);
    }
  };

  
  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
    
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>In this code, we do something similar to Ethereum where we get the <code>window.ton</code> object, check if there is a wallet connected and, if not, prompt the user to connect. Once they connect, we set the account to our <code>useState</code> for later. If the user doesn’t have a wallet, or if it’s outdated, we can give them a link to the extension.</p><p style="text-align: start">Once we have their wallet connected, we can start looking into creating the NFT collection. In order for this to work on TON, we actually need contract metadata, just like we do for individual NFTs, otherwise we won’t really see much on marketplaces or explorers. Thankfully, we can just as easily store this on IPFS as we can with the NFT itself! To handle uploads in a secure fashion, we’re going to take a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-upload-to-ipfs-from-the-frontend-with-signed-jwts?ref=pinata.cloud"><strong><u>“signed JWT”</u></strong></a> approach where we use a Next.js API route to generate temporary keys that we can use for uploads on the client side.</p><p style="text-align: start">To make this little API, we’ll make a route in our files with the path <code>app/api/key/route.ts</code> . Inside that <code>route.ts</code> file, we want to go ahead and put in the following code.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextRequest</span>, <span class="hljs-title">NextResponse</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;
const { v4: uuidv4 } <span class="hljs-operator">=</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">"uuid"</span>);
const pinataJWT <span class="hljs-operator">=</span> process.env.PINATA_JWT;

export const dynamic <span class="hljs-operator">=</span> <span class="hljs-string">"force-dynamic"</span>;

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">GET</span>(<span class="hljs-params">req: NextRequest, res: NextResponse</span>) </span>{
  <span class="hljs-keyword">try</span> {
    const uuid <span class="hljs-operator">=</span> uuidv4();
    const body <span class="hljs-operator">=</span> JSON.stringify({
      keyName: uuid.toString(),
      permissions: {
        endpoints: {
          pinning: {
            pinFileToIPFS: <span class="hljs-literal">true</span>,
            pinJSONToIPFS: <span class="hljs-literal">true</span>,
          },
        },
      },
      maxUses: <span class="hljs-number">1</span>,
    });
    const keyRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"&lt;https://api.pinata.cloud/users/generateApiKey&gt;"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        body: body,
        headers: {
          accept: <span class="hljs-string">"application/json"</span>,
          <span class="hljs-string">"content-type"</span>: <span class="hljs-string">"application/json"</span>,
          authorization: `Bearer ${pinataJWT}`,
        },
      },
    );
    const keyResJson <span class="hljs-operator">=</span> await keyRes.json();
    const keyData <span class="hljs-operator">=</span> {
      pinata_api_key: keyResJson.pinata_api_key,
      JWT: keyResJson.JWT,
    };
    <span class="hljs-keyword">return</span> NextResponse.json(keyData, { status: <span class="hljs-number">200</span> });
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> NextResponse.json(
      { text: <span class="hljs-string">"Error creating API Key:"</span> },
      { status: <span class="hljs-number">500</span> },
    );
  }
}</code></pre><p>With this method, we can create a temporary key that can only be used once and is limited to just <code>pinFileToIPFS</code> and <code>pinJSONToIPFS</code>. Now that we have our API endpoint ready, we can make the upload functions to handle files - like images and JSON data - for NFT metadata! Make a new folder in the root of your project called <code>utils/uploads.ts</code> and put in the following code.</p><pre data-type="codeBlock"><code>export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">uploadFile</span>(<span class="hljs-params">selectedFile: File | undefined</span>) </span>{
  <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>selectedFile) {
    console.log(<span class="hljs-string">"no file provided!"</span>);
    <span class="hljs-keyword">return</span>;
  }
  <span class="hljs-keyword">try</span> {
    const tempKey <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"/api/key"</span>, {
      method: <span class="hljs-string">"GET"</span>,
      headers: {
        <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
      },
    });
    const keyData <span class="hljs-operator">=</span> await tempKey.json();

    const formData <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> FormData();
    formData.append(<span class="hljs-string">"file"</span>, selectedFile);

    const metadata <span class="hljs-operator">=</span> JSON.stringify({
      name: `${selectedFile.<span class="hljs-built_in">name</span>}`,
    });
    formData.append(<span class="hljs-string">"pinataMetadata"</span>, metadata);

    const options <span class="hljs-operator">=</span> JSON.stringify({
      cidVersion: <span class="hljs-number">1</span>,
    });
    formData.append(<span class="hljs-string">"pinataOptions"</span>, options);

    const uploadRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"&lt;https://api.pinata.cloud/pinning/pinFileToIPFS&gt;"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          Authorization: `Bearer ${keyData.JWT}`,
        },
        body: formData,
      },
    );
    console.log({ uploadResStatus: uploadRes.status });
    <span class="hljs-keyword">if</span> (uploadRes.status <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-number">200</span>) {
      <span class="hljs-keyword">throw</span> <span class="hljs-built_in">Error</span>;
    }
    const uploadResJson <span class="hljs-operator">=</span> await uploadRes.json();
    const cid <span class="hljs-operator">=</span> uploadResJson.IpfsHash;
    console.log(cid);
    <span class="hljs-keyword">return</span> cid;
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-string">"Error uploading file:"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">uploadJson</span>(<span class="hljs-params">content: any</span>) </span>{
  <span class="hljs-keyword">try</span> {
    const data <span class="hljs-operator">=</span> JSON.stringify({
      pinataContent: content,
      pinataOptions: {
        cidVersion: <span class="hljs-number">1</span>,
      },
    });
    const tempKey <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"/api/key"</span>, {
      method: <span class="hljs-string">"GET"</span>,
      headers: {
        <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
      },
    });
    const keyData <span class="hljs-operator">=</span> await tempKey.json();

    const uploadRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"&lt;https://api.pinata.cloud/pinning/pinJSONToIPFS&gt;"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
          Authorization: `Bearer ${keyData.JWT}`,
        },
        body: data,
      },
    );
    const uploadResJson <span class="hljs-operator">=</span> await uploadRes.json();
    const cid <span class="hljs-operator">=</span> uploadResJson.IpfsHash;
    console.log(cid);
    <span class="hljs-keyword">return</span> cid;
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-string">"Error uploading file:"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>These two functions are pretty straight forward. For each one, we request a temporary key, then used it in our upload. <code>uploadFile</code> takes a file like an image and <code>uploadJson</code> takes any kind of object - both return a CID we can use for the NFTs.</p><p style="text-align: start">With the upload step complete, we can now create our other two TON functions in <code>app/page.tsx</code>. Like we mentioned earlier, we need the user to create a collection first, and once it’s deployed, we can mint NFTs to that collection. The collection metadata has several requirements such as a name, description, external link, image, and royalty points. Let’s add that code now to <code>page.tsx</code>.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">uploadFile</span>, <span class="hljs-title">uploadJson</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/utils/uploads"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">constants</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../constants.config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">TonWeb</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"tonweb"</span>;

const { NftCollection, NftItem } <span class="hljs-operator">=</span> TonWeb.token.nft;

const tonweb <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> TonWeb(
  <span class="hljs-keyword">new</span> TonWeb.HttpProvider(constants.NETWORK, {
    apiKey: constants.API_KEY,
  }),
);

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  const [walletAddress, setWalletAddress]: any <span class="hljs-operator">=</span> useState(<span class="hljs-string">""</span>);

  const [collectionName, setCollectionName] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [collectionDescription, setCollectionDescription] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [collectionExternalUrl, setCollectionExternalUrl] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [collectionRoyalty, setCollectionRoyalty] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>number<span class="hljs-operator">&gt;</span>(<span class="hljs-number">5</span>);
  const [collectionFile, setCollectionFile] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>File <span class="hljs-operator">|</span> undefined<span class="hljs-operator">&gt;</span>();
  const [collectionAddress, setCollectionAddress]: any <span class="hljs-operator">=</span> useState(null);
  const [nftCollection, setNftCollection]: any <span class="hljs-operator">=</span> useState(null);

  const [complete, setComplete] <span class="hljs-operator">=</span> useState(<span class="hljs-literal">false</span>);

  const connectWallet <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
		<span class="hljs-comment">// previous code...</span>
  };

  const deployNftCollection <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    const provider <span class="hljs-operator">=</span> window.ton;

    const collectionImageCid <span class="hljs-operator">=</span> await uploadFile(collectionFile);

    const collectionData <span class="hljs-operator">=</span> {
      name: collectionName,
      description: collectionDescription,
      external_link: collectionExternalUrl,
      image: `ipfs:<span class="hljs-comment">//${collectionImageCid}`,</span>
      seller_fee_basis_points: <span class="hljs-number">100</span>,
      fee_recipient: walletAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>),
    };

    const collectionUri <span class="hljs-operator">=</span> await uploadJson(collectionData);

    const nftCollection <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> NftCollection(tonweb.provider, {
      ownerAddress: walletAddress, <span class="hljs-comment">// owner of the collection</span>
      royalty: collectionRoyalty <span class="hljs-operator">/</span> <span class="hljs-number">100</span>, <span class="hljs-comment">// royalty in %</span>
      royaltyAddress: walletAddress, <span class="hljs-comment">// address to receive the royalties</span>
      collectionContentUri: `ipfs:<span class="hljs-comment">//${collectionUri}`, // url to the collection content</span>
      nftItemContentBaseUri: <span class="hljs-string">""</span>, <span class="hljs-comment">// url to the nft item content</span>
      nftItemCodeHex: NftItem.codeHex, <span class="hljs-comment">// format of the nft item</span>
    });
    console.log(<span class="hljs-string">"Collection data:"</span>, nftCollection);
    const nftCollectionAddress <span class="hljs-operator">=</span> await nftCollection.getAddress();

    console.log(
      <span class="hljs-string">"Collection address (changes with provided data):"</span>,
      nftCollectionAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>),
    );

    const stateInit <span class="hljs-operator">=</span> (await nftCollection.createStateInit()).stateInit;
    const stateInitBoc <span class="hljs-operator">=</span> await stateInit.toBoc(<span class="hljs-literal">false</span>);
    const stateInitBase64 <span class="hljs-operator">=</span> TonWeb.utils.bytesToBase64(stateInitBoc);

    provider
      .<span class="hljs-built_in">send</span>(<span class="hljs-string">"ton_sendTransaction"</span>, [
        {
          to: nftCollectionAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>),
          <span class="hljs-built_in">value</span>: TonWeb.utils.toNano((<span class="hljs-number">0</span><span class="hljs-number">.05</span>).toString()).toString(), <span class="hljs-comment">// 0.05 TON to cover the gas</span>
          stateInit: stateInitBase64,
          dataType: <span class="hljs-string">"boc"</span>,
        },
      ])
      .then(async (res: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
        <span class="hljs-keyword">if</span> (res) {
          console.log(<span class="hljs-string">"Transaction successful"</span>);

          setCollectionAddress(nftCollectionAddress);
          setNftCollection(nftCollection);
        } <span class="hljs-keyword">else</span> {
          console.log(<span class="hljs-string">"Wallet didn't approved minting transaction"</span>);
        }
      })
      .catch((err: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
        console.error(err);
      });
  };

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
      
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>At the top of the file, we import our upload functions and declare some new states. In our <code>deployCollection</code> function, we’ll first connect to the TON provider, then we’ll upload the image provided for the collection. With that CID, we’ll construct the metadata object for the collection, which takes in most of the parameters we’ll ask for in the front end. One nice thing to note is that we can use the <code>ipfs://</code> protocol url, as TON made the effort to support it in their ecosystem to help ensure persistent content, which you can read more about <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/how-to-ensure-nft-data-persistence-with-ipfs/"><strong><u>here</u></strong></a>.</p><p style="text-align: start">Once we have our <code>collectionData</code> ready we can upload it with <code>uploadJson</code>, which will give us a CID that will act as the <code>collectionUri</code>. Now, we can actually create the collection using <code>new NftCollection</code> from the TON library, where it is then passed through a state initialization, BOC (Bags of Cells) binary object, base6, which is finally passed into <code>provider.send</code> where we send the BOC data and prompt the user to sign the transaction. If all goes well, then we can set the <code>nftCollectionAddress</code> and <code>nftCollection</code> object for minting the NFT.</p><p style="text-align: start">Minting the NFT to the collection looks pretty similar. Let’s update our <code>page.tsx</code> file.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">uploadFile</span>, <span class="hljs-title">uploadJson</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/utils/uploads"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">constants</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../constants.config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">TonWeb</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"tonweb"</span>;

const { NftCollection, NftItem } <span class="hljs-operator">=</span> TonWeb.token.nft;

const tonweb <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> TonWeb(
  <span class="hljs-keyword">new</span> TonWeb.HttpProvider(constants.NETWORK, {
    apiKey: constants.API_KEY,
  }),
);

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  const [walletAddress, setWalletAddress]: any <span class="hljs-operator">=</span> useState(<span class="hljs-string">""</span>);

  const [collectionName, setCollectionName] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [collectionDescription, setCollectionDescription] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [collectionExternalUrl, setCollectionExternalUrl] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [collectionRoyalty, setCollectionRoyalty] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>number<span class="hljs-operator">&gt;</span>(<span class="hljs-number">5</span>);
  const [collectionFile, setCollectionFile] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>File <span class="hljs-operator">|</span> undefined<span class="hljs-operator">&gt;</span>();
  const [collectionAddress, setCollectionAddress]: any <span class="hljs-operator">=</span> useState(null);
  const [nftCollection, setNftCollection]: any <span class="hljs-operator">=</span> useState(null);

  const [name, setName] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [description, setDescription] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [externalUrl, setExternalUrl] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [file, setFile] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>File <span class="hljs-operator">|</span> undefined<span class="hljs-operator">&gt;</span>();

  const [complete, setComplete] <span class="hljs-operator">=</span> useState(<span class="hljs-literal">false</span>);

  const connectWallet <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    <span class="hljs-comment">// previous code...</span>
  };

  const deployNftCollection <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
		<span class="hljs-comment">// previous code..</span>
  };

  const deployNftItem <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    const provider <span class="hljs-operator">=</span> window.ton;
    const amount <span class="hljs-operator">=</span> TonWeb.utils.toNano((<span class="hljs-number">0</span><span class="hljs-number">.05</span>).toString());

    const nftImageCid <span class="hljs-operator">=</span> await uploadFile(file);
    const nftData <span class="hljs-operator">=</span> {
      name: name,
      description: description,
      image: `ipfs:<span class="hljs-comment">//${nftImageCid}`,</span>
      external_link: externalUrl,
    };
    const nftUri <span class="hljs-operator">=</span> await uploadJson(nftData);

    const body <span class="hljs-operator">=</span> await nftCollection.createMintBody({
      amount: amount,
      itemIndex: <span class="hljs-string">"0"</span>, <span class="hljs-comment">// Typically you will want to fetch the existing colleciton to see the next token id</span>
      itemContentUri: `ipfs:<span class="hljs-comment">//${nftUri}`,</span>
      itemOwnerAddress: walletAddress,
    });

    const bodyBoc <span class="hljs-operator">=</span> await body.toBoc(<span class="hljs-literal">false</span>);
    const bodyBase64 <span class="hljs-operator">=</span> TonWeb.utils.bytesToBase64(bodyBoc);

    provider
      .<span class="hljs-built_in">send</span>(<span class="hljs-string">"ton_sendTransaction"</span>, [
        {
          to: collectionAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>),
          <span class="hljs-built_in">value</span>: amount.toString(),
          data: bodyBase64,
          dataType: <span class="hljs-string">"boc"</span>,
        },
      ])
      .then((res: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
        <span class="hljs-keyword">if</span> (res) {
          setComplete(<span class="hljs-literal">true</span>);
          console.log(<span class="hljs-string">"Transaction successful"</span>);
        } <span class="hljs-keyword">else</span> {
          console.log(<span class="hljs-string">"Wallet didn't approved minting transaction"</span>);
        }
      })
      .catch((err: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
        console.log(err);
      });
  };

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
      
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>In this function, we follow the same pattern where we upload an image, use the image CID in the metadata, upload the metadata, which then leaves us with a <code>nftUri</code>. We can use the <code>nftCollection</code> object we made earlier to pass in that <code>nftUri</code> the same way we did before with the IPFS protocol url: <code>ipfs://</code>. Additionally, we can pass in things like the <code>itemIndex</code> which works like a token ID. Generally, you would want to use TonWeb to fetch the latest index and increment it, since it doesn’t happen automatically like most Solidity smart contracts. After we have our <code>body</code> complete, we can compile it to BOC, the bytes to base64, and finally send the transaction to the <code>collectionAddress</code>.</p><p style="text-align: start">With all of our functions ready to go, we can add in our JSX forms and fields.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">uploadFile</span>, <span class="hljs-title">uploadJson</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/utils/uploads"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">constants</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../constants.config"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">TonWeb</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"tonweb"</span>;

const { NftCollection, NftItem } <span class="hljs-operator">=</span> TonWeb.token.nft;

const tonweb <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> TonWeb(
  <span class="hljs-keyword">new</span> TonWeb.HttpProvider(constants.NETWORK, {
    apiKey: constants.API_KEY,
  }),
);

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-comment">// all our useState</span>

  const connectWallet <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
   <span class="hljs-comment">// previous code</span>
  };

  const deployNftCollection <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    <span class="hljs-comment">// previous code</span>
  };

  const deployNftItem <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    <span class="hljs-comment">// previous code</span>
  };

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
      {<span class="hljs-operator">!</span>walletAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span>button
          className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
          onClick<span class="hljs-operator">=</span>{connectWallet}
        <span class="hljs-operator">&gt;</span>
          Connect Wallet
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
      )}
      {walletAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>collectionAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>h2 className<span class="hljs-operator">=</span><span class="hljs-string">"text-3xl font-bold"</span><span class="hljs-operator">&gt;</span>Create NFT Collection<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>h2<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>Connected: {walletAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>)}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Collection Name"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{collectionName}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setCollectionName(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Collection Description"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{collectionDescription}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setCollectionDescription(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"&lt;https://pinata.cloud&gt;"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{collectionExternalUrl}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setCollectionExternalUrl(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"royalty percentage (e.g. 5 for 5%)"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"number"</span>
            value<span class="hljs-operator">=</span>{collectionRoyalty}
            onChange<span class="hljs-operator">=</span>{(e: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setCollectionRoyalty(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"file"</span>
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span>
              setCollectionFile(
                e.target.files <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> e.target.files.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>
                  ? e.target.files[<span class="hljs-number">0</span>]
                  : undefined,
              )
            }
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>button
            onClick<span class="hljs-operator">=</span>{deployNftCollection}
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
          <span class="hljs-operator">&gt;</span>
            Create Collection
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      )}
      {walletAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> collectionAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>h2 className<span class="hljs-operator">=</span><span class="hljs-string">"text-3xl font-bold"</span><span class="hljs-operator">&gt;</span>Mint an NFT<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>h2<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>Connected: {walletAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>)}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>
            Collection Address: {collectionAddress.toString(<span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>, <span class="hljs-literal">true</span>)}
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Name"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{name}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setName(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Description"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{description}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setDescription(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"&lt;https://pinata.cloud&gt;"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{externalUrl}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setExternalUrl(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"file"</span>
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span>
              setFile(
                e.target.files <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> e.target.files.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>
                  ? e.target.files[<span class="hljs-number">0</span>]
                  : undefined,
              )
            }
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>button
            onClick<span class="hljs-operator">=</span>{deployNftItem}
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
          <span class="hljs-operator">&gt;</span>
            Mint NFT
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      )}{<span class="hljs-string">" "</span>}
      {walletAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> collectionAddress <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>h2<span class="hljs-operator">&gt;</span>Mint Complete<span class="hljs-operator">!</span> 🎉<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>h2<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>a
            href<span class="hljs-operator">=</span>{`https:<span class="hljs-comment">//testnet.getgems.io/collection/${collectionAddress}`}</span>
            className<span class="hljs-operator">=</span><span class="hljs-string">"underline font-bold"</span>
          <span class="hljs-operator">&gt;</span>
            View NFT
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>a<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      )}
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>There’s a lot here, so let’s break it down a bit. In the beginning, we check if there is a connected address and, if not, show the button for the user to connect with. Then, we show the “create collection” section of our app. Once the collection is deployed, we show the mint section. Both of these sections use the state we declared earlier to fill in the fields of our collection and NFT metadata. Once the user has minted the NFT, we can show them a completion modal where they can view the NFT on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://getgems.io"><strong><u>getgems.io</u></strong></a>!</p><p>To see the full code for this tutorial you can check out the repo <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/PinataCloud/ton-nft-minting-tutorial?ref=pinata.cloud"><strong><u>here</u></strong></a>!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-wrapping-up"><strong>Wrapping Up</strong></h2></div><p style="text-align: start">While TON is a shift from what most Web3 developers are used to, there is a plethora of material to learn from and build whatever you want! Having a blockchain built alongside a social platform is truly powerful. Building on it means having a whole different layer of distribution, and Pinata is here to help you scale and keep your content persistent.</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/4642d5851f5259a813d942da03b418e9.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Organize Your IPFS Files With Groups]]></title>
            <link>https://paragraph.com/@pinatacloud/organize-your-ipfs-files-with-groups</link>
            <guid>xG4aKsP4vVeYoMZ0FbML</guid>
            <pubDate>Mon, 08 Jul 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[With Groups, you can now organize your files via the Pinata API or the web app.]]></description>
            <content:encoded><![CDATA[<p>Pinata has always been a collaboration tool. Developers working on NFT collections with artists. Agencies working with clients. Decentralized Finance protocols sharing order books with users. DAO documenting proposals and votes. The list goes on, but the fact is and has always been that Pinata is used by teams of various shapes and sizes. Even when a single person uses Pinata, the files they work with are often representative of external collaboration or need some sort of organization method.</p><p style="text-align: start">Earlier this year, we introduced Workspaces to make it easy for teams to collaborate, but there was still a missing ingredient. We needed to give everyone a way to organize their files. Today, that problem is solved.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-introducing-groups"><strong>Introducing Groups</strong></h3></div><p style="text-align: start">With Groups, you can now organize your files via the Pinata API or the web app. For developers using the API, this creates a new primitive that can enhance your app development experience. In the past, you may have used some combination of JSON files or Pinata Metadata to organize app-related files and to fetch those files for your app. Now, you can simply create a Group and store all of your app’s IPFS content in that Group. Fetching a list of content for a Group is incredibly fast and simple.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/b39ff737d6a001d85e8c05febb6161be.png" alt="" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAKCAIAAABaL8vzAAAACXBIWXMAAAsTAAALEwEAmpwYAAADWklEQVR4nE2S/28TdRjHP2F0wqTb2tV+Wdvr3fWuvaO3fll7ZbaMZCFrg4DERI0JxB/0DyD+LIkGAv6whGDAaXRxS+oAx0rTsUygrGmq0FnS0ts30SGSbjaiUTBGSaTt21yBxOSVd56fntfz5HlILoH8JG6cR/ECbiZRSkFJYzGNlVl8N4e1K7hzFXevoZrFRg61PO7n8WsefxTwYAF/LuCvIh6V8G8ZjxU0l4BlYBW4/Yw1kPxZtfvXk5ifQD6h1oUvn8puXcRiCktprLZkP7S48xV+yqA6j40sarmnvt+v40Gh5VvA3zfxTwlYUburAnX2JF6Lf+By7Jb4/Tw17KKG3fZhoZUeOuahYxIT8zCxgHtv1PdKRDogC3sC3HCAj/Xz8ZArLguxJ4TF+IAYj0ovedmdh984jvWWoDiN4jQG+g51Eaths1NHKB1xdLSpdLbTnZsZNYlDRyjTc6xVv92iF7u3ctvanXpi1xP7NtLb9YzuVho0NkI64wOvowbcAykmVcEu31vcFkHQBXh9gNP7nU7Z6Qyz/gjniQhShKG9ktkfsgb9XNjvjpjoHax3t9cZ8jL9nFVkzG7WouLsFQSzJNoC5g77gcE31Q2qIKUUSknI0kHrJnbIENXSgxrnkNjt39UT4aiQRRoS3XJkx6BA+9yMJNAeLy+5bILEiH285Oe9ft7r5SQfJwVc3oCrL8QEZT7a20W/vPOgKlgHqaTVk0b9h3TEbm7jtBr+ea3QuYmxtnMmDavdyvfo+Rf0Qk8bqyX27ha6/6Entp42+xMMGsqgsZu2UB1Ev2fgVVXwM4iSVjfYN/iOsWu73Sg7jEHK0E8bg5Q5SJuCTlOQMQZZU5C1hDirzFtll01Nt01FsKuIlCw6wh5HuK+Fj32Rs0hv7z+MKlADWZ5B5SKSpx5+9K4yeqQ8eqT0yXvlT98vf3a0PH60PH6sPHGsnDh+64sTlckTlXMjytRIZWqkMn1SSZ1UUqeUmQ8rl04rs2eUudPK5TPK1VEl8/Fybmy1euUR7gL3QVZn1U8vnMX858iM1bNjj7Pj9dx4PT/RuJ6o30g0CpONb881S+dRmqpXLjQWk42lVGMl1bw90/z+EtZmmz/O4d5lrGewkUHtGn7J4uE3gKJeGL/hP++QxQuOFqDCAAAAAElFTkSuQmCC" nextheight="644" nextwidth="2000" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p style="text-align: start">If you’re using the web app, it couldn’t be simpler. You have three ways to add files to a Group:</p><ol><li><p>From the context menu of a file, you can add a single file to a Group</p></li><li><p>From the Groups page, you can add new files to a Group</p></li><li><p>From the files page, you can use our bulk select tool and use the add to Group bulk action</p></li></ol><p style="text-align: start">When you visit the Groups page, you can see all of the files just for that Group. This makes organizing projects, whether they be NFT collections, student assignments, research papers, or anything else simple.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-groups-or-folders"><strong>Groups or Folders</strong></h3></div><p style="text-align: start">Groups look and feel like folders, but they are distinctly different because IPFS natively supports folders. As you may have experienced in the past, if you upload a folder from your file system to Pinata, the entire folder is pinned to IPFS. When you access that folder, all of the files in the folder (which are also pinned) are accessible.</p><p style="text-align: start">With Groups, you can organize content without requiring individual files to live in an immutable folder. In fact, you can organize folders of files inside Groups. Conveniently, the mutability of Groups means you can move files and folders between Groups.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-organization-and-collaboration"><strong>Organization and Collaboration</strong></h3></div><p style="text-align: start">Combined with the power of Workspaces, Groups gives you a whole new way to stay organized. We have many customers with millions of files pinned through their accounts. Staying organized when you have that many files is difficult. Groups solves this.</p><p style="text-align: start">If you’re working on a team, you can switch into your team’s Workspace and help collaborate on Groups starting today. Groups created and updated in the web app are available via the API, so whether you’re technical or more visual, everything stays in sync.</p><p style="text-align: start">Start using Groups today and organize your files. Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/0dea45cbda52f74e32d0d7a95505ae89.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Insights from Pinata’s Intern Program]]></title>
            <link>https://paragraph.com/@pinatacloud/insights-from-pinatas-intern-program</link>
            <guid>dSeHzbU6TExTIO5EHx3Q</guid>
            <pubDate>Mon, 08 Jul 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Each year, we are consistently impressed by the talent and inventiveness of the students and recent graduates who choose to spend their summers with us.]]></description>
            <content:encoded><![CDATA[<p>This year marks Pinata’s third summer intern program <span data-name="hooray" class="emoji" data-type="emoji">🥳</span>. Each year, we are consistently impressed by the talent and inventiveness of the students and recent graduates who choose to spend their summers with us. Rather than just raving about how great they are, we invite you to hear from them directly about their experiences and get tips on standing out during the application process.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-intern-insights"><strong>Intern Insights</strong></h2></div><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-lets-start-by-telling-us-a-bit-about-yourself"><strong>Let's start by telling us a bit about yourself.</strong></h3></div><p style="text-align: start">Howdy! My name is Connor Kildare. I was born and raised in Lincoln, Nebraska, and currently attend the University of Nebraska-Lincoln as a Senior in Software Engineering with a minor in Mathematics and a focus on AI &amp; Machine Learning. My focus while working during school has been to diversify my experiences, allowing me to explore a variety of career paths and technologies. I marked my entrance to software development in VR but have since moved to working with machine learning, user experience, and optimization. In my free time, I like to cook, bake, plan events, and hang out with my family.</p><p style="text-align: start">Hello! My name is Yongjie Xue. I have always been interested in programming and AI technology. I graduated with a master's degree in computer science from the University of Nebraska-Lincoln in 2024. During my studies, I took an Internet Programming class, which intrigued me and inspired me to delve deeper into the world of software development. This experience led me to decide to pursue a career in this field. I enjoy photography, horticulture, and watching movies in my leisure time.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-what-stood-out-about-pinata-or-the-interview-process-when-you-applied"><strong>What stood out about Pinata or the interview process when you applied?</strong></h3></div><p style="text-align: start">Connor: Pinata was very accepting about my lack of experience with IPFS, knowing I came prepared to learn. This openness made me feel comfortable knowing I was interviewing for an internship that cared about what I wanted to do and learn. My past few weeks here have only confirmed that feeling, allowing me to take charge of projects and find ways to pair my work with my interests.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-what-have-you-enjoyed-working-on-the-most-so-far"><strong>What have you enjoyed working on the most so far?</strong></h3></div><p style="text-align: start">Yongjie: Gosh, I’ve enjoyed so many things during this internship. Firstly, I enjoyed working on the frontend development projects. As a visual person, I love seeing the website improve little by little. It gives me a sense of achievement to see everything I built, and at the same time, I’m constantly learning something new. Furthermore, whenever I encountered technical questions, every team member was always willing to help and give advice. The combination of supportive colleagues and a positive work environment have made this experience truly enjoyable for me.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-how-have-you-made-connections-with-the-team-while-being-hybrid"><strong>How have you made connections with the team while being hybrid?</strong></h3></div><p style="text-align: start">Connor: I have made an effort to stay communicative about the issues I work on, which allows me to confirm requirements and build a connection with my coworkers. These technical discussions often lead to more personal conversations and non-technical meetings called “virtual coffees,” where we drink coffee and talk about what comes to mind! This approach has allowed me to feel less disconnected from my coworkers despite the nature of remote work.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-what-role-have-your-manager-and-mentor-played-during-your-internship"><strong>What role have your manager and mentor played during your internship?</strong></h3></div><p style="text-align: start">Yongjie: My manager and mentor have played crucial roles during my internship. My mentor, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/people-of-pinata-paulo/"><strong><u>Paulo</u></strong></a>, provided extensive hands-on training, including pair programming, to demonstrate how he approaches and solves technical issues. He meticulously reviewed my pull requests, offering valuable feedback on code cleanliness and debugging techniques, significantly enhancing my technical skills. Meanwhile, my manager, Justin, helped me understand the company's goals and identified key contacts within the organization for any questions I had. Paulo and Justin's regular feedback and evaluations every few weeks were instrumental in helping me recognize my strengths and areas for improvement. Their combined support was invaluable to my professional growth during the internship.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-advice-for-applying-to-our-intern-program"><strong>Advice for Applying to Our Intern Program</strong></h2></div><p style="text-align: start">Applying to and interviewing for internships can be daunting. We strive to make the process as straightforward as possible, understanding that students juggle many responsibilities, including academics, work, extracurriculars, and caretaking. However, a simple application doesn’t always provide as many opportunities to stand out, especially when we receive hundreds to thousands of applications.</p><p style="text-align: start">Here are a few ways students have successfully distinguished themselves beyond their application:</p><ul><li><p><strong>Involvement in relevant organizations and communities:</strong> Many campuses have blockchain or startup/entrepreneurship organizations. Even if your school doesn’t have a similar club, you can join numerous web3 and blockchain communities to learn and network. Warpcast and College DAO are great places to start.</p></li><li><p><strong>Building projects using our developer tools:</strong> We love to see or hear from students who have built projects using Pinata. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/?ref=pinata.cloud"><strong><u>Get started with a free account</u></strong></a>, and tell us what you create!</p></li><li><p><strong>Sending quality follow-up messages:</strong> One of the most effective ways to stand out during the application process is by sending thoughtful follow-up messages. We recommend avoiding generic messages; instead, highlight a few things you’re excited about and reiterate your relevant experience, skills, and achievements. You don’t have to set up a call for every role you’re interested in, but this will help you stand out in the sea of applications.</p></li></ul><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-what-we-look-for"><strong>What We Look For</strong></h2></div><ul><li><p><strong>Entrepreneurial experience or spirit:</strong> Whether you ran your own company, built an app, or created a product for a school project, we want to see that you’re passionate about entrepreneurship—a key component of startups. Even if you don’t have direct entrepreneurial experience, we value seeing how you approach risk-taking and creativity.</p></li><li><p><strong>Initiative and Proactiveness:</strong> We highly value students who take the initiative in identifying areas for improvement and finding solutions. Our interns demonstrate a proactive attitude by suggesting new projects, finding ways to improve existing processes, and enhancing team efficiency.</p></li><li><p><strong>Adaptability:</strong> Adapting to new challenges and pivoting when necessary helps you acclimate to the startup environment. We look for interns who can easily handle change and are open to learning new skills. Flexibility and a positive attitude towards change contribute to both personal and team success.</p></li></ul><p style="text-align: start">If this sounds like you, our internships will be posted late this fall, and we would love to see your application!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/4f65decf3157dbc56584aa38e78cd002.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How To Manage Your IPFS Costs With Analytics And Image Optimizations]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-manage-your-ipfs-costs-with-analytics-and-image-optimizations</link>
            <guid>dVAtyXrFz6WI4CGVE5wp</guid>
            <pubDate>Tue, 02 Jul 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Get the most out of your Dedicated Gateways while also saving money using Analytics and Image Optimizations.]]></description>
            <content:encoded><![CDATA[<p>When building with IPFS, like all other tools, you have to be able to understand your potential costs and mitigate those costs. While there’s a common misconception that IPFS is or should be free, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/how-much-does-an-ipfs-pinning-service-cost/"><strong><u>we’ve written in the past about why that simply can’t be true</u></strong></a>. So, accepting the fact that as a developer, you’ll probably be spending money to build a successful app, let’s explore what costs you might incur and some of the tools available to help you optimize those costs.</p><p style="text-align: start">There are two things your app will likely need to do when it comes to IPFS: Upload content and retrieve content. Uploading content is a pretty static cost and relatively predictable. Even if your app allows for a significant volume of user-generated content, you can generally determine the approximate number of files being uploaded every month and the size of those files. From there, you can calculate your estimated monthly cost for storage. With Pinata, all plans include a certain allotment for storage and total files. On our paid plans, you can go beyond this allotment and pay a usage fee. So assuming you have a grasp on your estimated storage volume per month, you can calculate the increase (if there is one) in storage costs.</p><p style="text-align: start">Retrieving content presents a totally different challenge. Humans are consumers more than they are creators. This is especially true when it comes to how people use applications. Imagine a social app. Which do you think happens more frequently, users scrolling through posts or users creating posts? I think we’d all agree with the former being more common and less predictable. On any given day, content may be consumed at a greater volume than the day before. This applies beyond social apps as well.</p><p style="text-align: start">With NFTs, the bandwidth and requests associated with loading NFT media can be unpredictable. A relatively obscure NFT may start with a few requests and limited bandwidth transfer, but it just as easily can catch fire and suddenly, that same NFT is doing hundreds of thousands of requests and resulting in hundreds of gigabytes of data transfer.</p><p style="text-align: start">This unpredictability can be frustrating for developers in the IPFS space because, unlike traditional web infrastructure, there have been very few tools built to help developers monitor and respond to usage spikes. Fortunately, that has changed with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/introducing-analytics/"><strong><u>Pinata’s Gateway Analytics</u></strong></a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/gateways/image-optimizations?ref=pinata.cloud"><strong><u>Image Optimization tools</u></strong></a>. Let’s dive into how developers can use these tools to monitor and respond to spikes in traffic.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-gateway-analytics"><strong>Gateway Analytics</strong></h3></div><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/10fb54a2b8df7964d4a128fe8311d108.png" alt="dashboard" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAUCAIAAABj86gYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAE2ElEQVR4nLWU32/bVBTHrT0h9SUqk9Ztbeo6jn/bcR3HdRw7/hH/imM7SZO2WVKvqdus7UZGy1Ch4scmTUg88QAve+MBCQRPIMHTxoT2J/CAkHjnP+A5yHHabRVC4oGrj67Ovbr3fO+955wLAABwdvbO48cPT08/uPd6Oz09vTR8NG2X5v+xHR6Ox+N3AQAA3pifvxvHozt7UbQfRfFgMBwMhqkxHj/Y2RlFUbwT7Ufb8dHR22dnD8/e//jwcJyuiaI43j1I11wwGAzj3cPR6N7u7uH8/HyiIRTl+PZbph5CIIXAqyjMoTAHQywE0nmIzUMsjpRwhM+BTEo6mYdYFOYIVCBQAUd4FOawPJ+HVqEs1e+Nvvn6h+sL0I0bNxIBlpba4bahhTDEpn4RmOMYpcipHKOQWLIfR/jUVwqWnw1xpITAHEVKHKOkYHm+QFRUpQFm8UwmA2QyGSRfLBCVIqdiqJAKcIwSD8d39k9ubx/JkstzmsDrU2o8p6T2xSRDSr3NvZPjjwb9g0H/oCp7yRZWgyF6JpADKY5RYIjNLuEQSEMgjSGlwOsZms+QFVEwUwRe5TlZkQK/Pg4ax5Jgi0IiQOFi6G61w21ZclPi4bjhbi0vTW8wd2UOyxdTF1ieB7MkBNIEKgRez9TDV84rV6vrrrUfNE6c2l7DvetYMc/JPKsxpGRWA8dom3rL1FsCr2uKryk+BJKpwBUcFW1jo253i5xK4SIyDV3D3bTMTllwJdERBd3UBy3/JPFbixOsOGgcl0WH5xSGlFruwLM6PKelGFpom+srqQAAAKsFxTI7LC3BEIPlizDETm+w1WnfC7zEacO9G3j3rdrQ0odObc+pxZY+bNTHpj7gChJDSuv1zcDdmh7FFHhdll1dfXmDORTly6Jd5NQcyKRPROGioTUcq+/UYteK6/Zoauxfohk8EAWbIcuu0fHcTVly00Sqyp6hhTOBTCYDLdMELhY5hSLFNMgULkqibRsbhtY2tLZpJkbN6LxqaNWmoXdlqUHhoqU1+71Rt7VTtzdcuxt4tzQleCmwkk2SJz37LIvyPENKFC5S+Nq0PzfIyzMMWSYxwbO6od8PvJ6m+LLkmnooSzYEnqfpShbPgYUL7/8JMEsiMOdZG3Wze/FKhha+9kSXBNJayy7hizexi8r4F2CIpYlygaoUqApDSgWqwhUS+7UY5EA2BxZS0jqoynVD81XFS7exdJItlyBQgcJFAi1JYk1VGrrqi4LJkOUpFRhiZwLZRRTMkmCWOIfkGOX4/odHdx40/W2e0y7+mVf+jIQkpGaHwstNfzvqHTTNW+1wAOfXVtkqX1RAEMlkriUCMLRKYAqGyBgi41glzSLbXG/6fWfaB14v8G41/b6ph8kLnOt57qbnbs5ijgif/fb9n389nzz7XKnIvvWo6X6aVBkAAFH/yYunk1+eTl48m3z31WSN36BJwTI762HUbQ27rZ2psdNtDR2jIwmWLDqy6EiCZWgt2+yUeJ1aEb78/afnkz+MivPzj09eTH6V+f7a6tZMYHmJYag6Szss7VBE7fo16ObNHE3yYqlaKdfEkiqWVKmsVso1Ai8ugxgE4hCILy+jBF4US2p2Mbe4sPLet5+w5fKbcwtXV4hHT7+AYfjqm1cXFhZmGv9f+xs59bX7IgDB/gAAAABJRU5ErkJggg==" nextheight="2004" nextwidth="3248" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p style="text-align: start">With Gateway Analytics, you can see the last 30 days (if you’re on the Picnic Plan) or 90 days (if you’re on the Fiesta or Enterprise Plans) of bandwidth and request data for any of your gateways. Unlike surface level usage metrics like total bandwidth and total requests, Gateway Analytics allow you to see important details that can drive your decision-making.</p><p style="text-align: start">You’ll be able to easily spot spikes in usage and see what the contributing content identifiers (CIDs) are.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/10b800d3cc7803952c90a161d98d91f9.png" alt="dashboard" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAJCAIAAADcu7ldAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB70lEQVR4nGNgYRDlYhUX4JFBQ9yskpQjFgZRBm5WSXVlI2V5PWV5XVUlQ3lpLXlpLSU5HW1Nc/KQga61ga61trq5urKxiKA8yAIrc7eb155+fPf3zcsf///8v3Ht0f8//+2svdSVjbXVzUlCyvJ6kuIqkuIqslIamiqmEmLKIAvMjB37e2bPmbVi4ZzVUaFp/t7R3u5hBtrWZJge6BMzsXduT+eMguwaK3M3USEFkAUG2tYlRY3NDf0dLVMMtK1lpTTkpbWU5fXUlY0hSFXBUFXJEEQqGEJEcFkQE5GxeP7aib1zK8paoRbwsklqq5trqpm5Owe1NU/q753T0zljysQFUyctnDF16ZSJ8/t750ydtHBi79z+ntkzpi5eOH9toE8MVjuM9GzkpbWszN3cnYO83cPMjB3FhBShPgjwiwv0ia2t6qqt6Kit6CgraASxq7oqyloh7Iqy1oqy1tqKjsaabm/3MFyeUFc2Tk8qrq1oKylqtLP2AvmAnUFcXcXEQNvGytzNwswVgsyMnbCyIcja3B0PgoQVKIRVTEAWiAkpQjyVnVa2fMmmKRPnr1iyZdumQwvnrF48f/3USQuXLd60ae3exfPXL1u8acWSLWtX7nSy9zPQtjYzdsREBtrW/t7R2Wll6UnFTvZ+MlLqAFKZ4nfOHRC2AAAAAElFTkSuQmCC" nextheight="358" nextwidth="1212" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p style="text-align: start">Armed with this information, there’s a lot you can do. For example, you might simply be interested in what content is performing best. Seeing the CIDs with the highest request volume or bandwidth volume can tell you that at a glance.</p><p style="text-align: start">If you’re concerned about cost, though, this data becomes equally valuable. Some common issues we’ve seen Gateway Analytics uncover include bugs in a developer’s code and unoptimized media. Bugs in code are usually a quick fix, but having the data to discover there is a bug in the first place–say a recursive loop–is vital. Gateway Analytics provides that.</p><p style="text-align: start">For unoptimized media, developers can combine Gateway Analytics with another important tool: Image Optimizations.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-image-optimizations"><strong>Image Optimizations</strong></h3></div><p style="text-align: start">IPFS Gateways, by default, return media in their original format. If you our your users uploaded a 50mb high-resolution image, that’s what IPFS and your gateway are going to return when the image is queried. However, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/what-is-a-dedicated-ipfs-gateway/"><strong><u>Pinata Dedicated Gateways</u></strong></a> have built-in image optimization functionality to help you control the size of images returned.</p><p style="text-align: start">Rather than having your app or website return the full-size image, you can use query parameters on the image URL to control the size. That 50mb image can be resized to a more reasonable 1mb and can be fit to the specific components of your app not only reducing your cost but also improving your app’s performance.</p><p style="text-align: start">Performance is a key factor to retention, even more so if your app is in a competitive market. NFT marketplaces, for example, have grown incredibly competitive. Every millisecond of latency can increase the chances of a user going to another marketplace. Using Image Optimizations can literally mean the difference between a retained customer and a customer lost to a competitor. Of course, this is generally applicable beyond just NFT marketplaces.</p><p style="text-align: start">Perhaps more important to early stage companies and developers, though, is the control over budget that Image Optimizations provide. We’ve seen customers use Gateway Analytics combined with Image Optimizations to slice their bills by as much as 50%.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-conclusion"><strong>Conclusion</strong></h3></div><p style="text-align: start">Pinata Gateway Analytics and Image Optimizations are available for all paid customers. If you’re building an app and you want to manage your cost, which almost every successful business does, then, these two tools are vital for your success.</p><p style="text-align: start">Get deep understanding of how your media is being consumed, then take action as necessary. Get started with Gateway Analytics and Image Optimization today.</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/38a05d1ca1cc1e1dbd452594263c95c6.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Introducing API Key Filtering And Search]]></title>
            <link>https://paragraph.com/@pinatacloud/introducing-api-key-filtering-and-search</link>
            <guid>qVMNh14btNmrMMiiMuzd</guid>
            <pubDate>Fri, 28 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Manage your API keys even easier with filtering and search functionality through the API and web app.]]></description>
            <content:encoded><![CDATA[<p>In 2020, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/pinata/introducing-scoped-api-keys-48e808623d5d?ref=pinata.cloud"><strong><u>we released Scoped API Keys</u></strong></a>. This gave developers flexibility and granularity when creating API Keys. It was a huge step forward and allowed developers to build interesting experiences.</p><p style="text-align: start">We saw NFT marketplaces use this functionality to give their users a single-use key to upload NFT images from the browser. We saw organization manage their workload and security by generating keys with limited access. We saw developers expand the power of serverless by <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/how-to-upload-to-ipfs-from-the-frontend-with-signed-jwts/"><strong><u>generating API keys through a serverless function</u></strong></a> and allowing them to be used on the client-side. The use cases go on and on.</p><p style="text-align: start">Since releasing Scoped Keys, developers have created over 15 million API Keys! While that number is staggering, we’re not done yet. We want to continue making the lives of developers easy, and are excited to announce new filtering tools for Scoped API Keys.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/6db53d260aca43180c68f03d879b4bba.png" alt="" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAPCAIAAAAK4lpAAAAACXBIWXMAAAsTAAALEwEAmpwYAAADRElEQVR4nKVU32vTUBTOf6CiMBBE/Ik/UFHxSUR8Udj24EQUn8SHTRHBTVCxrmPtbMvGftl2dqUkmSarNM4mrmuhTZU0y5pQm6JtxpJuSzpcugedOirT6HTSXSh97+F7+A7ce757vnvuhVJpMZuTsjkpLWbSYgbwWsCw3Hvx/QvsxeTUpKqqkKzkZSWvF5dKpdL3lRWQ1oIkL2Cjr+obrt5tbWcnBajt3gOoKlStUEv1nDTzfeVbdUHI4/U1NDReuXJtz979x46fDJJUjR3Mzc8PPcPa7tnazX1vxumyRas/V1d//TKM36XSj0VdX17+Wgs+f1k2DGPt75+1f2vFYhFaWPgkKwpFjTMJ1jCM9Zpjbq5g7uianpazH+WFhU9l00ul0vJGGDXH+vq/qSnx5q2HbjeGouTs7DyUzUmqpslKvqy5MWcVUoE0MwP8zeakagImosI3iDLqf71p8+6zZy91dQ0xLAeFI9EDB49ev9FsMlvuP3x8+07r+QuNnVa7zd7dabWbzBaT2XL6zLmdu/YdPXGqte3B4SMnDh05Dsi2uu31jRev32iu275jy9a65pbb9Y1NF5sumx6bWlpaaJoOEGMQz6ccjp6e3n6G5RiWo+m3ILXZuy1WG4b7eT7V2zfYbu4MR6IMy1msdoejh2E5kgqNT4QZliOIoM3ePT4R5pK8D0ZhBO3vH7Bau/L52SQvQDlpBsP9zzFM1QoAMDICI6jT5R54+jRGx/XiUoAgfDACfICRkQBBLOo6SPXiUpIXcNwPOE2/DZIUjvtjdNwwjLQoQmLmA0mFSCoErMzmJAzDUfR5gCCGPMNBklK1AkmFnC53khdkJR8gxkgqVH0fPJ8Cr0fVCgzLjY6+lKRpDMMtVpuqFcoCAYLweH1pMQO2+WDE6XLDyIjT5QYCr4Ok0+UWhJSs5D1eH4yMVN8tk2BhBAU8RscxDFe1QpIXwpFoWSCbkzxeX5IXKiPhcPT09g1YrLZH7R1jwaBeXPIMe5/YHaDioNPlGfbKSh4cCAg4XW7Aw5EojKCLug6aXtT1sgCTYMFqgBgdj9HxcCQao+PAFibBToQjQCBGx5kEW/03pMXMOyZR4UyCBR28YxKqVvgPw0Y+2O9/nZoAAAAASUVORK5CYII=" nextheight="1066" nextwidth="2274" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p style="text-align: start">In the past, we would show all keys ever created, including revoked keys and keys that had exhausted their limited uses. This made for a cluttered experience and it was difficult to find previously created API Keys.</p><p style="text-align: start">To solve this, we have introduced filtering and search. Whether it’s through our API or through our web app, developers can easily filter API Keys by the following:</p><ul><li><p>Active</p></li><li><p>Revoked</p></li><li><p>Exhausted</p></li><li><p>Limited</p></li></ul><p style="text-align: start">In addition, if a developer wants to find a key by the name they provided, we added a new search feature. This makes for a convenient and easy experience when trying to find a specific key.</p><p style="text-align: start">API Keys are a powerful tool for developers building apps on IPFS. Now, they are even easier to use and find later.</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/1fdcf9c8823c749c546f3e37b76c9432.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How to Ensure NFT Data Persistence with IPFS]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-ensure-nft-data-persistence-with-ipfs</link>
            <guid>vLLeEZgFqWvXHQZFivMq</guid>
            <pubDate>Thu, 27 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn about the strategies we can implement to ensure our precious NFT data remains decentralized and persistent.]]></description>
            <content:encoded><![CDATA[<p>Over the last several years, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/what-is-an-nft/"><strong><u>NFTs</u></strong></a> have taken the world by storm. Behind the scenes, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/what-is-ipfs/?ref=pinata.cloud"><strong><u>IPFS</u></strong></a> has been the unsung hero keeping all that unique data safe and sound. However, as blockchain technologies evolve and more Layer 2 solutions emerge, there's still a tendency to fall back on centralized storage. But fear not! There are strategies we can implement to ensure our precious NFT data remains decentralized and persistent. And this responsibility lies with both creators and platforms.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-empowering-nft-creators"><strong>Empowering NFT Creators</strong></h2></div><p style="text-align: start">When it comes to NFTs, creators hold the keys (quite literally) to where their NFTs will reside. The decision on how to store NFT data often needs to be made before minting, dictated by the smart contract, and it’s usually set in stone once minted.</p><p style="text-align: start">One crucial element here is the <strong>Token URI</strong>. This little URL is the backbone of your NFT, directing to the metadata and, ultimately, the asset itself. There are a couple of IPFS link options for this:</p><ul><li><p><strong>Protocol URL </strong>(<strong>ipfs://</strong>)<strong> -</strong> This is the gold standard for autonomous data storage. Sure, you can't just plop it into your browser and see your content. But it encourages marketplaces and platforms to utilize a gateway to fetch and render the content, ensuring longevity and reducing dependence on any single HTTPS URL that might go kaput.</p></li><li><p><strong>Gateway URL </strong>(<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://example.mypinata.cloud"><strong>https://example.mypinata.cloud</strong></a>) <strong>-</strong> This is your quick and easy solution. It makes the content accessible right in your browser. However, it can lead to a crutch where platforms rely on this specific gateway, potentially compromising the decentralized ethos in the long run.</p></li></ul><p style="text-align: start">At the end of the day, both options work because they include <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/blog/what-is-an-ipfs-cid/"><strong><u>the CID</u></strong></a> in the URL. This CID is like a fingerprint for your content, allowing anyone to fetch the data from IPFS.</p><p style="text-align: start">Creators can also foster a sense of community by <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/pinata/who-is-responsible-for-nft-data-99fb4e8147e4?ref=pinata.cloud"><strong><u>sharing the CIDs</u></strong></a> of their NFTs, just like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://boredapeyachtclub.com/?ref=pinata.cloud"><strong><u>Bored Ape Yacht Club</u></strong></a> has done. This practice not only promotes transparency but also encourages the broader community to participate in data persistence.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-responsibility-of-nft-platforms"><strong>Responsibility of NFT Platforms</strong></h2></div><p style="text-align: start">NFT platforms, like marketplaces, play a pivotal role in ensuring IPFS content is rendered correctly. When these platforms index data from the blockchain, encountering <strong>ipfs://CID</strong> shouldn’t be a deal-breaker. Instead of writing off the NFT as broken, they should employ a gateway to fetch and display the content.</p><p style="text-align: start">For a marketplace to stand out, supporting popular ecosystem standards like IPFS is a no-brainer. Tools like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/PinataCloud/ipfs-gateway-tools/tree/master?ref=pinata.cloud"><strong><u>IPFS Gateway Tools</u></strong></a> can convert any IPFS link into a preferred gateway link, including <a target="_blank" rel="noreferrer" class="dont-break-out" href="https://docs.pinata.cloud/gateways/dedicated-ipfs-gateways?ref=pinata.cloud"><strong><u>Dedicated Gateways</u></strong></a>. These dedicated gateways are the real MVPs – they're faster, free from rate limits, and come with nifty features like built-in CDNs and on-the-fly image optimization.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-wrapping-up"><strong>Wrapping Up</strong></h2></div><p style="text-align: start">By embracing protocol IPFS URLs and leveraging Dedicated Gateways, we can collectively ensure the persistence of NFT data. It’s up to both creators and platforms to champion these practices, fostering a more resilient and decentralized digital art ecosystem. So let’s keep our NFTs safe and accessible! Happy Pinning <span data-name="sparkles" class="emoji" data-type="emoji">✨</span></p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/ce61f9a6c96a536fe5fba1f726f49815.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[IPFS Gateway Analytics: Available On All Paid Plans]]></title>
            <link>https://paragraph.com/@pinatacloud/ipfs-gateway-analytics-available-on-all-paid-plans</link>
            <guid>JrkCYzF5zbgWr9U1ArHO</guid>
            <pubDate>Thu, 20 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[We’re excited to announce that Gateway Analytics are available on all paid plans, including the Picnic Plan.]]></description>
            <content:encoded><![CDATA[<p>In 2021, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/pinata/announcing-dedicated-ipfs-gateways-60f599949ce?ref=pinata.cloud"><strong><u>Pinata launched the first-ever Dedicated IPFS Gateway</u></strong></a>. The idea behind this product came from insights gleaned through countless customer conversations. We heard over and over again how IPFS was slow. This didn’t track in our minds, though. IPFS could be slow, but all servers could be slow. It was through those conversations that we realized the real knock was on public IPFS gateways. These public gateways were not optimized for production use, and they were heavily rate-limited. So, we build Dedicated Gateways for our paying customers and brought IPFS performance up to the standards developers had for traditional content retrieval.</p><p style="text-align: start">Since then, we’ve continued to iterate and improve on Dedicated Gateways. Every month, hundreds of terabytes of data passes through our customers’ Gateways. Every month billions of requests are sent to our customer’s Gateways. That data is valuable for our customers, so we built <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/introducing-analytics/?ref=pinata.cloud"><strong><u>Gateways Analytics</u></strong></a> to provide insights into how Gateways were being used.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/d0a71e28032d1137932a0359b96c5d57.png" alt="" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAUCAIAAABj86gYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFD0lEQVR4nLWUzW/bZBzHPS4IelikaaV7qec6jt/jpI7zxHHsxO+xE+eteWmSNnOaNG3WEWCb1HVD2grTOIPEAU5cYQc4sQsDhjjwF4A48AfwH3Asctx2Y0wIDjz6yLIfPf59n98rBEHQe3fvPnhwf3//3et/Xfv7+y98Hh4+PDx8+ML+S9fNm7fv3LkDQRD02rnlvdFwsjO+6u/4/qTXG87Z8v3xbHZr6O8MBtu+PxkMRnvX3j44uHdwcG86nfV6w8FgNBiMxuNrvj/xB+OQwWC0MRhtbe1OpzPfn+A4HmgAQdnZvmEZNXiZwtAkjvEExmMohyJxDE3G0CSFCwTGRxEuirAozEYRLjbfJzCewtM0AchYcICMCTF09coy3VufPHr0+MISevHixUCAYzKWUc9mDAxNRtFEFEkQGJ/ilBSn8IkcTQAKFyhcoAlAE4AhgydNBHYpPE3h6Ri6mqCzPCvznMJzCk0AlhJlyUFgOhJ5Azpz5nWSAAKvisCkKYChSRSJJ9jcaDgbDWeb/V1ZcgReBYIWIvAKEDQRWOGmCEyWEnvrk2vTW93OuNsZq4qnKiUgaFE0HolEoEgkgiEJgVdxjIeXKRSJo0icJkDZ6ehalefyJ6YNgVcFXlakiude99yZCGwgFICgsZRYdjqVUlcSbUm0Zcne7O/a5toKwgQCC68s4LEUEIy0oJExAYGZUMAxm6ri8ZySAUZ48YK85trTunfDsbY9d1Y0RqE3LCW23H7N23TslmO3MsBwzGbRbh4LQBDEUJKtt127FZ7G0CSJp2te33U2cmIlk9bSqbypbdS9m649KRoj2xgWjVHNe0cEtsCrLCXaekNXqykuL/BqWtAKSikvl1BkHiIIglaTqm02WUpE4DiO8aEHllHz3LHnzDw3oFJ6y9KGoemiMbK0Ydl509AHfEJiqWy/ulnz+mG2BF7Ny66uVtHQg0gkgmMJIBg5ySEJcJqDorlWKY0sbatcnJaL06Ixcqxtx9p27Un44ljbde9GVnRYKuMVO5VST1U8gVd5Lq9rVVOrPxNAEZYmAMdI9IkAx0hA0AytpqsNTW3YeltTG5betPW2rjYMvWmbHTVfs/RmXq6wlGiptbLddu22qdVtc802G7LkHIcoEomszIsnTG8IGRM4Jscx2X9BcC1Hb270d3vrE8uo5+WSa7e1vHec5EAApjAkcWr9vxLDklW3X3bWK6WuqngpXjO1uqk3nvPgZQIIzMDL1Gln/AMYmjxp7wzLSNwJz+XgShxbSUaRYEhE50o0AURgSqIhifbpD38nnApkTACClpOKshxUUWIeN47JPfMAvkwgMI3A5AnMaiJ3sP/+9b3b7dbWvDCCIbPKyvPOKpyg1bx+2enQBGjVr/qbe0130GkNY0RmNZkXeGUFIYNZdPbsqxi6SpMKicskLlNkoExTQNeqZadjm41KqeuVumWnU/X6WsFLsLlQj+eUornm2i2WEuN0lsXBhz9/9fsfT4+++zifU7zi/ar9QdBlEAT5G5/++O3R998c/fDk6MvPjzJCK05lHLPdqvud1qhVH87x1zvbjtmUgCWLRVksSqKtq1XbbKb4AoOkP/v18dOj3wpp/cnXn/x09EuO74qp7rEAvMzSjM6wATRdWFpauXQpGmcEMZ2XsoVsVs1mVSlbUHIaTfHw5SiKkCHhGfhy9NIifPuLB6m8cm5h6QKeuPf4IxhBzp9fXFhcPNb4/9afh5W2PuAu9r8AAAAASUVORK5CYII=" nextheight="1234" nextwidth="2000" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p style="text-align: start">This rich data is useful in a variety of ways. Customers can use it to understand how their content is performing, they can use it for debugging, to see where their content is being consumed the most, and so much more.</p><p style="text-align: start">Initially, we released Gateways Analytics on the Fiesta Plan and above, but today, we’re excited to announce that Gateway Analytics are available on all paid plans, including the Picnic Plan. If you’re on the Picnic Plan, you’ll be able to see 30 days worth of analytics. If you’re on the Fiesta Plan or Enterprise, you’ll be able to see 90 days worth of data.</p><p style="text-align: start">We believe Gateway Analytics is a major step forward for developers building on top of IPFS, and we can’t wait to see even more people using this feature.</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/844f17048b7ca532754ed1bfae89bff1.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How to Migrate Blog Posts From Webflow to Ghost]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-migrate-blog-posts-from-webflow-to-ghost</link>
            <guid>uUhP7qbWBsqPX3W7T0RU</guid>
            <pubDate>Tue, 18 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn how to migrate blog posts from Webflow to Ghost while preserving all your images on IPFS.]]></description>
            <content:encoded><![CDATA[<p>We’ve been using Webflow for a couple of years now, but we’ve never been happy with the blogging portion of Webflow. It’s always been more work than should be necessary to post and published a well-formatted technical blog. Because content is our number one driver of traffic, and because we produce so much of it, we decided to start exploring alternatives.</p><p style="text-align: start">I’ve personally always been a fan of Ghost. I’ve used it off and on for about a decade now, so it was a top candidate when we started looking for solutions. After confirming that we’d be able to match the URL format of our posts in Webflow with Ghost and confirming we wouldn’t kill our SEO, we decided to make the move. There were a few steps in this process, but the biggest of them all was migrating nearly 200 blog posts from Webflow to Ghost. Ghost doesn’t have a native import tool for Webflow, and Webflow doesn’t export data in a format that works with Ghost’s JSON importer. So, we do what we do best here.</p><p style="text-align: start">We wrote code.</p><p style="text-align: start">Well, actually, first we Googled. Unfortunately, there weren’t any guides that we could find on migrating blog content from Webflow to Ghost. That meant we’d have to turn to the Ghost and Webflow documentation sites and see what we could pull off. This guide will help if you ever want to make a similar migration.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-building-the-migration-tool"><strong>Building the Migration Tool</strong></h2></div><p style="text-align: start">I started this process with the ambitious goal of writing the migration script in Go, but then reality hit and I remembered we were on a time crunch. So, Gophers, sorry to disappoint, but this guide is for the JavaScript fans. Ultimately, I wrote the script in TypeScript and used Node.js.</p><p style="text-align: start">For this guide, you’ll need a few things:</p><ol><li><p>A text editor to write your code in</p></li><li><p>Node.js installed on your device (newest long-term support version is best)</p></li><li><p>Optionally, a Pinata account to upload images to IPFS</p></li></ol><p style="text-align: start">For the Pinata account, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/pricing?ref=pinata.cloud"><strong><u>you can sign up for free here</u></strong></a>. If you don’t choose to use Pinata, you’ll either want to find another hosting provider or you’ll have to change up the image handling script a bit (we’ll talk about that when we get there). But you probably don’t want all of your image references to point to Webflow’s CDN in the event you cancel your service with them.</p><p style="text-align: start">Ok, let’s get started. Fire up your text editor and launch your command line terminal. Let’s start by creating a project folder:</p><pre data-type="codeBlock"><code>mkdir webflow<span class="hljs-operator">-</span>to<span class="hljs-operator">-</span>ghost <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> cd webflow<span class="hljs-operator">-</span>to<span class="hljs-operator">-</span>ghost</code></pre><p>Now that you have a folder, and you’ve changed into it, let’s initialize the project. Run the following commands:</p><pre data-type="codeBlock"><code>npm init <span class="hljs-operator">-</span>y <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> npm i typescript <span class="hljs-operator">-</span><span class="hljs-operator">-</span>save<span class="hljs-operator">-</span>dev</code></pre><p>This will initialize npm in your project so that we can install node modules and it will install <code>typescript</code> as a developer dependency. Next, we need to create a config file for TypeScript. To do that, we should run this command:</p><pre data-type="codeBlock"><code>npx tsc <span class="hljs-operator">-</span><span class="hljs-operator">-</span>init</code></pre><p>Now, if you open your project folder in your text editor, you’ll see you have a <code>tsconfig.json</code> file. There are a lot of settings you can adjust in that file, but we’re only going to adjust one right now. Find the commented out property of <code>outDir</code>. Uncomment that and change the value from <code>./</code> to <code>./dist</code>. You’ll need to create a <code>dist</code> folder in the root of your project to support this.</p><p style="text-align: start">We just told the TypeScript compiler to output the compiled JavaScript files into the <code>dist</code> folder. This keeps things clean because, if you ran this on the root of your project without changing the configuration file, you’d have TypeScript and JavaScript files mixed together which can be confusing.</p><p style="text-align: start">Now that we’re all set up to work with TypeScript, let’s start writing some code. In the root of your file, let’s add a <code>types.ts</code> file. That’s right, we’re going to make life easy on ourselves by defining our types up front. In that file, we need to define the shape of the eventual JSON we will have for our Webflow blog posts, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ghost.org/docs/admin-api/?ref=pinata.cloud#posts"><strong><u>the shape of posts as Ghost expects them</u></strong></a>, and if you’re using Pinata to upload your images, the format of the upload response. You can copy and paste all of this into your <code>types.ts</code> file:</p><pre data-type="codeBlock"><code>export type Post = {
  "Title - Blog Post": string;
  "Link - Blog Post": string;
  "Collection ID": string;
  "Item ID": string;
  "Created On": string;
  "Updated On": string;
  "Published On": string;
  "Thumbnail - Blog Homepage": string;
  "Image - Blog Post": string;
  "Image <span class="hljs-selector-tag">caption</span> - Blog Post": string;
  "Meta Description - Blog Post": string;
  "Short Description - Blog Post": string;
  "Feature sentence - Blog Post (Plain text)": string;
  "Feature sentence - Visible?": boolean;
  "Blog <span class="hljs-attribute">Content</span> - Rich Text": string;
  "Date - Blog Post": string;
  "Category Tag - Blog Post": string;
  "Category Filters - Blog Homepage": string;
  "Multi-Reading Lists": string;
  "Author - Blog Post": string;
  "Read <span class="hljs-selector-tag">Time</span> - Blog Post": number;
  "Is Featured?": boolean;
  "Is recomended?": boolean;
};

interface Tag {
  created_at: string;
  description: string | null;
  feature_image: string | null;
  id: string;
  meta_description: string | null;
  meta_title: string | null;
  name: string;
  slug: string;
  updated_at: string;
  url: string;
  <span class="hljs-attribute">visibility</span>: string;
}

interface Role {
  id: string;
  name: string;
  description: string;
  created_at: string;
  updated_at: string;
}

interface Author {
  id?: string;
  name?: string;
  slug?: string;
  email?: string;
  profile_image?: string;
  cover_image?: string | null;
  bio?: string | null;
  website?: string;
  location?: string;
  facebook?: string;
  twitter?: string;
  accessibility?: string | null;
  status?: string;
  meta_title?: string | null;
  meta_description?: string | null;
  tour?: string | null;
  last_seen?: string | null;
  created_at?: string;
  updated_at?: string;
  roles?: Role[];
  url?: string;
}

interface Newsletter {
  id: string;
  name: string;
  description: string | null;
  slug: string;
  sender_name: string;
  sender_email: string | null;
  sender_reply_to: string;
  status: string;
  <span class="hljs-attribute">visibility</span>: string;
  subscribe_on_signup: boolean;
  sort_order: number;
  header_image: string | null;
  show_header_icon: boolean;
  show_header_title: boolean;
  title_font_category: string;
  title_alignment: string;
  show_feature_image: boolean;
  body_font_category: string;
  footer_content: string | null;
  show_badge: boolean;
  created_at: string;
  updated_at: string;
  show_header_name: boolean;
  uuid: string;
}

interface Email {
  id: string;
  uuid: string;
  status: string;
  recipient_filter: string;
  error: string | null;
  error_data: string;
  email_count: number;
  delivered_count: number;
  opened_count: number;
  failed_count: number;
  subject: string;
  <span class="hljs-selector-tag">from</span>: string;
  reply_to: string;
  <span class="hljs-selector-tag">html</span>: string;
  plaintext: string;
  track_opens: boolean;
  submitted_at: string;
  created_at: string;
  updated_at: string;
}

interface PrimaryTag {
  id: string;
  name: string;
  slug: string;
  description: string | null;
  feature_image: string | null;
  <span class="hljs-attribute">visibility</span>: string;
  meta_title: string | null;
  meta_description: string | null;
  created_at: string;
  updated_at: string;
  og_image: string | null;
  og_title: string | null;
  og_description: string | null;
  twitter_image: string | null;
  twitter_title: string | null;
  twitter_description: string | null;
  codeinjection_head: string | null;
  codeinjection_foot: string | null;
  canonical_url: string | null;
  accent_color: string | null;
  parent: string | null;
  url: string;
}

export interface GhostPost {
  slug: string;
  id?: string;
  uuid?: string;
  title: string;
  lexical?: string;
  <span class="hljs-selector-tag">html</span>: string;
  comment_id?: string;
  feature_image?: string;
  feature_image_alt?: string | null;
  feature_image_caption?: string | null;
  featured?: boolean;
  status: string;
  <span class="hljs-attribute">visibility</span>?: string;
  created_at: string;
  updated_at: string;
  published_at: string;
  custom_excerpt: string | null;
  codeinjection_head?: string | null;
  codeinjection_foot?: string | null;
  custom_template?: string | null;
  canonical_url?: string | null;
  tags: string[];
  authors: string[];
  primary_author: string;
  primary_tag: string;
  url?: string;
  excerpt: string;
  og_image: string | null;
  og_title: string | null;
  og_description: string | null;
  twitter_image: string | null;
  twitter_title: string | null;
  twitter_description: string | null;
  meta_title: string | null;
  meta_description: string | null;
  email_only?: boolean;
  newsletter?: Newsletter;
  email?: Email;
}

export type PinataUploadResponse = {
  "IpfsHash":string;
  "PinSize": number;
  "Timestamp": string;
  "isDuplicate": boolean;
}</code></pre><p>Ok, great, now let’s create an <code>index.ts</code> file. Inside that file, we’ll kick off this whole process by reading from our JSON file of blog posts from Webflow (don’t worry, I’ll show you how to get that soon). Add the following to your <code>index.ts</code> file:</p><pre data-type="codeBlock"><code>const readWebflowFiles <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">try</span> {
    const file <span class="hljs-operator">=</span> fs.readFileSync(<span class="hljs-string">"./blogposts.json"</span>, <span class="hljs-string">"utf-8"</span>);
    const posts <span class="hljs-operator">=</span> JSON.parse(file);
    <span class="hljs-keyword">return</span> posts;
    
    console.log(<span class="hljs-string">"Done!"</span>);
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
  }
};

(async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">try</span> {
    const posts <span class="hljs-operator">=</span> await readWebflowFiles();
    process.exit(<span class="hljs-number">0</span>);
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    process.exit(<span class="hljs-number">1</span>);
  }
})();</code></pre><p>You can see at the bottom of the file, we have a self-initializing function that calls the <code>readWebflowFiles()</code> function. That function should read from our JSON file called <code>blogposts.json</code> and return the parsed array of Webflow posts.</p><p style="text-align: start">Now, we already know we will need to convert the format of the Webflow posts into a format that Ghost’s API understands, so let’s write a function that does that and kicks up the upload process. Add a function in your <code>index.ts</code> file called <code>shapeAndPostToGhost</code>: </p><pre data-type="codeBlock"><code>const shapeAndPostToGhost <span class="hljs-operator">=</span> async (posts: Post[]) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">for</span> (const post of posts.filter((p: Post) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> p[<span class="hljs-string">"Published On"</span>] <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-string">""</span>)) {
      <span class="hljs-keyword">try</span> {
        const ghostPost <span class="hljs-operator">=</span> await shapePostForGhost(post);
        console.log(ghostPost.title);
        await addPostsToGhost(ghostPost);
      } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
        console.log(<span class="hljs-string">"POST ERROR"</span>)
        console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
        console.log(post);
        <span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
      }
    }
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)
    <span class="hljs-title"><span class="hljs-keyword">throw</span></span> <span class="hljs-title"><span class="hljs-keyword">error</span></span></span>;
  }
}</code></pre><p>You’ll also need to update your initialization function to call this new <code>shapeAndPostToGhost</code> function like so:</p><pre data-type="codeBlock"><code>(async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">try</span> {
    const posts <span class="hljs-operator">=</span> await readWebflowFiles();
    await shapeAndPostToGhost(posts);
    console.log(<span class="hljs-string">"Done!"</span>)
    process.exit(<span class="hljs-number">0</span>);
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    process.exit(<span class="hljs-number">1</span>);
  }
})();</code></pre><p>Now, if you look at the <code>shapeAndPostToGhost</code> function, you can see we’re taking each of the Webflow posts and running it through a function called <code>shapePostForGhost</code> and then we are uploading the result through a function called <code>addPostToGhost</code>. Let’s write each of those functions. First, add the <code>shapePostForGhost</code> function:</p><pre data-type="codeBlock"><code><span class="hljs-selector-tag">export</span> <span class="hljs-selector-tag">const</span> <span class="hljs-selector-tag">shapePostForGhost</span> = <span class="hljs-selector-tag">async</span> (<span class="hljs-attribute">post</span>: Post) =&gt; {
  <span class="hljs-selector-tag">const</span> <span class="hljs-selector-tag">image_url</span> = (await <span class="hljs-built_in">postImageToPinata</span>(post[<span class="hljs-string">"Image - Blog Post"</span>])) || "";  
  <span class="hljs-selector-tag">const</span> <span class="hljs-selector-tag">ghostPost</span> = {
    slug: post["Link - Blog Post"],
    title: post["Title - Blog Post"],
    html: await processImagesInHTML(post["Blog <span class="hljs-attribute">Content - Rich Text"]),
    feature_image</span>: image_url,
    <span class="hljs-attribute">status</span>: <span class="hljs-string">"published"</span>,
    <span class="hljs-attribute">created_at</span>: new <span class="hljs-built_in">Date</span>(post[<span class="hljs-string">"Created On"</span>]).<span class="hljs-built_in">toISOString</span>(),
    <span class="hljs-attribute">updated_at</span>: new <span class="hljs-built_in">Date</span>(post[<span class="hljs-string">"Updated On"</span>]).<span class="hljs-built_in">toISOString</span>(),
    <span class="hljs-attribute">published_at</span>: new <span class="hljs-built_in">Date</span>(post[<span class="hljs-string">"Created On"</span>]).<span class="hljs-built_in">toISOString</span>(),
    <span class="hljs-attribute">custom_excerpt</span>: post[<span class="hljs-string">"Feature sentence - Blog Post (Plain text)"</span>],
    <span class="hljs-attribute">tags</span>: [post[<span class="hljs-string">"Category Tag - Blog Post"</span>]],
    <span class="hljs-attribute">authors</span>: [<span class="hljs-built_in">getEmailFromWebflowAuthor</span>(post[<span class="hljs-string">"Author - Blog Post"</span>])],
    <span class="hljs-attribute">primary_author</span>: <span class="hljs-built_in">getEmailFromWebflowAuthor</span>(post[<span class="hljs-string">"Author - Blog Post"</span>]),
    <span class="hljs-attribute">primary_tag</span>: post[<span class="hljs-string">"Category Tag - Blog Post"</span>],
    <span class="hljs-attribute">excerpt</span>: post[<span class="hljs-string">"Feature sentence - Blog Post (Plain text)"</span>],
    <span class="hljs-attribute">og_image</span>: image_url,
    <span class="hljs-attribute">og_title</span>: post[<span class="hljs-string">"Title - Blog Post"</span>],
    <span class="hljs-attribute">og_description</span>: post[<span class="hljs-string">"Feature sentence - Blog Post (Plain text)"</span>],
    <span class="hljs-attribute">twitter_image</span>: image_url,
    <span class="hljs-attribute">twitter_description</span>: post[<span class="hljs-string">"Feature sentence - Blog Post (Plain text)"</span>],
    <span class="hljs-attribute">twitter_title</span>: post[<span class="hljs-string">"Title - Blog Post"</span>],
    <span class="hljs-attribute">meta_title</span>: post[<span class="hljs-string">"Title - Blog Post"</span>],
    <span class="hljs-attribute">meta_description</span>: post[<span class="hljs-string">"Feature sentence - Blog Post (Plain text)"</span>],
  };

  <span class="hljs-selector-tag">return</span> <span class="hljs-selector-tag">ghostPost</span>;
};</code></pre><p>There are some interesting ‘gotchas’ in this function, so let’s run through them. First, there’s the <code>image_url</code> variable. It’s set by calling a function called <code>postImageToPinata</code>. Much like the images in the Webflow posts HTML, you’ll likely have featured images that are hosted on Webflow’s CDN. This function simply uploads those to Pinata and returns a new URL to access the images from.</p><p style="text-align: start">Next, you’ll notice that the <code>html</code> property maps to a function called <code>processImagesInHTML</code>. Remember, there are image links from Webflow in the HTML of your posts. It probably makes sense to get those images hosted elsewhere. This function, as you’ll see soon, parses the HTML, finds the image links, uploads the images to Pinata, then returns the updated HTML string for use in the Ghost post object.</p><p style="text-align: start">Then, there’s the <code>published_at</code> property. When I was first testing this, I set this to map to Webflow’s <code>Published On</code> property. That was a mistake. Webflow updates this value every time you make a change to your blog posts. So if you correct a typo six months after initially publishing, the <code>Published On</code> date gets set to today. The closest approximation we have for the actual publication date is the <code>Created On</code> property from Webflow, so we map that to Ghost’s <code>published_at</code> field.</p><p style="text-align: start">Finally, the last ‘gotcha’ is that in Webflow, you’re going to get the author’s identifier, not their email address. The email address is what Ghost’s API uses to associate an author. So, we need a function to map the identifier to an email address.</p><p style="text-align: start">Let’s write all of these functions now. First, create the <code>postImageToPinata</code> like this:</p><pre data-type="codeBlock"><code>export default async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">postImageToPinata</span>(<span class="hljs-params">url: <span class="hljs-keyword">string</span></span>) </span>{
  <span class="hljs-keyword">try</span> {
    const urlStream <span class="hljs-operator">=</span> await fetch(url);
    const arrayBuffer <span class="hljs-operator">=</span> await urlStream.arrayBuffer();
    const blob <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> Blob([arrayBuffer]);
    const file <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> File([blob], <span class="hljs-string">"file"</span>);
    const data <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> FormData();
    data.append(<span class="hljs-string">"file"</span>, file);

    const upload <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"&lt;https://api.pinata.cloud/pinning/pinFileToIPFS&gt;"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          Authorization: `Bearer ${process.env.PINATA_JWT}`,
        },
        body: data,
      }
    );
    const uploadRes: any <span class="hljs-operator">=</span> await upload.json();
    <span class="hljs-keyword">return</span> `${process.env.PINATA_GATEWAY}<span class="hljs-operator">/</span>ipfs<span class="hljs-operator">/</span>${uploadRes?.IpfsHash}` <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-string">""</span>;
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>We’ll use this as a standalone function to upload feature images, but you’ll see that this function gets re-used soon. Like, right now.</p><p style="text-align: start">Go ahead and create the <code>processImagesInHTML</code> function like this:</p><pre data-type="codeBlock"><code>async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">processImagesInHTML</span>(<span class="hljs-params">html: <span class="hljs-keyword">string</span></span>) </span>{
  <span class="hljs-comment">// Find images that Ghost Upload supports</span>
  let imageRegex <span class="hljs-operator">=</span> <span class="hljs-operator">/</span><span class="hljs-operator">=</span><span class="hljs-string">"([^"</span>]<span class="hljs-operator">*</span>?(?:\\.jpg|\\.jpeg|\\.gif|\\.png|\\.svg|\\.sgvz))<span class="hljs-string">"/gmi;
  let result;

  while ((result = imageRegex.exec(html)) !== null) {
    let file = result[1];
    const url = await postImageToPinata(file);
    html = html.replace(file, url || "</span><span class="hljs-string">");
  }

  return html;
}</span></code></pre><p>This is where, if you’re not using Pinata and you want to upload to another service or upload directly to Ghost, you’ll need to modify the script. The <code>postImageToPinata</code> function creates a buffer from the URL. If you want to upload to Ghost you’ll need to convert that or you’ll need to write the file to disk then upload. I’ll leave that up to you because this is a Pinata blog and we’re uploading to Pinata here!</p><p style="text-align: start">Now let’s write our author mapping function. I’m going to use fake identifiers, but you’ll need to get all of the identifiers from your Webflow export and map them to your authors’ emails. The function should look like this:</p><pre data-type="codeBlock"><code>const getEmailFromWebflowAuthor <span class="hljs-operator">=</span> (author: <span class="hljs-keyword">string</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">if</span> (author <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"joe-smith"</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-string">"joe.smith@pinata.cloud"</span>;
  }
  <span class="hljs-keyword">if</span> (author <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"jane-doe"</span>) {
    <span class="hljs-keyword">return</span> <span class="hljs-string">"jane.doe@pinata.cloud"</span>;
  }  
  <span class="hljs-keyword">return</span> <span class="hljs-string">"team@pinata.cloud"</span>;
};</code></pre><p>I have a catch-all at the end. You may have employees who aren’t with the company that wrote blogs or something else might make it so an author in Webflow doesn’t map to your new publication. In that case, you can create an account for your catch-all email in Ghost and that will be the default author if not other author is found.</p><p style="text-align: start">Ok, so we’ve shaped the post, but now we need to actually post it to Ghost’s API. Luckily, Ghost has a JavaScript SDK that can help us. Let’s install that now:</p><pre data-type="codeBlock"><code>npm <span class="hljs-selector-tag">i</span> <span class="hljs-keyword">@tryghost</span>/admin-api</code></pre><p>We have to use the <code>admin-api</code> because we aren’t just reading from the API, we’re writing from it. Unfortunately, Ghost’s SDK doesn’t support types yet, and I don’t have the time to write my own declaration file, so we’re going to tell TypeScript to ignore the lack of types. Add the following to the top of your <code>index.ts</code> file:</p><pre data-type="codeBlock"><code><span class="hljs-comment">//  @ts-ignore</span>
<span class="hljs-keyword">import</span> <span class="hljs-title class_">GhostAdminAPI</span> <span class="hljs-keyword">from</span><span class="hljs-string">'@tryghost/admin-api'</span>;</code></pre><p>Before we can write the code to upload to the API, we need to do a few things. First, we need to get an Admin API key from Ghost. To do that, you’ll want to go into your Ghost dashboard, into settings, then find the Integrations option. From there, create a custom integration and give it a name.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/89aefee18500667a8228b923222d7904.png" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAARCAIAAAAzPjmrAAAACXBIWXMAAAsTAAALEwEAmpwYAAADN0lEQVR4nJVU708SYRxna7VlNTXN9a40Ex0Op6mRQICCIgR4ngcCd7vT4+iOOA7ZlMVwaE6n/Q/VP9Far33BnKahW/OFP3JrAyHQsonOzWzw5M0UUr/7vPg+z4vns+fz+Xy/ApKiSYqmGTdJ0QTp5HuSojnf4JA/wPkGL4Uhf+AkBOAtO0r0mK0Y0U9SjIfz4YTDxXojkcj09PTs7OxCJDI3N//lTC0uLo1PTJ19NAdBe+czhUqDEyQ44gT5gh0Ih8Nisbi1ta2qqqqlRbqysnJ0dHRwcHB0XLu7u2PjExcisKGYQqUxQjD/IZKiFyKR9x8/bMY3V9fXopvRHzs/0/vp9F46vZ9ObaW+pxKprVRweITzDQaCoUAwBPTMTQDUxwkSoNeO9Vqx1W9r4cjM5+XF2aVP69GvG7GNjdhGNBWLpmLpvfTh78PEdtLDDbRqtEYI1mh1Rgj2+oZyE4hqxUqVmrfXiuJwj3nn105iOxlPxuPJeGIrkcF2Mjw3s7yyLMiW3++fnHqtN3bhhMOGYiRF55Wo02CUtMiUrZqsEw47SkAwclJuvubn52PRGCAQCmvevH1H9FFAIqBSbgKNVlff2Cyub2ySSGVyFQQjHZ16s6XXaOo6hW64x2zpZT3cyOir54wLMVtoxn1+TIEHwG0bitlRokNnqBTWlJbdLb5ddhKFxSU3bxUJBIIrV6+XVzxELNYLpaihsVlYLRJWi3CCpBm3HSXMFpsNxSAYyaAb5qE3GJ+q2qRyhVSuRCxWyklfiEAmV9Vl9VGoNIjFChKV+Vmf4z+gnLSL9V5i0NTtHVK5MjvPf1eFhxtwsd58yCl6HpPbOxuaHgN7wQ2fuUAwFBod43NyFqf2Vd5dBMGIzgDxswYIXKwXJLKwuASCEZwgQQr4xoZiF5JIbzDpDSYXy5IU7aAZB80AAs43WFf/qKJSKKypvVf+QPJECsGI3mAC5oPGxXrPJygoLM0MjkisVGsBcIIEBBqtDrgSCIZeBodDI6Nj45Oh0TEe+UbsHwKhqK6g6M61G8WNEplcqZYr1RjRDyS6X1GpUGS8oRm3k2FdrFdvMGUDytCMm2G5Y0kzx7Me/AFOD9AFhOLeUgAAAABJRU5ErkJggg==" nextheight="1346" nextwidth="2516" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>When you’re done, there will be a Content API Key and an Admin API Key. We need the Admin Key, so copy that and then create a <code>.env</code> file in your project’s root. Add the admin key like this:</p><pre data-type="codeBlock"><code><span class="hljs-attr">ADMIN_KEY</span>=Your admin key</code></pre><p>Like with anytime you add secrets to a project, be sure to ‘gitignore’ them. Create a <code>.gitignore</code> file, if you don’t have one already, and add the <code>.env</code> file as ignored.</p><p style="text-align: start">Ok, so we’re getting close, but we still can’t just use that Admin Key. We need to turn it into a JWT that can be used as part of our API requests to Ghost. So, let’s install a couple more dependencies.</p><pre data-type="codeBlock"><code>npm <span class="hljs-selector-tag">i</span> jsonwebtoken dotenv</code></pre><p>We’ll need <code>jsonwebtoken</code> to help us sign the JWT we’re going to use, and we need <code>dotenv</code> to read our <code>.env</code> file.</p><p style="text-align: start">Now, head back over to your <code>index.ts</code> file, and add the following imports at the top:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> <span class="hljs-title">GhostAdminAPI</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span><span class="hljs-string">'@tryghost/admin-api'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">jwt</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"jsonwebtoken"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">dotenv</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"dotenv"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">GhostPost</span>, <span class="hljs-title">Post</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./types"</span>;
dotenv.config();</code></pre><p>I snuck one in there that is necessary. We never imported our types, but we need that for our code to compile. The other imports all help power the JWT signing and the API requests. Let’s first create a signed token and initialize the Ghost API client. Below your imports, add:</p><pre data-type="codeBlock"><code>const key <span class="hljs-operator">=</span> process.env.ADMIN_KEY!;

<span class="hljs-comment">// Split the key into ID and SECRET</span>
const [id, secret] <span class="hljs-operator">=</span> key.split(<span class="hljs-string">":"</span>);

<span class="hljs-comment">// Create the token (including decoding secret)</span>
let token;
<span class="hljs-keyword">try</span> {
  token <span class="hljs-operator">=</span> jwt.sign({}, Buffer.from(secret, <span class="hljs-string">"hex"</span>), {
    keyid: id,
    algorithm: <span class="hljs-string">"HS256"</span>,
    expiresIn: <span class="hljs-string">"5m"</span>,
    audience: `<span class="hljs-operator">/</span>admin<span class="hljs-operator">/</span>`,
  });
} <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
  console.log(<span class="hljs-string">"jwt error"</span>);
  <span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
}

const api <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> GhostAdminAPI({
  url: <span class="hljs-string">"&lt;http://localhost:2368&gt;"</span>,
  key: process.env.ADMIN_KEY,
  version: <span class="hljs-string">"v5.0"</span>,
}); </code></pre><p>Now, we’re ready to write our upload function. Add the following function in your <code>index.ts</code> file:</p><pre data-type="codeBlock"><code>export const addPostsToGhost <span class="hljs-operator">=</span> async (post: GhostPost) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">try</span> {    
    await api.posts.add(post, {source: <span class="hljs-string">'html'</span>});    
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
  }
};</code></pre><p>Notice that we add a configuration object in the SDK call specifying our source as HTML. Ghost defaults to a format called ‘lexical’ and, if you don’t explicitly set the source to HTML, your post body will be blank.</p><p style="text-align: start">The last thing we have left to do is export our content from Webflow and converting it to JSON. We could write a script to convert the CSV from Webflow to JSON, but unless you have sensitive data in there, you might just want to use an existing online tool.</p><p style="text-align: start"><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://university.webflow.com/lesson/import-export-collection-content?topics=cms-dynamic-content&amp;ref=pinata.cloud#how-to-export-collection-items-to-a-csv-file"><strong><u>Here’s a guide from Webflow on exporting your posts into a CSV</u></strong></a>. Once you have that, you can use any online CSV to JSON converter you feel comfortable with. Once you have the JSON file, add it to the root of your project and be sure to name it <code>blogposts.json</code>.</p><p style="text-align: start">Guess what? That’s it. You can now compile your code and run it like this:</p><pre data-type="codeBlock"><code></code></pre><p>Then:</p><pre data-type="codeBlock"><code>node dist/index.js</code></pre><p>You’ll see the title of each post as it’s being uploaded. If there are errors, they will be printed in the terminal. When the process is done, you’ll see the word “Done!” printed. When that happens, you can check out your Ghost admin panel and you’ll see all of your posts.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-wrapping-up"><strong>Wrapping Up</strong></h3></div><p style="text-align: start">This wasn’t the typical Pinata tutorial, but we did make use of IPFS in this post. I didn’t find much content out there when migrating our blog from Webflow, so hopefully, if you find yourself needing to do a similar migration, this is helpful.</p><p style="text-align: start">Happy Blogging!</p><p></p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/bacbd3f8e5ed1bd9b1ba382c22ee8217.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Quick To Market: Testing Crypto Payments With A Lean MVP]]></title>
            <link>https://paragraph.com/@pinatacloud/quick-to-market-testing-crypto-payments-with-a-lean-mvp</link>
            <guid>f5B4LCPd96VG4sfUxkqF</guid>
            <pubDate>Tue, 11 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[We’re pleased to share that, after one month of enabling new Pinata customers to pay with cryptocurrency, we’ve seen significant traction and are actively working on enhancing the MVP.]]></description>
            <content:encoded><![CDATA[<p>It’s been just over a month since we ventured into <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/announcing-crypto-payments"><strong><u>accepting crypto payments</u></strong></a>. Instead of pouring developer resources and time into architecting the perfect solution for our initial release, we built a scrappy MVP (Minimum Viable Product) in one week to test the waters. We’re pleased to share that, after one month of enabling new Pinata customers to pay with cryptocurrency, we’ve seen significant traction and are actively working on enhancing the MVP.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-why-crypto-payments"><strong>Why Crypto Payments?</strong></h3></div><p style="text-align: start">Our mission at Pinata is to make our customers’ lives easier by introducing new features that meet their needs and improve their experience. Over the past few months, many customers have been requesting the ability to pay with crypto. Existing users inquired about our plans to add this option, and prospective customers asked about it prior to signing up. The lack of crypto payment support had become a barrier for some, and a preferred option for many.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-building-and-testing-the-mvp"><strong>Building and Testing The MVP</strong></h3></div><p style="text-align: start">To gauge the initial interest, we quickly rolled out an annual pay-with-crypto option for both the Picnic and Fiesta plans. We utilized Loop Crypto’s system to help execute the transactions and purposefully accepted UX shortcomings on our side in order to link our systems as quickly as possible. Our goal was to get the feature out swiftly and learn from real user interactions. The positive response and number of new customers who chose this option have been encouraging, and we were pleasantly surprised to see that users were willing to work through a somewhat manual signup process to pay with crypto.</p><p style="text-align: start">Our quick and dirty approach allowed us to validate the demand before dedicating more time and resources towards building out the full solution. We’ve learned that addressing a key pain point with a desired feature will prove results even if customers must meet us halfway. With this customer validation in hand, we’re excited to iterate on our MVP and streamline customer flow over the coming months.</p><p style="text-align: start">If you’re interested in paying for an upfront annual plan with crypto, you can check out our <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/pricing"><strong><u>pricing options here</u></strong></a>. Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/1d7f67770bb8bcd42a2e62f46cf9eb86.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Announcing Pinata’s Partnership With NFT.Storage]]></title>
            <link>https://paragraph.com/@pinatacloud/announcing-pinatas-partnership-with-nft-storage</link>
            <guid>d8pK5Ts468GpdSeF0JQo</guid>
            <pubDate>Tue, 11 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[We're thrilled to announce our new partnership with NFT.Storage! This collaboration ensures that customers of the previous NFT.Storage service (now called NFT.Storage Classic) have robust options for adding resiliency to their previously stored files.]]></description>
            <content:encoded><![CDATA[<div class="relative header-and-anchor"><h3 style="text-align: start" id="h-exciting-news-new-partnership-with-nftstorage"><span data-name="party" class="emoji" data-type="emoji">🎉</span> <strong>Exciting News: New Partnership with </strong><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage"><strong>NFT.Storage</strong></a><strong>!</strong></h3></div><p style="text-align: start">We're thrilled to announce our new partnership with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage"><strong><u>NFT.Storage</u></strong></a>! This collaboration ensures that customers of the previous <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> service (now called <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> Classic) have robust options for adding resiliency to their previously stored files.</p><p style="text-align: start">As <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/easily-migrate-your-ipfs-content-from-nft-storage"><strong><u>highlighted in our migration article</u></strong></a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> is now the premier choice for long-term file storage on the Filecoin network. With this shift, they're phasing out their IPFS pinning service. Rest assured, content already uploaded won't be removed, but performance may be impacted over time. Which is why this partnership is so helpful. To ensure continued performance and availability of content, it’s always smart to have an alternative. Pinata is that alternative, and the benefits of this partnership don’t stop there.</p><p style="text-align: start">For existing <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage"><strong><u>NFT.Storage</u></strong></a> customers looking to migrate their content, and for those seeking a new IPFS provider, our partnership ensures a seamless transition!</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-the-details"><span data-name="sparkles" class="emoji" data-type="emoji">✨</span><strong> The Details</strong></h3></div><ol><li><p><strong>Exclusive Discounts</strong>: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> customers referred to Pinata get <strong>50% off</strong> their first month of paid service.</p></li><li><p><strong>Support Ongoing Development</strong>: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> benefits too, receiving an ongoing commission from revenue generated through these plans.</p></li></ol><p style="text-align: start">This partnership is a win-win. You get to use Pinata, a trusted solution, at a discounted rate, while also supporting <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a>'s continued growth.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-join-the-movement"><span data-name="rocket" class="emoji" data-type="emoji">🚀</span><strong> Join the Movement</strong></h3></div><p style="text-align: start">If you're an existing <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage"><strong><u>NFT.Storage</u></strong></a> customer searching for a new IPFS Pinning Service, we welcome you with open arms! To snag your discount and ensure <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> gets their referral commission, please follow the instructions provided by the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://NFT.Storage">NFT.Storage</a> team via email.</p><p style="text-align: start">Let's keep the pinning fun and efficient!</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/c69ff61fd968092d2cd2a8c075f572f8.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Verifiable Photography NFTs With IPFS]]></title>
            <link>https://paragraph.com/@pinatacloud/verifiable-photography-nfts-with-ipfs</link>
            <guid>EsVDvLWseic7fR2OdNf0</guid>
            <pubDate>Fri, 07 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[A noteworthy shift is underway as photographers are increasingly embracing the trend of selling their photographs as NFTs, a movement gaining mainstream traction.]]></description>
            <content:encoded><![CDATA[<p>If you're familiar with the NFT market, you've undoubtedly heard of acclaimed artists like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://opensea.io/beeple"><strong><u>Beeple</u></strong></a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.niftygateway.com/collections/pak"><strong><u>Pak</u></strong></a>, who have captured attention with their groundbreaking graphic art. These visionaries, alongside numerous others, have demonstrated the widespread appeal of graphic art in the NFT realm. However, a noteworthy shift is underway as photographers are increasingly embracing the trend of selling their photographs as NFTs, a movement gaining mainstream traction.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-noteworthy-artists"><strong>Noteworthy Artists</strong></h2></div><p style="text-align: start">The NFT market has witnessed several noteworthy sales that highlight the increasing interest in photographic art. &nbsp;One of the most talked about artists is engineer turned photographer Kate Woodman. &nbsp;Kate garnered significant attention by selling her photograph <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.instagram.com/p/CL5oRgkBeTr/"><strong><u>"Always Coca-Cola"</u></strong></a> as an NFT, fetching an impressive 11.88 ETH (around $20,000 at the time). &nbsp;Since then, she has continued to rake in the ETH through other NFT sales from her various collections.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/f5520d31effdce72368e62a088a06f99.jpg" alt="" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAgCAIAAABywqTfAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHZ0lEQVR4nCWUWUwb+R3HJ8Ezf4/NjMfX3Ift8W2PjS8wtglxnAAGEm4My2VsLgPmCAkkhMVAgBJCNkeT7Cp0G2mzK7a76UZVW7XRdvPU1Up9bdWHvlR9aV/62Jc+beVU+un39pG+P+n3+UJoLWow1VKUXhDNsp20OynZQdpks2Q1s6KZF42cZKR5I80bcFJXS2J6mtAatBodihs0ahxAhBGjaIMgUjaZdjppj4fxupk6P6MolMNFyg5SlEmK15sonYHR6xm9gdPrSBw31RpIDWHUQGZKz/Jmm0wHg1wszIcCTDTEBPwMzZJavVlLmCjOLMokK5op3kRJZsZKGWi9kcJNFGYgcYjlzVY7rSjchbgQDbNBhY2GGAPFQagVAjboHH8Oprxe3qswJG9kJDNvpyjeaKAJktVRnB6y26k6hU1E+YYYryhsXZDjBboGswneuFOpl2QfjIoanPJ4aVYyMqJRclR5RjIzooHm9JDVTvn8bEOUi0VYt4/1KlwNbLjU1vrHv/zm3fenj7d7HbwDgmjCSNidZt5qpjm9iSZojmA4gqRwyO2j/X72QlxIJ4VYmHf7GBUwTs8O/vvHf/7wt3f35tMZtxOCmHOIjuaNktVEUrUYjmhrVTiO4DgCuVyMP8jGo3wyxkfCrFdhaZbz+ZXtvfLuZj4RDoxEZaOGVmkMDEeYKExPwGr1eQ1Q1aKwBkUgr8KGInx9jG+Mi4l6vjFhEUW2u7Pl66+OPzksnD2YW2pys7jRQJoEyWgyaVBNjRqoMFSFA1gLVFA4LDSnbA0xPhThkykp1SQ5XVwqET19urY+1vbpRu9wwE6SJpo3UKyO0AOghhG4RgNUBAowFIECYSGZsNTXC/46LhKXYglJqRPibanS2uRmvqPcrmS8oi/s8tTJJgrDdDAANTCsgmGVGqg0QAUFI0IwUoUDYdEflpSw0NSTKT3Y3Tr77Gc/vC2Xuj4YSl37IBO/VMeKZkR9HoFVSJWHtQAhtCrIXyf6w+L/dyBqE1yWnrXlnV+92T97ubm7U3nx0cqT3eL6+Mmru9v7E40KpwbnAajmx1AVplVBTg/nVnhvQHArvMsrKAq/dLK79s1XR6ef/jqSejlXrAwOVPZLT7+oPHqxutDuuWA31GqBEQekDia0NZDNwTo9vNPDWRxs5mpkJN+wf/ai8ubLnr6+qXjy47XpL4Z6Dh+uPTw7vr0zm21wtbpJk16DadVmHahFYcjiYGQnZ5GZYFLpmh24flB+9v0ffv7XP3/49rv6vu5UU6qnqy0/kN24VfjJaaUw35+LSnEnpUGRKq8FECuSNgcr2dlQwjOyPn3/d18uvf3m+E/fPv7ul6FsW9fa6uPXT7f3S7vPtsu3RpePtuaykbmLFiOhITFgxBCIk6q8zcG6/Jb8jcln73575+//WDq9tTgmDxQHtn9x9vzr+x99dnf9YHZo6ML83vpkvrPS4wvwBgxFqrzFwVisJiWp3Pn82cbTuyMHm8f/+fH1f/+1eqetszd98ObVk1d7N7dyU4WW9rR/YCSbL+d2x+NZD4WhiF4LIE6iWI6IXYqXjveu5VpH7m6t/f7brc+fjk60Lh6s3X/98e7+RLnYPJgNpyP2i0l/Lt9xe6QxF6AJVE2gaojlSUGiJDvb1NqYdHHdFxtKq/mFqctLM5crlfHdSm5hJFHojFxLui4ELbJgCsfcC9eiOYUhULVei0CCRFmsNCeRosxFY96M15IJyH3Z+pm++NxocnUiOXM1PHrZ1x61WWkCBwDH1CmfVC8atUBlwqr5SU4kOYnirYwz4Ez57Q0OMaHIQ22hYk/D/Fiy0F433ORs9nFGXIvCQA0QuOZ89XlRlR4FkGSlOSslyqwv7ksNdFwe7U13XLzcGhsaapzsVaay7rFmua9R6miwRtxMLQoQWIUDBEMRAgVagEAWKyOI5mBSaSv0Z+cLvaul8c3ltYdbWw9XN/dHr5eaZ3rCxe7QcIs3HRWpauqquWpYpQUIAsOQxUrb7HSmv6U9392zkJ8+OSod7918crd8Z3LjYHplrX1mIlXoDo20e5vrJbvVpAEIDhAtABpQtRjiRNLhkZq7Ll2dHc1tbZRODpaPNmZXhsbyLaUb/ZMTqclCOj8YH+5U0nGb20HqcLUGVOVXw9WBLA7arTjS/dn+1dmJ7fWlR4flo42F25PzK/0z1weKSz2F+Wy+mMldDWeSssvFUBT+3v/zMKxCYRjyR1wX+1o68719pdHC4U75+cOpww9X9ldWbg0v7xSW7wzPLHUU59tyXeF0XHY6KIbVobBK8/54HCBQ4krDlVx799zocOXW1IN7iz89mTu4UVjMzS6239ibXN0enVnMFibTA23+RESyWs00hWPaavloANDCAIokg9mx7tzN+Ymd24uP7t14fn/1aGV8PFNc7FxeH5idvpKfSA1eDbU02hQ3JXB6iiLMOrWuCqur+VPdmY7C4FB5bObww/WXn2ycnsyvjxWK2dJGX368cbBT6U67WlNyvY+zsTqBJWgS02PgfXlWq/h/FoTBUhgXK7AAAAAASUVORK5CYII=" nextheight="528" nextwidth="350" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>“Always Coca-Cola” by Kate Woodman</p><p style="text-align: start">Similarly, photographer Justin Aversano made headlines with his collection <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://opensea.io/collection/twinflames"><strong><u>"Twin Flames,"</u></strong></a> a series featuring diverse photographs of twins that found success on OpenSea which has amassed over 5,900 ETH in total sales. One such photo from Aversano’s collection, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://opensea.io/assets/ethereum/0x3c28de567d1412b06f43b15e9f75129625fa6e8c/0"><strong><u>“Twin Flames #49. Alyson and Courtney Aliano”</u></strong></a>, made history becoming one of top ten most expensive photographs sold as an NFT, scoring a whopping 871 ETH (about $2.4 million at the time).<strong> </strong>These high-profile transactions illustrate a growing interest in and the potential value of the NFT market for photographers.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/9ee80a566cc13671bd7d595e3f4da5e3.jpg" alt="" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAACXBIWXMAAAsTAAALEwEAmpwYAAAMAElEQVR4nE3V51uThwIF8JdrIBCSvCN7QUhCEvYeQtgbRIaIiloKONCiZVwJUEWR0QJxgHBFUbEgopRRESIhJGLKEqFijOjFRaFEsUWtKI62vvfh3i/3Hzi/53w4zwF6Z1Hlw5d9Or18/Kl8/Gnv5KxSO6vS6VU6vfquXq2bV2nnVdo55eRM7+QTxcSja+PT8rEH8mHtlcHJzoGJdvXNy31DLXJNU7f6fIeivk1+srWn+uIV2fedZecuF9U1An3PUfUv71UPf+udeNI7+VSp/UWlm1Pr5gd08wNTv6p1v6p1syrtU5X2Sd/kI8X4g2vjD+TjU9dGtN3Dt7s0tzqvj7arh1oVNy7JVU1Xes+3d9f/cKW2ueNYU1v5uZaiU42A8jd0QP/5+uMlhXZOMTmj1M6otLNq3fz/DNVK+hOV9oly8mHf5MO+iYeK8SnF+NS1Ma18ePKqZqJrYKxTPdTWp2mVq5uvKpqu9Da0Xf1Xc1t1U2vlmebiukag/3d04DmqmV1W6vQq7dzIzOuJ+fcT+o/j+g+35pdHZl4PP14cevRicFp/Y2pOrZtRaR/3TzxQjOuujd2RD//cPXir88boiqG4cWElved8R+/ZTsXpDvmJ1i5ZcwegeolqXqA/6T/131+4fn9Bdu6HsuqG2vMd9S3dje39zVcHLsmH25SjnddvXRm8LR/RKsb+3T/5UDU5rRy/pxjTdg/e6hoY7VBqujSjxWUV9lyuE1/oJBS72Th6uXv7+AQD6peoZhEdXPg88PDlT49eewVE4LEEGhEmY3F0UyKLAHIRkiWNzqPQLekMEcvMnmcpZLEKS74bnJ5VjusGdU8GtI+Ut+5en7gvzS8UmOL8HEXe1nw3EcfOgi5mkoGB1+jgK3ToBaqZeTs6+z4pJYNGNbMWiFysxU5CoQPf0obDFDPJAiqJh0AckMgECYiBQXp6xtjMi/6JqQMllVGRsQnr1p9sunS4pMKOSv0yxllWEnmsNLwkP6QgKwS48QYd/gMdXkR/mv/z5wU0I6eQQWb7h/gm74rb9lXirr1J23fHbkwKy9y3Y39JTsHhnF0ZW62oyM6UtNvzrzZtSTUxWGVoABgCABsBfT08fIRCVyoxOVJYnO1f+LW/NMMbuPEWHXqDjrxCB59/vvMHWlhWxWFwQ8KCtn0Vm3Mg42B5/sHygtLjB6vqZVWnKkqrDhSW5jiyackbkgZ0TyyYLNjAgGxiRDLEIkZGJAwmUCxypCPWsAkTZ+jMJbs7WQKaZXT4HXrzDTqyiN5bRmV1jWKeICoidE9u0sFyac2Zo2VVRcfqyytrykqP5BXL8kqP7HezYMdHRo3NLHg42CNYY5IhBjY0FIAEuiHG3oxjAxEcKMQtqevWBjg6i8mA5gM6soyOvkVvvkTvfULrW7uthVbhoUGZ+VsOfScNDfE3I8ERIZKqU2VHa0sqTxRWVB9yEwki/ALuLS4X5UlJhli6iQlsZGxFxDtBODYEClmMQH/JFxsjDx0pSNsVAyheoP0vVqZw8yWq+4ReVmjc7F38fCS5hSnrN8fZcdm16eFrXHnZ+V/Wnjt6vK6ssqZotYN1kOfqCf2b7vY2jimWCAAE4B8cU8O1YjLbGBMZFWRjb+0i5mzI3pO4dydwdepd36P3AzPLo79/vvcn+qPmToBPkLend05BWmJCWK10x7Vv0zZJhGk7oksqpCGRkvjN4YESd19HJ83087v3p4syUtOSvsxLio5xt920mscxWWUnME/cmrBtT+r+wxlfpK0FBh6/GZp7P6z/OPb7SoOe8emokHB3R/es/NTwSJ+yr5JHKtJCRdT4BL/iCqnQ3jIuMWBteKC7UHRn/q12Eb14RXPsbPfpC/KT5zqTEr9gm2K8uOT0dZL0dZ474ly2RjoC1+fRwWfoyHP01iJ69wPap9PHrYn195Rk56flFmaeP7Dl7J4w2MAgUGJTWXPAN8g1NMYnOizYhcfbll0mtvU3wdIwBjDGkGpszDTFMkAcLUJMlW50yE31/mb76vyMMKD/V1TzHB1aWAG0y6jm8R+J8QmBq70dXV1DouIqC7bLNrs4UCB3sSAlLWH9huCIeP+YsAAzC7tV7NWmiBCm21GYDmSqNQxyQQLH1JhhjEGETIYbnyOmkThE4gpw49kKMLaI3nmHjsx/Sk5KCnRx5/LFHHMhhyPcGeuTHutOJpIdRXxvib1/pFf8mmC6UAIKA9h2YRxLCUyxBmEhkWCGxzFNjek4DIUGEeKjo7an7f46KxdQ/h9wewkdX/ickpIW7OzO5fBoNHMGiWnBMPdwcqbgQT6b5e5h4xXsFh4aAPG8eC4RzpI4a9coB89oC0tPOk1MoYhIiIBGsYxc497Q1tw7/HO7Qr0CDOjRoWd/jS78/fMrdPI1umvXXomtPY/OJkE0CsxgIAxXR2eKCZEBIh7O4nUbAiRBATDPy8lvPUIRE8hiKtfTQuxnwXczM7dnsR1YdMsNm/wb2tpariq+b7sKKGdR9dzfP83/NfL8z/HfP99dQjMyc72sbYQMJoIn0WE6lUj1cHFlInSqKVHAovsFOjoHBcF8XyffdRAsIFPEMFkEUayJII+AY2JXUSkwI3VHzKXunov/PR9A8Quqnv1LM/dxWP9hTP9R9xbNzitaLRSJmGzIFKKBVAoedLS1oxEROg5vTqNZirgCVwnHNlRkJYFAc4QkhElChCKGYD5IZOONECaVviU1qqVHdeGK6szFVkD+5LPy6Uf103dD88ujs0sPltH9Rd85m3OdrGzY5kIGwiCZwq6OLhwqjY4n2op4dtYCkGrFt/IR8BxAIodEtUKoNjBkBmIRIo5OxFK5DGbCOt+6+uLyksTivNVA96O/FY/fqx8vDc29G5l5PbWEllbWcCn0NcHBGTn7fDw8OQjFzsLCisUQkSB7GiJicSCanZWVN5PGhxE+iSygkHgkyBwisiFTmgmGKGSRtyfQy/P5RZmsomxzoGv6U8+DJeX028HZpRXgNXq09rw1m+NkKbJic3gIIoBhPhG0JIAWeByPSKTAZjBZaOPoB4NMGOIgkBneCMECBEPA1BAw4bKEgY5wuVR8vNDuW6noYKYAGHjwpll9u+Pm9PX7+pGZN5MLn6vOtnLIbC6JIYBhOxrizSFFWNESPbgZUSJfazYI8RkMsT3XwsrSlkHlMak8dzf/6OhNiZt3Hq6obepUJa2xLc62KNrLO7CbnfUlFeif+PX7buXhMyc75fK+/j55d3tdZUGil1lagEV2JK8wgV+cyD8pDblwMlXeWRK9JsEAgANcnPeEMC+3d6i0z1QTT+/MvX/8Cp16/uGefklxazoq0CMjiXToa8H+PdxvMnhAVUNrTmnFPtnJxqamlur8i7LMptLkc9lep/a41O11rc1wPfV1QMs3ST8UxMuK8i6pp9b6eeXH8mQpQoVC8QxFf0PRX5bRsUeLHcqx/aVV7l5BBENwvT/1ZKlzZb51ca4IOCefah982jP8sEejbTktu3Ak5/uy9Lp9kXWZvjV73M9m+avLs/rKMkdke0/sjq05uOPH0pjL+X4/5PqUH5SW1bbmHa6KTUxzcvGjkDnGq3C4VSZ4DMGahS/OElbmWZX+UwS0tVxuOX3ifHVRQ4W08Yi08UhuQ8n2euma+uzAhtzAS/lBXUXR8uKo7pK1fSWxHdmSxhTXqkjLci+aA52CwxDwhgQsYIxbhQeNIQSHwFhT0BhmE3CbwpGCdLOyfSKgpjirpjjrX2W5DbL8y1XS9uqs7mO75EfTVFVpqiNb+0rXX8oMrt/iXBvDPx5MqgqAKjxNj0rwMn+CFYVMBal0mE42QRAcBGEhCAuDWCJMpFKNsWExMclf+Baks4HzMullWVZXdZa8ereyJqOvJr2nfHPTTkl9km1NDO9IAHQskHgilFgfD59JgM8mIuc2Uuvj4UMSAg9GSHiEZEqCDYkwhghhCCCWAGEJRAxOYCGI3S51j0hMiGQBXZVpP5ZuvSiNO53hV5vqWr1BKAtn1kRS6hMoTZsYTVsZzancpm38+s2smjjqtz6w1IaQQsfFkHBsAkTGQyQTGDIiQEYE0IgAGpqAGGPQABOXvCtZejh44w6/8ND/AO7FKx+FWueQAAAAAElFTkSuQmCC" nextheight="600" nextwidth="600" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>“Twin Flames #49. Alyson and Courtney Aliano” by Justin Aversano</p><p style="text-align: start">Jeremy Cowart, another renowned photographer turned NFT guru, has embraced the power of blockchain technology to revolutionize his photos. He utilizes IPFS to host his extensive collections, ensuring the security and accessibility of his digital creations. Cowart offers a diverse range of NFT series, showcasing his innovative approach to photography. Among these collections is "A Year in Portraits," a highly successful series that has garnered significant attention and amassed hundreds of sales. This series exemplifies Cowart's ability to blend traditional photography with cutting-edge digital technology, solidifying his status as a leader in the NFT space.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/fba161201a7cc14917b16a1eb773e854.jpg" alt="" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAgCAIAAABywqTfAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHt0lEQVR4nC2RW1Ca+RmH/3FVzqCCgCYeYjSe8YAEFVBAAeGTj5MCCghCPhQ8A/p9oIKACgZFURCDppnEySab6W6n22lmNzvZ2ZvO7LTTtL3odNqZTm+6vepFT3c7ne2Y6c07783z/N53fmDFPBhCpAdrqhMMzm0bzoJwITp5ETE82bd+nHH99GrlFIOPNxRnQTgbhC+j+scR3fkWfLVnvtqbKkSNYMslTiyPpQLKE3Q8v63PhuDzbfiLgutv7wvvvzr94zenv3kTywZVjyOaj4+tnxzbXqatr27mzGV0shCdBIcB6HhDdYapc1vaQtSQj2if7xsRDW+E28xiVLZVM/Nh419+kfrx6ezTXe2nWfvrU/urY9uz/cknceOTuBEkluUZdPwi8uHyHd2z/cn8phYAwCohA1BMBvh6diXmGv38ePpJVFOIwJc7mh/9f9GeBWFwsKLIoNCRfywdkOe3xq8iGm53CwCAe/d2T03VPTa7jsUCAIz233+xr8usy7OYMoepbvioNhtUg7hHfOiTp5ZlCa8kvwldbKoBALfJ+JaaKh2/caSjrqv+dnVRUUtT3cs97QmqzKJjRz5ZOjB26B87QVUg7hlOeCUJryTmHsqiig3rAK6EIG5g7Go6EFHzRE+9p/9eI41o1oteJg07DwePfCPZoPIoIE8uy8431SDsFIXswoC5f3tWtO+VhB39gvYaMigKShu0nPpWZqWuo/YWAOOSjusIlFqRZNZl5yHoMqrNhaDzEASC9sGYeyhkF+x7xXvzooRXnPIM3vzPJE11sCV3q9Wcqk5WcdDcceKX7nlFqRXpKarIYqrMhiIdkIOIU/BoSXziHz3wCpJe8cmG9JvLvgM3Q9R0m1fDamfS9h2cvI9/viFKr4qyqCLtV6T9o1lUkd+CzkMqEJkdPFgcPvGL330S+vXb1Z8c3Pk8wfg6zdwx3xlva+hks5YMvD99e/Crd8l3L5cKkfEoIop7xUc+WWZdfuiTgRgiClq5b67RH77/+pevxWcOcGQF+fnS52vEPMK29d1NzAn+8ee97//z9of//u7bLw8Xdd07iPDQr0gsjoSdIrCq78Hs4u/+kPsqz40bb3nExUujxQnTRzk37vUW5XK+4XJ+4HVcch2q/ddfr/799y/zO8bt2YFDnyyxNBJyCIFH2Xadsn6WHkS1xVk3BYWKPaNkIw+HQaWnjpIcUpK1172KGnYtXT9Ldvzzu8xnF5Ytx2BqZSTqHkZtg2DdzIs4uOsw88V2/aGjZNdS9shOtwnIKk5pXF9yPENMW0lH1o4vLpYDMPP9p+q313bMwg/aB7ccwhs+aOH5Jh9kl7teYPSUFf9olo5B5CBMHufgTX0l+yZq1kXaszVcYuZCaDq3yP7tW9cOIsSs/IC5f0HHvclf1HAvfM1ZN/7ISTtBylCIHNZR5iVEQy9uUU44d9OOHUxTFdUgHJhX1fz+jT4TVPhN3PVpPjLeDVYn++bUPbml+6cI6chFT1ooASUOhWlhHWVVSXKK8Psm4vUy09jFKmY1CroZP082P0tCO4hoBxFuOkVgfZr/UMkp+NoySAUKEVEVJaAkuCWkmJEWnqT5VQQMwucQSn61805NQ289IeukPg4KIm5J2DV0wwdtAx51V27x7p6Ffuhihg1lGyqiU4DfgIi7loqYkYLCtJiBdI02Pahlc6uLd9S4vYftqF246RR6DTyAWvo9Ks6T9cbCStWZmxUz0rwSooFLnhPjE9MVKQf1g5FwjNxuqalqZdzahnB5bGjDJsDsAhfUDebUPY7RjstA0/kCM2qmb2uoawriWDt+dgAXM9JOkIqUoxwZxp152HJh0z0CCCkJr5LD2Ifylib4YEHDXdBwDmbvoBDZIyl2DxctiouEjXhFOz6sIR06Ky6Xq9xiStJSYVI3NdHAugz3PNSaXJP6pgaWJvnAA/e6IY5fXRUylGEQaUtPiupLpwWEFnbRvJiQRphP16pQbcWakmSDqlsrb6EKwvkCO4MNITBvceIBsMk6p6SdPm3tBlzukRA39dSYkZBxkWeEZEljaWKm8mqNfeRgzgiIZiGtmQ78MuKRvfx5bMA61uNQ9QKbrMMq65weqvdKqYtywoocvyovTs6QTx9S3VIKaqBfLrMv5tiryrIJHrmZDnxy6u4E+SnWYlP1zCi6gEXabh3thAXNkwNsZBg3L7lRRA3EuKkkg5BOFyrPPKwswtzW0+clVEEDbm6ItG+kZr21S4Zeh7IbTEvabbJO43CbVtBsFrDdYtrKKH5BUhpQlqQclLCx4tjFSNvpcRNjUUoeaSbZB4iPpsujxiqvoW91ahDYFRyTuNU5xrErOLOSWvF9sryNMtlHWB2jeqRUp4CQsDLiJsbJLCtqoBl6SaY+ysE0LWSoXp0aCNhEQCtshQWtU9J2WNBql9Zb+LTuOmJXLR7qpg434ZZGiElLZURfkbRU5hDmOkQ19JDCMAnT1Xj0/HkdH8CCVr2oXStsG+W1eMabwhqqllMy1FjMq/+oo+qWT1W2N1W5radHDeUpOyukZ5h51E01NThxD3MMIVo+MEo7bWNdFkWPUdrtUDQHNZUbUJlHQnQKCNYHpKCGHjUyQppyDC6PGemYhqHvpfoUVGziHvZQMj/R/z/++KKqpYfZBgAAAABJRU5ErkJggg==" nextheight="1125" nextwidth="750" class="image-node embed"><figcaption htmlattributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>Photograph by Jeremy Cowart</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-why-photographers-are-gravitating-towards-nfts"><strong>Why photographers are gravitating towards NFTs</strong></h2></div><p style="text-align: start">As the digital photography scene explodes, photographers are not only getting excited about raking in some extra cash; but the awesome security perks that accompany NFT sales. One major part of the NFT minting process is IPFS – think of this as a digital vault for art. &nbsp;Before minting an NFT, it is standard practice for an artist to upload their work onto the IPFS network. This ensures the safe storage of their work, providing a secure foundation for NFT sales.</p><p style="text-align: start">The utilization of IPFS grants artists peace of mind by allowing them to maintain ownership of their photos. It guarantees that their work is immutable, safeguarded by the blockchain's decentralized network. This technology empowers artists to track sales effectively and share in the profits as their work appreciates in value. Furthermore, IPFS's content addressing mechanism helps to preserve the integrity of digital files. Each file stored on IPFS is assigned a unique cryptographic hash, also known as a CID (Content Identifier), acting as a digital fingerprint. Any changes to the file itself results in a changed hash, thereby providing a reliable method for detecting tampering and ensuring data integrity.</p><p style="text-align: start">In addition to the added security, retaining rights over their creations offers significant advantages for photographers. While NFT purchasers acquire the token associated with the digital file, the original artist retains copyright and reproduction rights to the actual photograph itself. This enables photographers to monetize their work through NFT sales without forfeiting their ability to display their work across various platforms, license it for commercial use, or sell physical prints.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-in-conclusion"><strong>In conclusion</strong></h2></div><p style="text-align: start">Blockchain technology, especially through IPFS platforms like Pinata, is changing how photographers &nbsp;protect their work. Photographers like Kate Woodman, Justin Aversano, and Jeremy Cowart show the vast potential of photographic art in the NFT space. Using the sufficiently decentralized and secure nature of IPFS, photographers can keep their digital creations safe while also maintaining ownership and rights. IPFS offers a strong and secure way to store and share digital files, protecting them from tampering and loss. This means the original artist stays in control of their work, even when it’s bought and sold as an NFT. Combining traditional photography with new digital technology gives artists new ways to make money and connect with fans and collectors worldwide.</p><p style="text-align: start">As more photographers use NFTs and the security of IPFS, we can expect more exciting and innovative works that push the boundaries of art and technology. This shift is empowering photographers to explore new creative ideas and reach a global audience.</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/27168abd9621cda1a9117fec32a3d915.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How To Build A Farcaster Raycast Extension With Pinata]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-build-a-farcaster-raycast-extension-with-pinata</link>
            <guid>9SSaPUyF7SCaEdZaiA5q</guid>
            <pubDate>Wed, 05 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[In this tutorial, we’ll show you how we built Raycaster, a Raycast extension used for sending casts to Farcaster. It will let you send text, links, and even images to your feed or to a channel of your choice! Not only that, but the principles you’ll learn here can be taken deeper into the Farcaster ]]></description>
            <content:encoded><![CDATA[<p>If you’ve followed our blog for the last few months, then you’ve probably picked up that we love building Farcaster clients (or at least I do). There’s something exciting about an open social graph that can be interfaced from so many different places. Additionally, the combination of IPFS gives the opportunity for sharing and consuming any kind of content, including, but not limited to, images and videos. Combine that with Raycast, a killer Mac OS productivity app? You get the best speed casting experience!</p><p style="text-align: start">In this tutorial, we’ll show you how we built Raycaster, a Raycast extension used for sending casts to Farcaster. It will let you send text, links, and even images to your feed or to a channel of your choice! Not only that, but the principles you’ll learn here can be taken deeper into the Farcaster or Raycast ecosystem to build even more tools.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-setup"><strong>Setup</strong></h2></div><p style="text-align: start">Before you get started on this fun extension, you’re going to need a few things.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-pinata-account"><strong>Pinata Account</strong></h3></div><p style="text-align: start">The first thing you’ll need is a Pinata account, which you can start for free by signing up <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://app.pinata.cloud/register"><strong><u>here</u></strong></a>. For this tutorial you can use the default free account until you’ve uploaded too much and need to migrate. Once you create your account, all you need to do is create an API key with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/account-management/api-keys"><strong><u>these instructions</u></strong></a>. That’s it!</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-developer-environment"><strong>Developer Environment</strong></h3></div><p style="text-align: start">The great thing about building Raycast extensions is that it’s primarily React code that is compiled to native Swift for Mac OS, which results in a fantastic developer experience. With that said, you will probably want some experience with React, as well as Node.js, installed on your machine along with a trusty text editor.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-raycast"><strong>Raycast</strong></h3></div><p style="text-align: start">If you haven’t already, you will want to install Raycast by visiting the link <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://raycast.com/"><strong><u>here</u></strong></a>. Once you install it, you should be able to run <strong>Create Extension</strong> which will bring up a form to fill out. For the template I would recommend the <strong>Form</strong> as the starting point, and for the command just start with <strong>Send Cast</strong> as the name with a description. Once you fill it out and submit the form, it will generate the code base for you! Open up the terminal and <strong>cd</strong> into the folder, then run the following command to install some dependencies.</p><pre data-type="codeBlock"><code>npm install @farcaster<span class="hljs-operator">/</span>core node<span class="hljs-operator">-</span>fetch @noble<span class="hljs-operator">/</span>hashes form<span class="hljs-operator">-</span>data</code></pre><p>Now, go ahead and open the repo with your code editor of choice, then in the terminal, run <strong>npm run dev</strong> to have Raycast bring up your new extension!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-authorize"><strong>Authorize</strong></h2></div><p style="text-align: start">The first, and arguably the most, challenging part of sending a cast to Farcaster is the authorization, which <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-sign-in-with-warpcast"><strong><u>we’ve talked about in depth before</u></strong></a>. We’ve even built our own Farcaster Auth to help developers scale posting to Farcaster with many users. However, for this particular extension, it gets a little tricky due to the restrictions of the UI and compatible libraries. Because of that, we’ll be taking a bit of an old fashioned approach to authorization. First, we’ve spun up an auth server with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/stevedylandev/farcaster-keys-server"><strong><u>this repo</u></strong></a> which we’re using as a service to go along with the extension. If you wanted to do something similar you are welcome to fork the repo and deploy it yourself! With it, we can create and sign keys with our app FID and mnemonic securely, without asking users to paste in their own mnemonic to the extension. Now, back in our repo, you will want to make a new file under <strong>src</strong> called <strong>authorize.tsx</strong>. Then, inside the <strong>package.json</strong> file, we will want to add this block of code.</p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">"commands"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"send-cast"</span><span class="hljs-punctuation">,</span> <span class="hljs-comment">// Existing command</span>
      <span class="hljs-attr">"title"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Send Cast"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Send a Cast to the Farcaster network. Requires a Signer Private Key and your FID"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"mode"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"view"</span>
    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"authorize"</span><span class="hljs-punctuation">,</span> <span class="hljs-comment">// New Command</span>
      <span class="hljs-attr">"title"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Authorize Raycaster"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"In order to send a cast with Raycaster you first need to authorize it with this command"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"mode"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"view"</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span></code></pre><p>This will make sure that our command is registered and accessible inside of Raycast.</p><p style="text-align: start">Back in our <strong>authorize.tsx</strong>, let’s put in the following code:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">useEffect</span>, <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">List</span>, <span class="hljs-title">showToast</span>, <span class="hljs-title">Toast</span>, <span class="hljs-title">Icon</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@raycast/api"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">KeyRequestData</span>, <span class="hljs-title">PollRequestData</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./types"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">fetch</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"node-fetch"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">LocalStorage</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@raycast/api"</span>;

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Command</span>(<span class="hljs-params"></span>) </span>{
  const [token, setToken] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span> <span class="hljs-operator">|</span> undefined<span class="hljs-operator">&gt;</span>();
  const [complete, setComplete] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>boolean<span class="hljs-operator">&gt;</span>(<span class="hljs-literal">false</span>);
  const [signInError, setSignInError] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>boolean<span class="hljs-operator">&gt;</span>(<span class="hljs-literal">false</span>);

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSigner</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">try</span> {
      const localKey <span class="hljs-operator">=</span> await LocalStorage.getItem(<span class="hljs-string">"signerKey"</span>);
      <span class="hljs-keyword">if</span> (localKey) {
        setComplete(<span class="hljs-literal">true</span>);
        <span class="hljs-keyword">return</span>;
      }
      const keyReq <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"https://api.farcasterkeys.com/sign-in"</span>, {
        method: <span class="hljs-string">"POST"</span>,
      });
      const keyRes <span class="hljs-operator">=</span> (await keyReq.json()) <span class="hljs-keyword">as</span> KeyRequestData;
      <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>keyReq) {
        <span class="hljs-keyword">throw</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Problem generating key"</span>);
      }
      console.log(keyRes);
      setToken(keyRes.pollingToken);
      const pollReq <span class="hljs-operator">=</span> await fetch(`https:<span class="hljs-comment">//api.farcasterkeys.com/sign-in/poll?token=${keyRes.pollingToken}`);</span>
      const pollRes <span class="hljs-operator">=</span> (await pollReq.json()) <span class="hljs-keyword">as</span> PollRequestData;
      console.log(pollRes);
      const pollStartTime <span class="hljs-operator">=</span> Date.now();
      <span class="hljs-keyword">while</span> (pollRes.state <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-string">"completed"</span>) {
        <span class="hljs-keyword">if</span> (Date.now() <span class="hljs-operator">-</span> pollStartTime <span class="hljs-operator">&gt;</span> <span class="hljs-number">120000</span>) {
          await showToast({
            title: <span class="hljs-string">"Sign in Timed out"</span>,
            style: Toast.Style.Failure,
          });
          setSignInError(<span class="hljs-literal">true</span>);
          <span class="hljs-keyword">break</span>;
        }
        const pollReq <span class="hljs-operator">=</span> await fetch(`https:<span class="hljs-comment">//api.farcasterkeys.com/sign-in/poll?token=${keyRes.pollingToken}`);</span>
        const pollRes <span class="hljs-operator">=</span> (await pollReq.json()) <span class="hljs-keyword">as</span> PollRequestData;
        console.log(pollRes);
        <span class="hljs-keyword">if</span> (pollRes.state <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"approved"</span>) {
          await LocalStorage.setItem(<span class="hljs-string">"signerKey"</span>, keyRes.privateKey);
          await LocalStorage.setItem(<span class="hljs-string">"fid"</span>, pollRes.userFid!);
          await showToast({
            title: <span class="hljs-string">"Sign In Complete!"</span>,
          });
          setComplete(<span class="hljs-literal">true</span>);
          <span class="hljs-keyword">return</span> pollRes;
        }
        await <span class="hljs-keyword">new</span> Promise((resolve) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setTimeout(resolve, <span class="hljs-number">2000</span>));
      }
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
      await showToast({
        title: <span class="hljs-string">"Problem Authorizing"</span>,
        message: <span class="hljs-function"><span class="hljs-keyword">error</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title"><span class="hljs-keyword">string</span></span>,
        <span class="hljs-title">style</span>: <span class="hljs-title">Toast</span>.<span class="hljs-title">Style</span>.<span class="hljs-title">Failure</span>,
      })</span>;
    }
  }

  useEffect(() <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    createSigner();
  }, []);

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>List<span class="hljs-operator">&gt;</span>
      {complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span>List.EmptyView icon<span class="hljs-operator">=</span>{Icon.CheckCircle} title<span class="hljs-operator">=</span><span class="hljs-string">"Raycaster is authorized! Now you can use Send Cast"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      )}
      {<span class="hljs-operator">!</span>complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>signInError <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span>List.EmptyView
          icon<span class="hljs-operator">=</span>{{ source: `https:<span class="hljs-comment">//api.farcasterkeys.com/qr/${token}?filename=image.png` }}</span>
          title<span class="hljs-operator">=</span><span class="hljs-string">"Scan the QR code to authorize Raycaster"</span>
        <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      )}
      {<span class="hljs-operator">!</span>complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> signInError <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">&lt;</span>List.EmptyView icon<span class="hljs-operator">=</span>{Icon.XMarkCircle} title<span class="hljs-operator">=</span><span class="hljs-string">"Timed out trying to sign in"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>}
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>List<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Now, this might seem a little daunting, but let’s walk through each piece and what we’re trying to do. First, we’ll import dependencies, and inside our <strong>Command()</strong> component, we’ll add some React state (which we’ll get to soon). Then, we have just one function here called <strong>createSigner()</strong>. The first thing it’s going to do is check if we already have a stored local key called <strong>signerKey</strong>. If we do, then we set <strong>complete</strong> to <strong>true</strong> and return. Otherwise, we continue with the rest of the code, which includes an API request to our keys server. The server will return us a JSON object that looks like this:</p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
    <span class="hljs-attr">"deepLinkUrl"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"farcaster://signed-key-request?token=&lt;POLLING_TOKEN&gt;"</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"pollingToken"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"&lt;POLLING_TOKEN&gt;"</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"privateKey"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"&lt;PRIVATE_KEY&gt;"</span><span class="hljs-punctuation">,</span>
    <span class="hljs-attr">"publicKey"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"&lt;PUBLIC_KEY&gt;"</span>
<span class="hljs-punctuation">}</span></code></pre><ul><li><p><strong>deepLinkUrl</strong> - Can be turned into a QR code or button on mobile to open up Warpcast to approve the signed key</p></li><li><p><strong>pollingToken</strong> - Used in the <strong>/sign-in/poll</strong> endpoint to check on the status of whether the key has been approved</p></li><li><p><strong>privateKey</strong> &amp; <strong>publicKey</strong> - The signed keypair that we’ll store for sending casts</p></li></ul><p style="text-align: start">With this data, we’ll start a new API request to our server to poll this key request, waiting for our user to approve the key we just made. To give them access to approve this key, we’ll use <strong>setToken(keyRes.pollingToken)</strong> which then updates our handy UI component at the bottom:</p><pre data-type="codeBlock"><code>{<span class="hljs-operator">!</span>complete <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>signInError <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
  <span class="hljs-operator">&lt;</span>List.EmptyView
    icon<span class="hljs-operator">=</span>{{ source: `https:<span class="hljs-comment">//api.farcasterkeys.com/qr/${token}?filename=image.png` }}</span>
    title<span class="hljs-operator">=</span><span class="hljs-string">"Scan the QR code to authorize Raycaster"</span>
  <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
)}</code></pre><p>You might notice that the icon source is our same keys server, but with a special endpoint that returns a QR code image based on the polling token provided - pretty nifty! While that user is scanning the code and approving it in Warpcast, our <strong>createSigner()</strong> function will continue to poll token to check the status every two seconds. From there we have two outcomes: A) The request takes too long and times out, and we throw an error to show the user in the UI, or B) The signed key request is approved by the user and we save both the <strong>privateKey</strong> and <strong>fid</strong> to local storage and make the UI reflect that the extension has been authorized. Now we have what we need to start sending casts.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-send-cast"><strong>Send Cast</strong></h2></div><p style="text-align: start">Before we start updating the code for the <strong>send-cast</strong> command, we’ll make one more small change to our <strong>package.json</strong> by adding this code:</p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">"preferences"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"PINATA_JWT"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Your Pinata API key JWT which can be created at https://app.pinata.cloud/developers"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"password"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"required"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"title"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Pinata API JWT"</span>
    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"GATEWAY"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Paste in your Dedicated Gateway or public gateway in the following format: gateway.pinata.cloud"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"textfield"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"required"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"title"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"IPFS Gateway"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"placeholder"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"gateway.pinata.cloud"</span>
    <span class="hljs-punctuation">}</span>
  <span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span></code></pre><p>What you see here is a special field provided by Raycast called <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://developers.raycast.com/api-reference/preferences"><strong><u>Preferences</u></strong></a>. It allows users to securely make preferences or add API keys to be used in the extension. In ours, we’ll make two, a Pinata API JWT and a Gateway field. Both of them are optional but will enable uploads to IPFS that can be used as image attachments for casts!</p><p style="text-align: start">Back in the <strong>send-cast.tsx</strong> file, let’s update the code with the following.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> {
  <span class="hljs-title">LocalStorage</span>,
  <span class="hljs-title">Form</span>,
  <span class="hljs-title">ActionPanel</span>,
  <span class="hljs-title">Action</span>,
  <span class="hljs-title">showToast</span>,
  <span class="hljs-title">getPreferenceValues</span>,
  <span class="hljs-title">Toast</span>,
  <span class="hljs-title">openExtensionPreferences</span>,
  <span class="hljs-title">Detail</span>,
  <span class="hljs-title">showHUD</span>,
  <span class="hljs-title">PopToRootType</span>,
} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@raycast/api"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Message</span>, <span class="hljs-title">NobleEd25519Signer</span>, <span class="hljs-title">CastAddBody</span>, <span class="hljs-title">makeCastAdd</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@farcaster/core"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Values</span>, <span class="hljs-title">ChannelResult</span>, <span class="hljs-title">FileUploadResult</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./types"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">hexToBytes</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@noble/hashes/utils"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">fetch</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"node-fetch"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">fs</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"fs"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">FormData</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"form-data"</span>;

<span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">Preferences</span> </span>{
  PINATA_JWT?: <span class="hljs-keyword">string</span>;
  GATEWAY?: <span class="hljs-keyword">string</span>;
}

const preferences <span class="hljs-operator">=</span> getPreferenceValues<span class="hljs-operator">&lt;</span>Preferences<span class="hljs-operator">&gt;</span>();

const JWT <span class="hljs-operator">=</span> preferences.PINATA_JWT;
const GATEWAY <span class="hljs-operator">=</span> preferences.GATEWAY;

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Command</span>(<span class="hljs-params"></span>) </span>{
  const [lengthError, setLengthError] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span> <span class="hljs-operator">|</span> undefined<span class="hljs-operator">&gt;</span>();
  const [imageUploadError, setImageUploadError] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>boolean<span class="hljs-operator">&gt;</span>(<span class="hljs-literal">false</span>);
  const markdown <span class="hljs-operator">=</span> `

# Pinata API key either missing or incorrect. 

Press Enter then update the key on the right side of the prefernce pane
`;

  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dropLengthErrorIfNeeded</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (lengthError <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> lengthError.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>) {
      setLengthError(undefined);
    }
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">uploadFile</span>(<span class="hljs-params">selectedFile: <span class="hljs-keyword">string</span></span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>preferences.PINATA_JWT) {
      await showToast({
        style: Toast.Style.Failure,
        title: <span class="hljs-string">"Files require a Pinata API Key"</span>,
      });
      setImageUploadError(<span class="hljs-literal">true</span>);
    }

    await showToast({ style: Toast.Style.Animated, title: <span class="hljs-string">"Uploading File..."</span> });

    <span class="hljs-keyword">try</span> {
      const data <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> FormData();

      const file <span class="hljs-operator">=</span> fs.createReadStream(selectedFile);

      data.append(<span class="hljs-string">"file"</span>, file);

      const uploadReq <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"https://api.pinata.cloud/pinning/pinFileToIPFS"</span>, {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          Authorization: `Bearer ${JWT}`,
        },
        body: data,
      });

      <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>uploadReq.ok) {
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Problem uploading file"</span>);
      }
      const uploadRes <span class="hljs-operator">=</span> (await uploadReq.json()) <span class="hljs-keyword">as</span> FileUploadResult;

      const headersReq <span class="hljs-operator">=</span> await fetch(`https:<span class="hljs-comment">//${GATEWAY}/ipfs/${uploadRes.IpfsHash}`, {</span>
        method: <span class="hljs-string">"HEAD"</span>,
      });

      const fileExtension <span class="hljs-operator">=</span> selectedFile.split(<span class="hljs-string">'.'</span>).<span class="hljs-built_in">pop</span>();

      const link <span class="hljs-operator">=</span> `https:<span class="hljs-comment">//${GATEWAY}/ipfs/${uploadRes.IpfsHash}?filename=image.${fileExtension}`;</span>

      <span class="hljs-keyword">return</span> link;
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-string">"Problem uploading files"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
      <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Problem Uploading File"</span>);
    }
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sendCast</span>(<span class="hljs-params">
    message: <span class="hljs-keyword">string</span>,
    parentUrl?: <span class="hljs-keyword">string</span> | undefined,
    embed?: <span class="hljs-keyword">string</span> | undefined,
    file?: <span class="hljs-keyword">string</span> | undefined,
  </span>) </span>{
    await showToast({ style: Toast.Style.Animated, title: <span class="hljs-string">"Sending Cast..."</span> });
    const FID <span class="hljs-operator">=</span> await LocalStorage.getItem(<span class="hljs-string">"fid"</span>);
    const SIGNER <span class="hljs-operator">=</span> (await LocalStorage.getItem(<span class="hljs-string">"signerKey"</span>)) <span class="hljs-keyword">as</span> <span class="hljs-keyword">string</span>;

    <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>FID <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-operator">!</span>SIGNER) {
      <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Sign in first"</span>);
    }
    <span class="hljs-keyword">try</span> {
      const dataOptions <span class="hljs-operator">=</span> {
        fid: Number(FID),
        network: <span class="hljs-number">1</span>,
      };

      const privateKeyBytes <span class="hljs-operator">=</span> hexToBytes(SIGNER.slice(<span class="hljs-number">2</span>));
      const ed25519Signer <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> NobleEd25519Signer(privateKeyBytes);

      const castBody: CastAddBody <span class="hljs-operator">=</span> {
        text: message,
        embeds: [],
        embedsDeprecated: [],
        mentions: [],
        mentionsPositions: [],
        parentUrl: parentUrl,
      };

      <span class="hljs-keyword">if</span> (embed) {
        const embedUrl <span class="hljs-operator">=</span> { url: embed };
        castBody.embeds.<span class="hljs-built_in">push</span>(embedUrl);
      }

      <span class="hljs-keyword">if</span> (file) {
        const fileUrl <span class="hljs-operator">=</span> { url: file };
        castBody.embeds.<span class="hljs-built_in">push</span>(fileUrl);
      }

      const castAddReq <span class="hljs-operator">=</span> await makeCastAdd(castBody, dataOptions, ed25519Signer);
      const castAdd <span class="hljs-operator">=</span> castAddReq._unsafeUnwrap();
      const messageBytes <span class="hljs-operator">=</span> Buffer.from(Message.encode(castAdd).finish());

      const castRequest <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"https://hub.pinata.cloud/v1/submitMessage"</span>, {
        method: <span class="hljs-string">"POST"</span>,
        headers: { <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/octet-stream"</span> },
        body: messageBytes,
      });

      const castResult <span class="hljs-operator">=</span> await castRequest.json();
      <span class="hljs-keyword">return</span> castResult;
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-string">"problem sending cast:"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    }
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleSubmit</span>(<span class="hljs-params">values: Values</span>) </span>{
    <span class="hljs-keyword">try</span> {
      let channelUrl: <span class="hljs-keyword">string</span> <span class="hljs-operator">|</span> undefined;
      let fileUrl: <span class="hljs-keyword">string</span> <span class="hljs-operator">|</span> undefined;

      <span class="hljs-keyword">if</span> (values.channel) {
        const channelReq <span class="hljs-operator">=</span> await fetch(`https:<span class="hljs-comment">//api.warpcast.com/v1/channel?channelId=${values.channel}`);</span>

        <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>channelReq.ok) {
          <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Channel not found"</span>);
        }

        const channelRes <span class="hljs-operator">=</span> (await channelReq.json()) <span class="hljs-keyword">as</span> ChannelResult;
        channelUrl <span class="hljs-operator">=</span> channelRes.result.channel.url;
      } <span class="hljs-keyword">else</span> {
        channelUrl <span class="hljs-operator">=</span> undefined;
      }

      <span class="hljs-keyword">if</span> (values.image <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> values.image.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>) {
        const upload <span class="hljs-operator">=</span> await uploadFile(values.image[<span class="hljs-number">0</span>]);
        fileUrl <span class="hljs-operator">=</span> upload;
      } <span class="hljs-keyword">else</span> {
        fileUrl <span class="hljs-operator">=</span> undefined;
      }

      const castRes <span class="hljs-operator">=</span> await sendCast(values.cast, channelUrl, values.embed, fileUrl);
      <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>castRes) {
        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"Trouble sending cast"</span>);
      }
      await showHUD(<span class="hljs-string">"Cast Sent!"</span>, { clearRootSearch: <span class="hljs-literal">true</span>, popToRootType: PopToRootType.Immediate });
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
      showToast({ title: <span class="hljs-string">"Problem sending cast"</span>, message: <span class="hljs-function"><span class="hljs-keyword">error</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title"><span class="hljs-keyword">string</span></span>, <span class="hljs-title">style</span>: <span class="hljs-title">Toast</span>.<span class="hljs-title">Style</span>.<span class="hljs-title">Failure</span> })</span>;
    }
  }

  <span class="hljs-keyword">if</span> (imageUploadError) {
    <span class="hljs-keyword">return</span> (
      <span class="hljs-operator">&lt;</span>Detail
        markdown<span class="hljs-operator">=</span>{markdown}
        actions<span class="hljs-operator">=</span>{
          <span class="hljs-operator">&lt;</span>ActionPanel<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>Action title<span class="hljs-operator">=</span><span class="hljs-string">"Open Extension Preferences"</span> onAction<span class="hljs-operator">=</span>{openExtensionPreferences} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>ActionPanel<span class="hljs-operator">&gt;</span>
        }
      <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
    );
  }

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>Form
      actions<span class="hljs-operator">=</span>{
        <span class="hljs-operator">&lt;</span>ActionPanel<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>Action.SubmitForm title<span class="hljs-operator">=</span><span class="hljs-string">"Send Cast"</span> onSubmit<span class="hljs-operator">=</span>{handleSubmit} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>Action
            shortcut<span class="hljs-operator">=</span>{{ modifiers: [<span class="hljs-string">"cmd"</span>, <span class="hljs-string">"shift"</span>], key: <span class="hljs-string">"p"</span> }}
            title<span class="hljs-operator">=</span><span class="hljs-string">"Setup Pinata for Images"</span>
            onAction<span class="hljs-operator">=</span>{openExtensionPreferences}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>ActionPanel<span class="hljs-operator">&gt;</span>
      }
    <span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Form.Description text<span class="hljs-operator">=</span><span class="hljs-string">"At least one field should be used to send a cast"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Form.TextArea
        id<span class="hljs-operator">=</span><span class="hljs-string">"cast"</span>
        title<span class="hljs-operator">=</span><span class="hljs-string">"Cast"</span>
        placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Type you main cast here"</span>
        <span class="hljs-function"><span class="hljs-keyword">error</span>=</span>{lengthError}
        onChange<span class="hljs-operator">=</span>{dropLengthErrorIfNeeded}
        onBlur<span class="hljs-operator">=</span>{(<span class="hljs-function"><span class="hljs-keyword">event</span>) =&gt; </span>{
          const value <span class="hljs-operator">=</span> <span class="hljs-keyword">event</span>.target.<span class="hljs-built_in">value</span>;
          <span class="hljs-keyword">if</span> (value <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> value.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">320</span>) {
            setLengthError(<span class="hljs-string">"Exceeds 320 character maximum"</span>);
          } <span class="hljs-keyword">else</span> {
            dropLengthErrorIfNeeded();
          }
        }}
      <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Form.TextField id<span class="hljs-operator">=</span><span class="hljs-string">"embed"</span> title<span class="hljs-operator">=</span><span class="hljs-string">"Embed"</span> placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Past a link here"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Form.TextField id<span class="hljs-operator">=</span><span class="hljs-string">"channel"</span> title<span class="hljs-operator">=</span><span class="hljs-string">"Channel"</span> placeholder<span class="hljs-operator">=</span><span class="hljs-string">"raycast"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Form.Separator <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Form.FilePicker
        id<span class="hljs-operator">=</span><span class="hljs-string">"image"</span>
        title<span class="hljs-operator">=</span><span class="hljs-string">"Image"</span>
        canChooseDirectories<span class="hljs-operator">=</span>{<span class="hljs-literal">false</span>}
        allowMultipleSelection<span class="hljs-operator">=</span>{<span class="hljs-literal">false</span>}
        info<span class="hljs-operator">=</span><span class="hljs-string">"Requires Pinata API key, run Cmd + Shift + Enter"</span>
        storeValue<span class="hljs-operator">=</span>{<span class="hljs-literal">false</span>}
      <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Form<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Again, it’s a lot of code, but we’ll break it down piece by piece. At the top, we have our imports from different libraries, as well as an interface for <strong>Preferences</strong>. Followed closely behind is our <strong>preferences</strong> object where we use the Raycast API to get the Pinata JWT and Gateway fields provided by the user.</p><p style="text-align: start">Inside the <strong>Command()</strong> component, we’ll start by creating some error states, and an error message to pop up if someone tries to upload a file without first entering their Pinata API key. We also have a special error function designed by Raycast to show up if people exceed 320 characters in the text field, which we’ll get to momentarily.</p><p style="text-align: start">Next, we have our <strong>uploadFile</strong> function, which takes in a path to a local file on the user’s computer. We then follow the patterns outlined in the Pinata Docs for pinning a file via API. We use <strong>fs</strong> to read the file, attach it to <strong>FormData</strong>, and then submit the API request to upload. Once we get the CID back, we can create a link using our gateway by appending the file extension from the <strong>selectedFile</strong> path. With that link, we can then use it in our cast body!</p><p style="text-align: start">Moving on to the next and primary function, <strong>sendCast</strong>, we take in several parameters, including the message or main text of the cast, a <strong>parentUrl</strong> for channels, <strong>embed</strong> for links, and <strong>file</strong> for image uploads. From there, we retrieve the local storage items <strong>FID</strong> and <strong>SIGNER</strong> from our previous <strong>Authorize</strong> command and trigger an error if someone tries to send a cast without those. We then follow the pattern of sending a cast as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-send-a-cast-with-the-pinata-farcaster-api"><strong><u>demonstrated in this post</u></strong></a>, with the exception that if we receive a file or a link, we push it to the <strong>embeds</strong> array. We format the request using <strong>makeCastAdd</strong>, convert it into bytes, and then send the cast request to the Pinata Hub.</p><p style="text-align: start">Now, the final function <strong>handleSubmit</strong> brings it all together! With this function, we can use the automatic values passed down through the Form component by Raycast, which is a really easy way to handle state. One of the challenges with posting to a channel is that we need the full URL, and there are too many channels to try live filtering without better infrastructure or a CDN. Instead, we take a simpler approach by making a request to the Warpcast API for a channel by name, such as <strong>diet-coke</strong>, and use the response as the channel URL. Additionally, if we happen to have a file passed in through the form, we use our <strong>uploadFile</strong> function and assign the link to <strong>fileUrl</strong>. Finally, we send our cast, passing in all our values and returning either a success or error message.</p><p style="text-align: start">Lastly, if you look in the UI section, you can see how much we've been able to achieve with very little code, thanks to Raycast’s UI library. Everything is handled, including form validation if there are too many characters in the text field, or returning a separate component if someone tries to upload a file without a Pinata API key.</p><p style="text-align: start">Once you’ve completed your extension, follow this guide by Raycast to go through the steps to publish it on their store. From my experience, it’s really helpful to run <strong>npm run build</strong> frequently to catch any errors, as well as <strong>npx ray lint --fix</strong> to handle formatting issues. Once you have all the details done, such as filling out the <strong>package.json</strong> fields and creating an icon, you can run <strong>npx ray publish</strong>, which will create a fork and branch for your extension and even open the PR to submit. In the PR, add details about your extension and include a video explaining what it does to help ensure it gets approved faster. After a little back and forth with the team, you should be all set!</p><p style="text-align: start">Raycaster is now available and can be downloaded <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.raycast.com/stevedylandev/raycaster"><strong><u>here</u></strong></a>!&nbsp;</p><p style="text-align: start">This will spin up a dev server and load the extension locally and allow you to use it whenever you want! At this point you can kill the dev server and the extension will stay available.</p><p style="text-align: start">This is just the beginning of what you can do with Farcaster, Raycast, and Pinata. We can’t wait to see what you build! Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/3e02d92ffc176436eaf6270717124c84.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How To Mint NFTs With Foundry, Viem, And Pinata]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-mint-nfts-with-foundry-viem-and-pinata</link>
            <guid>oTLciqVYJct6Seww1yd9</guid>
            <pubDate>Fri, 24 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Combine Foundry, Viem, and Pinata to create, test, and deploy an ERC721 minting contract, and build an app to upload content to IPFS and mint NFTs.]]></description>
            <content:encoded><![CDATA[<p>Creating smart contracts and interacting with them through a website is nothing new, but the frameworks that are used change constantly. When it comes to writing and testing smart contracts, many developer agree <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/foundry-rs/foundry"><strong><u>Foundry</u></strong></a> is at the top, and for good reasons. Foundry is built in Rust so its compiler and test builds are blazing fast. All the tests and scripts are written in Solidity so there’s no context switching in your code. As far as interacting with smart contracts through a Typescript environment, nothing beats <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://viem.sh/"><strong><u>Viem</u></strong></a>. It’s a clean and simplistic library for building apps on Ethereum-compatible blockchains. However if you ever have to mint NFTs with your app, the chances are you need a place to store the images and metadata. No better place for that then IPFS with Pinata!</p><p style="text-align: start">Today we’ll show you how all three work together. With Foundry we’ll write, test, and deploy a simple ERC721 minting contract. With Viem and Pinata we’ll build an app that lets people upload the content to IPFS, then turn it into an NFT with Viem and our previously deployed contract. With the core concepts in this tutorial you can really build any kind of dApp that utilizes smart contracts and IPFS. Let’s dig in!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-setup"><strong>Setup</strong></h2></div><p style="text-align: start">Before we get started you’ll need just a few things to kick off.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-pinata-account"><strong>Pinata Account</strong></h3></div><p style="text-align: start">The first thing you’ll need is a Pinata account, which you can start for free by signing up <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://app.pinata.cloud/register"><strong><u>here</u></strong></a>. For this tutorial you can use use the default free account, and if you happen to take your project further you can scale with one of our paid plans! Once you create your account, all you need to do is create an API key with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/account-management/api-keys"><strong><u>these instructions</u></strong></a>. That’s it!</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-wallet-on-base-sepolia"><strong>Wallet on Base Sepolia</strong></h3></div><p style="text-align: start">We’ll be deploying our contract to the Base Sepolia testnet, and if you don’t already you’ll need a crypto wallet. I would highly recommend the Coinbase Wallet as its pretty easy to use and will have lots of documentation on getting things like the private key and getting testnet funds. You can learn more about it <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.cdp.coinbase.com/wallet-sdk/docs/developer-settings/#show-private-key"><strong><u>here</u></strong></a>.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-development-environment"><strong>Development Environment</strong></h3></div><p style="text-align: start">You will probably need at least some coding experience and command line experience to run through this, as well as having things like Node.js installed and a text editor handy!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-smart-contract"><strong>Smart Contract</strong></h2></div><p style="text-align: start">As stated before we’ll be using Foundry to write our smart contract. In order to use Foundry you’ll need to install it first, which you can do by following the instructions <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://book.getfoundry.sh/getting-started/installation"><strong><u>here</u></strong></a>. Once installed you can make sure it’s working by running <strong>forge --version</strong>. Then we can use it to initialize our project.. Then we can use it to initialize our project.</p><pre data-type="codeBlock"><code>forge <span class="hljs-keyword">init</span> my_nft</code></pre><p>Once the project is put together, <strong>cd</strong> into it and build it to make sure its working properly.</p><pre data-type="codeBlock"><code>cd my_nft <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> forge build</code></pre><p>If it works you should see the output:</p><pre data-type="codeBlock"><code>[⠊] Compiling...
[⠊] Compiling <span class="hljs-number">27</span> files with Solc <span class="hljs-number">0</span><span class="hljs-number">.8</span><span class="hljs-number">.23</span>
[⠢] Solc <span class="hljs-number">0</span><span class="hljs-number">.8</span><span class="hljs-number">.23</span> finished in <span class="hljs-number">1</span>.00s
Compiler run successful<span class="hljs-operator">!</span></code></pre><p>Then we’re going to install the OpenZeppelin library for our smart contracts, so run the following command:</p><pre data-type="codeBlock"><code>forge install OpenZeppelin<span class="hljs-operator">/</span>openzeppelin<span class="hljs-operator">-</span>contracts</code></pre><p>If we take a look at the project structure you’ll notice a few things.</p><pre data-type="codeBlock"><code>.
├── foundry.toml
├── lib
│  └── forge<span class="hljs-operator">-</span>std
├── README.md
├── script
│  └── Counter.s.sol
├── src
│  └── Counter.sol
└── test
   └── Counter.t.sol</code></pre><p>At the top we have a <strong>foundry.toml</strong> file that will be the config for the project. Outside of that we have a <strong>lib</strong> folder were dependencies are stores, <strong>src</strong> where the contracts live, <strong>script</strong> for automation we can run, and <strong>test</strong> for our contract testing.</p><p style="text-align: start">Now let’s go into the project structure and delete the contents of <strong>src</strong>, <strong>script</strong>, and <strong>test</strong>. In order for our OpenZeppelin contracts to have a more natural import method, we’ll do one short command to export a remapping in our directory to help locate the library.</p><pre data-type="codeBlock"><code>forge remappings <span class="hljs-operator">&gt;</span> remappings.txt</code></pre><p>This will allow us to import the contracts at the top of our file with the more standard <strong>import "@openzeppelin/contracts/token/ERC721/ERC721.sol"</strong> vs doing a relative path.</p><p>For actually writing the contract I love to start on the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://wizard.openzeppelin.com/"><strong><u>OpenZeppelin Contract Wizard</u></strong></a>, where we can just pick some default options. For this contract I’ll select ERC721, put in the name “MyNFT” and the symbol “MYNFT”, leave base URI blank, then the following options.</p><ul><li><p>Mintable</p><ul><li><p>Auto Increment IDs</p></li></ul></li><li><p>Burnable</p></li><li><p>Pausable</p></li><li><p>URI Storage</p></li></ul><p>By all means do careful research and testing for your specific use case when you’re looking to deploy a smart contract to mainnet. In the end I’m going to paste the following code into a new file in our <strong>src</strong> folder called <strong>MyNFT.sol</strong>.</p><pre data-type="codeBlock"><code><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-comment">// Compatible with OpenZeppelin Contracts ^5.0.0</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.20;</span>

<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC721/ERC721.sol"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/access/Ownable.sol"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">MyNFT</span> <span class="hljs-keyword">is</span> <span class="hljs-title">ERC721</span>, <span class="hljs-title">ERC721URIStorage</span>, <span class="hljs-title">ERC721Pausable</span>, <span class="hljs-title">Ownable</span>, <span class="hljs-title">ERC721Burnable</span> </span>{
    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">private</span> _nextTokenId;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>)
        <span class="hljs-title">ERC721</span>(<span class="hljs-params"><span class="hljs-string">"MyNFT"</span>, <span class="hljs-string">"MYNFT"</span></span>)
        <span class="hljs-title">Ownable</span>(<span class="hljs-params"><span class="hljs-built_in">msg</span>.sender</span>)
    </span>{}

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pause</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">onlyOwner</span> </span>{
        _pause();
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">unpause</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title">onlyOwner</span> </span>{
        _unpause();
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">safeMint</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> to, <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> uri</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-keyword">uint256</span> tokenId <span class="hljs-operator">=</span> _nextTokenId<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
    }

    <span class="hljs-comment">// The following functions are overrides required by Solidity.</span>

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_update</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> to, <span class="hljs-keyword">uint256</span> tokenId, <span class="hljs-keyword">address</span> auth</span>)
        <span class="hljs-title"><span class="hljs-keyword">internal</span></span>
        <span class="hljs-title"><span class="hljs-keyword">override</span></span>(<span class="hljs-params">ERC721, ERC721Pausable</span>)
        <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">address</span></span>)
    </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">super</span>._update(to, tokenId, auth);
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">tokenURI</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> tokenId</span>)
        <span class="hljs-title"><span class="hljs-keyword">public</span></span>
        <span class="hljs-title"><span class="hljs-keyword">view</span></span>
        <span class="hljs-title"><span class="hljs-keyword">override</span></span>(<span class="hljs-params">ERC721, ERC721URIStorage</span>)
        <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span></span>)
    </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">super</span>.tokenURI(tokenId);
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">supportsInterface</span>(<span class="hljs-params"><span class="hljs-keyword">bytes4</span> interfaceId</span>)
        <span class="hljs-title"><span class="hljs-keyword">public</span></span>
        <span class="hljs-title"><span class="hljs-keyword">view</span></span>
        <span class="hljs-title"><span class="hljs-keyword">override</span></span>(<span class="hljs-params">ERC721, ERC721URIStorage</span>)
        <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>)
    </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">super</span>.supportsInterface(interfaceId);
    }
}</code></pre><p>I made just a few small changes that you may want to note:</p><ul><li><p>Removed the argument in the <strong>Constructor</strong> and just used <strong>msg.sender</strong> as the owner, i.e. whoever deploys the contract will be the owner.</p></li><li><p>Removed the restriction of <strong>onlyOwner</strong> on the <strong>safeMint</strong> function. This allows people to mint their own NFT but of course adjust based on your needs.</p></li></ul><p style="text-align: start">After we have saved this file we can make sure it still builds with <strong>forge build</strong></p><p style="text-align: start">With the smart contract done we can add a small example test in our <strong>test</strong> folder; add the file <strong>MyNFT.t.sol</strong> with the following contents.</p><pre data-type="codeBlock"><code><span class="hljs-comment">// SPDX-License-Identifier: UNLICENSED</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.20;</span>

<span class="hljs-keyword">import</span> {<span class="hljs-title">Test</span>, <span class="hljs-title">console</span>} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"forge-std/Test.sol"</span>;
<span class="hljs-keyword">import</span> {<span class="hljs-title">MyNFT</span>} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"../src/MyNFT.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">MyNFTTest</span> <span class="hljs-keyword">is</span> <span class="hljs-title">Test</span> </span>{
    MyNFT instance;
    <span class="hljs-keyword">address</span> owner;
    <span class="hljs-keyword">address</span> recipient;

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">setUp</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        instance <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> MyNFT();
        owner <span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-built_in">this</span>);
        recipient <span class="hljs-operator">=</span> makeAddr(<span class="hljs-string">"recipient"</span>);
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">testSafeMint</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-keyword">string</span> <span class="hljs-keyword">memory</span> tokenURI <span class="hljs-operator">=</span> <span class="hljs-string">"ipfs://CID"</span>;
        instance.safeMint(recipient, tokenURI);
        assertEq(instance.ownerOf(<span class="hljs-number">0</span>), recipient);
        assertEq(instance.tokenURI(<span class="hljs-number">0</span>), tokenURI);
    }

}</code></pre><p>In here we import the contract we just wrote and declare a test. In the test we make some variables for the contract, the owner, and a recipient. With the <strong>setUp()</strong> function we can create a new instance of the contract, declare the owner, and create a random address for recipient. Finally we make a <strong>testSafeMint()</strong> function where we call the contract <strong>instance</strong> with the method <strong>safeMint</strong> and passing in the arguments of <strong>recipient</strong> and <strong>tokenURI</strong>. After that we can use <strong>assertEq</strong> to make sure the owner of NFT 0 is the recipient, and that the tokenURI of 0 is what we passed in. Now let’s run the test with the following command.</p><pre data-type="codeBlock"><code>forge test <span class="hljs-operator">-</span>vvv <span class="hljs-operator">-</span><span class="hljs-operator">-</span>gas<span class="hljs-operator">-</span>report</code></pre><p>This will run our tests, give us verbose errors if there are any, and give us a nice report of how much gas is used for the functions used!</p><pre data-type="codeBlock"><code>[PASS] testSafeMint() (<span class="hljs-built_in">gas</span>: <span class="hljs-number">136031</span>)
Suite result: ok. 1 passed; <span class="hljs-number">0</span> failed; <span class="hljs-number">0</span> skipped; finished in <span class="hljs-number">1</span>.07ms (<span class="hljs-number">102.67</span>µs CPU time)
<span class="hljs-operator">|</span> src<span class="hljs-operator">/</span>MyNFT.sol:MyNFT <span class="hljs-class"><span class="hljs-keyword">contract</span> |                 |        |        |        |         |
|------------------------------|-----------------|--------|--------|--------|---------|
| <span class="hljs-title">Deployment</span> <span class="hljs-title">Cost</span>              | <span class="hljs-title">Deployment</span> <span class="hljs-title">Size</span> |        |        |        |         |
| 1335108                      | 6238            |        |        |        |         |
| <span class="hljs-title">Function</span> <span class="hljs-title">Name</span>                | <span class="hljs-title">min</span>             | <span class="hljs-title">avg</span>    | <span class="hljs-title">median</span> | <span class="hljs-title">max</span>    | # <span class="hljs-title">calls</span> |
| <span class="hljs-title">ownerOf</span>                      | 664             | 664    | 664    | 664    | 1       |
| <span class="hljs-title">safeMint</span>                     | 120397          | 120397 | 120397 | 120397 | 1       |
| <span class="hljs-title">tokenURI</span>                     | 1827            | 1827   | 1827   | 1827   | 1       |</span></code></pre><p>Now there’s only one thing left to do which is deploy our smart contract. In this tutorial we’ll be deploying to Base Sepolia but you can use any chain you like based on the RPC URL you provide. To deploy from the command line we would use a command like this</p><pre data-type="codeBlock"><code>forge create src<span class="hljs-operator">/</span>MyNFT.sol:MyNFT \
<span class="hljs-operator">-</span><span class="hljs-operator">-</span>rpc<span class="hljs-operator">-</span>url https:<span class="hljs-comment">//sepolia.base.org \</span>
<span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-keyword">private</span><span class="hljs-operator">-</span>key <span class="hljs-operator">&lt;</span>PRIVATE_KEY<span class="hljs-operator">&gt;</span></code></pre><p>In the first line we declare what we are deploying, starting with the path to the smart contract and then the name of the contract we declare in the file. Then we declare the <strong>--rpc-url</strong> which in our case is the free to use Base Sepolia RPC, and then our <strong>--private-key</strong> from the wallet which should already have some test Eth on the Base Sepolia network. It should be important to note that you usually want to use a wallet that is setup with just test funds and no mainnet crypto, and you usually don’t want to past the keys in plain text like this. Foundry provides a tool called <strong>cast</strong> that has some great management which you can check out <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://book.getfoundry.sh/reference/cast/wallet-commands"><strong><u>here</u></strong></a>. Once successfully deployed we should see an address to which the contract was deployed to.</p><pre data-type="codeBlock"><code><span class="hljs-attr">Deployer:</span> <span class="hljs-number">0x971e6c57d9824a803f56f1b0d5D998160fe196a9</span>
<span class="hljs-attr">Deployed to:</span> <span class="hljs-number">0x521587f3Cc78651703F22423BBD4De6Cd9ad8E09</span>
<span class="hljs-attr">Transaction hash:</span> <span class="hljs-number">0x063834efe214f4199b1ad7181ce8c5ced3e15d271c8e866da7c89e86ee629cfb</span></code></pre><p>You did it! You deployed a smart contract <span data-name="party" class="emoji" data-type="emoji">🎉</span> Be sure to save that <strong>Deployed to:</strong> address since we’ll need it later.</p><p style="text-align: start">If we wanted to we can also verify the contract with an <a target="_new" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/"><strong><u>Etherscan API key</u></strong></a>.</p><pre data-type="codeBlock"><code>forge v <span class="hljs-operator">&lt;</span>CONTRACT_ADDRESS<span class="hljs-operator">&gt;</span> \ 
src<span class="hljs-operator">/</span>MyNFT.sol:MyNFT \
<span class="hljs-operator">-</span>e <span class="hljs-operator">&lt;</span>ETHERSCAN_API_KEY<span class="hljs-operator">&gt;</span> \
<span class="hljs-operator">-</span><span class="hljs-operator">-</span>rpc<span class="hljs-operator">-</span>url https:<span class="hljs-comment">//sepolia.base.org</span></code></pre><p>The last thing we need to do in this repo before moving on is getting the contract ABI. This is like a manual of instructions so other apps can interact with the contract on the blockchain. You should be able to find it under <strong>out/MyNFT.sol/MyNFT.json</strong>. In that file there is a whole bunch of stuff, but all you need is the <strong>abi</strong> array which looks something like this.</p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
  <span class="hljs-attr">"abi"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"constructor"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"inputs"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"stateMutability"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"nonpayable"</span>
    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
    <span class="hljs-punctuation">{</span>
      <span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"function"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"approve"</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"inputs"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>
        <span class="hljs-punctuation">{</span>
          <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"to"</span><span class="hljs-punctuation">,</span>
          <span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"address"</span><span class="hljs-punctuation">,</span>
          <span class="hljs-attr">"internalType"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"address"</span>
        <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
        <span class="hljs-punctuation">{</span>
          <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"tokenId"</span><span class="hljs-punctuation">,</span>
          <span class="hljs-attr">"type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"uint256"</span><span class="hljs-punctuation">,</span>
          <span class="hljs-attr">"internalType"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"uint256"</span>
        <span class="hljs-punctuation">}</span>
      <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"outputs"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>
      <span class="hljs-attr">"stateMutability"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"nonpayable"</span>
    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>
    <span class="hljs-comment">// rest of outputs</span>
  <span class="hljs-punctuation">]</span>
<span class="hljs-punctuation">}</span></code></pre><p>Copy that into a <strong>json</strong> file and we’ll get back to it!</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-minting-client"><strong>Minting Client</strong></h2></div><p style="text-align: start">The majority of minting use cases happen on a front end app, so in our tutorial we’ll be using Next.js. To get started run the following:</p><pre data-type="codeBlock"><code>npx <span class="hljs-built_in">create</span>-<span class="hljs-built_in">next</span>-app@latest my_nft_client</code></pre><p>It will ask a few questions where you can just choose all the defaults options. Once you’re done we need to install some dependencies.</p><pre data-type="codeBlock"><code></code></pre><p>After that we will need to setup some environment variables. You can do this by making a new file in the root of the project called <strong>.env.local</strong> with the following values put in.</p><pre data-type="codeBlock"><code><span class="hljs-attr">NEXT_PUBLIC_CONTRACT_ADDRESS</span>=
PINATA_JWT=</code></pre><p>Naturally you will want to paste in the contract address from our previously deployed contract, and our Pinata JWT that we got when creating an API key.</p><p style="text-align: start">Since we’ll be working with <strong>window.ethereum</strong> we’re going to make a few tweaks to the config files to make sure everything runs smoothly. First make a new file in the root of the project again called <strong>new-types.d.ts</strong> with the following contents.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">interface</span> <span class="hljs-title class_">Window</span> {
  ethereum: any;
}</code></pre><p>Then inside the existing <strong>tsconfig.json</strong> file, locate the <strong>"include"</strong> key and put our new file as a value in the array, like so.</p><pre data-type="codeBlock"><code><span class="hljs-attr">"include"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"new-types.d.ts"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"next-env.d.ts"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"**/*.ts"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"**/*.tsx"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">".next/types/**/*.ts"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span></code></pre><p>Now we can start building some stuff. To begin with we’ll setup our Viem code. Remember that contract ABI we took a look at earlier? Now we’re ready for it! Make a folder called <strong>utils</strong> then put a file called <strong>contract.json</strong> and paste in the ABI file. Piece of cake.</p><p style="text-align: start">With that setup let’s go into the main file under <strong>app/page.tsx</strong> and put in the following code.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">createPublicClient</span>, <span class="hljs-title">createWalletClient</span>, <span class="hljs-title">custom</span>, <span class="hljs-title">http</span>, <span class="hljs-title"><span class="hljs-keyword">type</span></span> <span class="hljs-title">Address</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"viem"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">contractData</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/utils/contract.json"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">baseSepolia</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"viem/chains"</span>;

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  const [account, setAccount] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>Address<span class="hljs-operator">&gt;</span>();

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">connect</span>(<span class="hljs-params"></span>) </span>{
    const walletClient <span class="hljs-operator">=</span> createWalletClient({
      chain: baseSepolia,
      transport: custom(window.ethereum),
    });

    const [<span class="hljs-keyword">address</span>] <span class="hljs-operator">=</span> await walletClient.requestAddresses();
    setAccount(<span class="hljs-keyword">address</span>);
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">mintNft</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>account) <span class="hljs-keyword">return</span>;

    const walletClient <span class="hljs-operator">=</span> createWalletClient({
      chain: baseSepolia,
      transport: custom(window.ethereum),
    });
    const publicClient <span class="hljs-operator">=</span> createPublicClient({
      chain: baseSepolia,
      transport: http(),
    });

    const { request } <span class="hljs-operator">=</span> await publicClient.simulateContract({
      account,
      <span class="hljs-keyword">address</span>: process.env.NEXT_PUBLIC_CONTRACT_ADDRESS <span class="hljs-keyword">as</span> `0x`,
      <span class="hljs-built_in">abi</span>: contractData.abi,
      functionName: <span class="hljs-string">"safeMint"</span>,
      args: [account, `ipfs:<span class="hljs-comment">//`],</span>
    });

    const res <span class="hljs-operator">=</span> await walletClient.writeContract(request);
    alert(res);
  }

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
      {account ? (
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>Connected: {account}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>button
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            onClick<span class="hljs-operator">=</span>{mintNft}
          <span class="hljs-operator">&gt;</span>
            Mint NFT
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      ) : (
        <span class="hljs-operator">&lt;</span>button
          className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
          onClick<span class="hljs-operator">=</span>{connect}
        <span class="hljs-operator">&gt;</span>
          Connect Wallet
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
      )}
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>This basically setups all the Web3 functionality we need. First we declare a state for an account, then make a function to set it by using the <strong>walletClient</strong> to request any browser wallets we might encounter in our app. Once its set we can display a button that will run <strong>mintNft()</strong>. In that function we first use our <strong>publicClient</strong> to simulate a transaction on the contract; this helps catch any errors before they even happen. In the <strong>request</strong> we’ll pass in the connected account, the <strong>address</strong> of our contract, the ABI, the name of the function, and the arguments. Then we can pass that <strong>request</strong> into the walletClient method <strong>writeContract</strong>.</p><p style="text-align: start">Now this is all well and good, but if we minted this now the NFT would be empty since our argument for the token URI is just an empty <strong>ipfs://</strong>! We need a way to add data and content to the NFT, which is what we’ll do now using Pinata. There are several ways to handle uploads in Next.js, but one we’re fond of is setting up a secure API route in Next where we generate a temporary API key using our admin API key. This key will only have two uses, and even still we’ll revoke it after its used.</p><p style="text-align: start">To do this make a new route and file under <strong>app/api/key/route.ts</strong> and put the following contents in.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextRequest</span>, <span class="hljs-title">NextResponse</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;
const { v4: uuidv4 } <span class="hljs-operator">=</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">"uuid"</span>);
const pinataJWT <span class="hljs-operator">=</span> process.env.PINATA_JWT;

export const dynamic <span class="hljs-operator">=</span> <span class="hljs-string">'force-dynamic'</span>

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">GET</span>(<span class="hljs-params">req: NextRequest, res: NextResponse</span>) </span>{
  <span class="hljs-keyword">try</span> {
    const uuid <span class="hljs-operator">=</span> uuidv4();
    const body <span class="hljs-operator">=</span> JSON.stringify({
      keyName: uuid.toString(),
      permissions: {
        endpoints: {
          pinning: {
            pinFileToIPFS: <span class="hljs-literal">true</span>,
            pinJSONToIPFS: <span class="hljs-literal">true</span>,
          },
        },
      },
      maxUses: <span class="hljs-number">2</span>,
    });
    const keyRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"https://api.pinata.cloud/users/generateApiKey"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        body: body,
        headers: {
          accept: <span class="hljs-string">"application/json"</span>,
          <span class="hljs-string">"content-type"</span>: <span class="hljs-string">"application/json"</span>,
          authorization: `Bearer ${pinataJWT}`,
        },
      },
    );
    const keyResJson <span class="hljs-operator">=</span> await keyRes.json();
    const keyData <span class="hljs-operator">=</span> {
      pinata_api_key: keyResJson.pinata_api_key,
      JWT: keyResJson.JWT,
    };
    <span class="hljs-keyword">return</span> NextResponse.json(keyData, { status: <span class="hljs-number">200</span> });
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> NextResponse.json({ text: <span class="hljs-string">"Error creating API Key:"</span> }, { status: <span class="hljs-number">500</span> });
  }
}</code></pre><p>This declares a route where we can create an API key just for our client side upload. In those key permissions we’re able to scope them to just the endpoints we need and reduce the max uses just to two; very nice!</p><p style="text-align: start">With keys taken care of, let’s make some upload functions that we can use with our NFT minting page. Back in the <strong>utils</strong> folder make a file called <strong>uploads.ts</strong> with the following contents.</p><pre data-type="codeBlock"><code>export const generatePinataKey <span class="hljs-operator">=</span> async () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-keyword">try</span> {
    const tempKey <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"/api/key"</span>, {
      method: <span class="hljs-string">"GET"</span>,
      headers: {
        <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
      },
    });
    const keyData <span class="hljs-operator">=</span> await tempKey.json();
    <span class="hljs-keyword">return</span> keyData;
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-string">"error making API key:"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
  }
};

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">uploadFile</span>(<span class="hljs-params">selectedFile: File | undefined, keyToUse: <span class="hljs-keyword">string</span></span>) </span>{
  <span class="hljs-keyword">if</span>(<span class="hljs-operator">!</span>selectedFile){
    console.log(<span class="hljs-string">'no file provided!'</span>)
    <span class="hljs-keyword">return</span>
  }
  <span class="hljs-keyword">try</span> {
    const formData <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> FormData();
    formData.append(<span class="hljs-string">"file"</span>, selectedFile);

    const metadata <span class="hljs-operator">=</span> JSON.stringify({
      name: `${selectedFile.<span class="hljs-built_in">name</span>}`,
    });
    formData.append(<span class="hljs-string">"pinataMetadata"</span>, metadata);

    const options <span class="hljs-operator">=</span> JSON.stringify({
      cidVersion: <span class="hljs-number">1</span>,
    });
    formData.append(<span class="hljs-string">"pinataOptions"</span>, options);

    const uploadRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"https://api.pinata.cloud/pinning/pinFileToIPFS"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          Authorization: `Bearer ${keyToUse}`,
        },
        body: formData,
      },
    );
    console.log({ uploadResStatus: uploadRes.status });
    <span class="hljs-keyword">if</span> (uploadRes.status <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-number">200</span>) {
      <span class="hljs-keyword">throw</span> <span class="hljs-built_in">Error</span>;
    }
    const uploadResJson <span class="hljs-operator">=</span> await uploadRes.json();
    <span class="hljs-keyword">return</span> uploadResJson.IpfsHash;
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-string">"Error uploading file:"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">uploadJson</span>(<span class="hljs-params">content: any, keyToUse: <span class="hljs-keyword">string</span></span>) </span>{
  <span class="hljs-keyword">try</span> {
    const data <span class="hljs-operator">=</span> JSON.stringify({
      pinataContent: {
        name: content.<span class="hljs-built_in">name</span>,
        description: content.description,
        image: `ipfs:<span class="hljs-comment">//${content.image}`,</span>
        external_url: content.external_url
      },
      pinataOptions: {
        cidVersion: <span class="hljs-number">1</span>,
      },
    });

    const uploadRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"https://api.pinata.cloud/pinning/pinJSONToIPFS"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
          Authorization: `Bearer ${keyToUse}`,
        },
        body: data,
      },
    );
    const uploadResJson <span class="hljs-operator">=</span> await uploadRes.json();
    const cid <span class="hljs-operator">=</span> uploadResJson.IpfsHash;
    console.log(cid);
    <span class="hljs-keyword">return</span> cid
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-string">"Error uploading file:"</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>It’s a far bit of code but we essentially have three primary functions:</p><ul><li><p><strong>generatePinataKey</strong> - Gets us a temporary API key for uploads</p></li><li><p><strong>uploadFile</strong> - A function that lets us upload a file that we pass, along with a temporary API key.</p></li><li><p><strong>uploadJson</strong> - A function we’ll use to create our NFT metadata that takes in an object with all the data we need.</p></li></ul><p style="text-align: start">When it comes to IPFS and NFTs, there’s a general flow that is pretty standard. First we need to upload our primary content. Since IPFS supports any kind of content, it could be anything, like an image, an audio file, or even 3D / HTML content. For this we’ll just stick with an image. Once we upload it we’ll get a CID for that file. The we need to use that image CID in metadata json file with all the information about our NFT, so in the end we have a nested data situation. To make this happen in our app let’s adjust our <strong>page.tsx</strong> code one more time.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">createPublicClient</span>, <span class="hljs-title">createWalletClient</span>, <span class="hljs-title">custom</span>, <span class="hljs-title">http</span>, <span class="hljs-title"><span class="hljs-keyword">type</span></span> <span class="hljs-title">Address</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"viem"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">contractData</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/utils/contract.json"</span>;
<span class="hljs-keyword">import</span> {
  <span class="hljs-title">generatePinataKey</span>,
  <span class="hljs-title">uploadFile</span>,
  <span class="hljs-title">uploadJson</span>,
} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/utils/uploads"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">baseSepolia</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"viem/chains"</span>;

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  const [account, setAccount] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>Address<span class="hljs-operator">&gt;</span>();
  const [name, setName] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [description, setDescription] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [externalUrl, setExternalUrl] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span><span class="hljs-keyword">string</span><span class="hljs-operator">&gt;</span>();
  const [file, setFile] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>File <span class="hljs-operator">|</span> undefined<span class="hljs-operator">&gt;</span>();

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">connect</span>(<span class="hljs-params"></span>) </span>{
    const walletClient <span class="hljs-operator">=</span> createWalletClient({
      chain: baseSepolia,
      transport: custom(window.ethereum),
    });

    const [<span class="hljs-keyword">address</span>] <span class="hljs-operator">=</span> await walletClient.requestAddresses();
    setAccount(<span class="hljs-keyword">address</span>);
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">mintNft</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>account) <span class="hljs-keyword">return</span>;

    const walletClient <span class="hljs-operator">=</span> createWalletClient({
      chain: baseSepolia,
      transport: custom(window.ethereum),
    });
    const publicClient <span class="hljs-operator">=</span> createPublicClient({
      chain: baseSepolia,
      transport: http(),
    });

    const keyData <span class="hljs-operator">=</span> await generatePinataKey();

    const fileCID <span class="hljs-operator">=</span> await uploadFile(file, keyData.JWT);

    const metadata <span class="hljs-operator">=</span> {
      name: name,
      description: description,
      image: fileCID,
      external_url: externalUrl,
    };

    const uriCID <span class="hljs-operator">=</span> await uploadJson(metadata, keyData.JWT);

    const { request } <span class="hljs-operator">=</span> await publicClient.simulateContract({
      account,
      <span class="hljs-keyword">address</span>: process.env.NEXT_PUBLIC_CONTRACT_ADDRESS <span class="hljs-keyword">as</span> `0x`,
      <span class="hljs-built_in">abi</span>: contractData.abi,
      functionName: <span class="hljs-string">"safeMint"</span>,
      args: [account, `ipfs:<span class="hljs-comment">//${uriCID}`],</span>
    });

    const res <span class="hljs-operator">=</span> await walletClient.writeContract(request);
    alert(res);
  }

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col justify-center items-center min-h-screen gap-4"</span><span class="hljs-operator">&gt;</span>
      {account ? (
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>Connected: {account}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Name"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{name}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setName(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Description"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{description}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setDescription(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            placeholder<span class="hljs-operator">=</span><span class="hljs-string">"https://pinata.cloud"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span>
            value<span class="hljs-operator">=</span>{externalUrl}
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setExternalUrl(e.target.<span class="hljs-built_in">value</span>)}
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>input
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"file"</span>
            onChange<span class="hljs-operator">=</span>{(e) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span>
              setFile(
                e.target.files <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> e.target.files.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>
                  ? e.target.files[<span class="hljs-number">0</span>]
                  : undefined,
              )
            }
          <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>button
            className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
            onClick<span class="hljs-operator">=</span>{mintNft}
          <span class="hljs-operator">&gt;</span>
            Mint NFT
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      ) : (
        <span class="hljs-operator">&lt;</span>button
          className<span class="hljs-operator">=</span><span class="hljs-string">"border border-black rounded-md p-2"</span>
          onClick<span class="hljs-operator">=</span>{connect}
        <span class="hljs-operator">&gt;</span>
          Connect Wallet
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
      )}
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Let’s go over the changes we made here. First we added some React state to handle inputs in the UI like the <strong>name</strong>, <strong>description</strong>, <strong>externalUrl</strong>, and <strong>file</strong>. Then in our <strong>mintNft</strong> function we’ll handle the flow mentioned earlier:</p><ul><li><p>Generate <strong>keyData</strong>, our API key, with <strong>generatePinataKey</strong></p></li><li><p>Use the <strong>keyData</strong> to upload the file a user has selected and get the <strong>fileCID</strong> back</p></li><li><p>Declare a <strong>metadata</strong> object with all the details by the user, including the <strong>fileCID</strong></p></li><li><p>Upload that <strong>metadata</strong> using <strong>uploadJson</strong> and get our <strong>uriCID</strong> back</p></li><li><p>Pass in the <strong>uriCID</strong> into the <strong>args</strong> of our contract request</p></li></ul><p style="text-align: start">That’s it! You now have an app that can mint NFTs! Of course this is just the beginning of what you can do with these tools. If you want a reference for each of these repos, you can find the smart contract <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/PinataCloud/foundry-pinata-minting-template"><strong><u>here</u></strong></a>, and the client app <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/PinataCloud/viem-pinata-minting-template"><strong><u>here</u></strong></a>. Whether its a memecoin machine or a minting dApp, Pinata is here to help you scale with all your media needs on IPFS.</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/12c1bb21c23aa25ba2f04364d4af53db.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Introducing Pinata Gateway Plugins]]></title>
            <link>https://paragraph.com/@pinatacloud/introducing-pinata-gateway-plugins</link>
            <guid>sLh0kzsdjAov93kFONB2</guid>
            <pubDate>Tue, 21 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Introducing the Gateway Plugins, Pinata's answer to plugin shops and app marketplaces]]></description>
            <content:encoded><![CDATA[<p>For years, people have asked us, "What's inside the pinata?" We're finally ready to show you. For the first time ever, we're opening up the pinata, and we're doing it in a big way.</p><p style="text-align: start">Introducing the Gateway Plugins, Pinata's answer to plugin shops and app marketplaces. IPFS has always been incredibly powerful, but we started to ask ourselves, what if it could do more? What if, through the power of small integrations, your IPFS Gateway could gain superpowers? The answers to those questions, and more, are found in Gateway Plugins.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-what-are-gateway-plugins"><strong>What Are Gateway Plugins?</strong></h2></div><p style="text-align: start">Gateway Plugins is a plugin marketplace for developers who want to extend Pinata's IPFS Gateway functionality. Similar to other marketplaces, developers can build tools that serve an existing audience, thus getting immediate exposure for their work. Pinata, on the other hand, benefits by having a richer experience for all its customers because of the innovative plugins that extend what's possible with Dedicated IPFS Gateways.</p><p style="text-align: start">Pinata users will be able to install Gateway Plugins at their gateway level or at the individual CID level, depending on the app. This creates a level of flexibility that bends to the needs of the customer. Developers will have a sandbox environment where they can test their plugins before requesting they be added to the Plugins Store.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-why-build-gateway-plugins"><strong>Why Build Gateway Plugins?</strong></h2></div><p style="text-align: start">Building apps is hard. Building apps in web3 is even harder. At times, distribution can feel impossible. Developers who build on Gateway Plugins can focus on building and leave the distribution to us.</p><p style="text-align: start">Pinata has over 600,000 users, over a billion files pinned to IPFS, and sees petabytes of data flow through our Dedicated IPFS Gateways each month. Developers interested in reaching a web3 audience as fast as possible should consider building Gateway Plugins.</p><p style="text-align: start">If that's you, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://tally.so/r/w7dyL2"><strong><u>click here</u></strong></a>.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-whats-launching-in-the-plugins-store"><strong>What's Launching in the Plugins Store?</strong></h2></div><p style="text-align: start">We're excited to launch with a number of plugins developed in house as will be rolling out plugins built by partners. Let's take a look.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-hot-swaps"><strong>Hot Swaps</strong></h3></div><p style="text-align: start">One of the most requested features we get from customers is an IPNS-like solution that is flexible and performant. While IPFS is immutable, there are plenty of valid use cases for being able to swap out the content of an IPFS CID in an auditable way without having to change the entire URL. This works well for websites and NFTs as well as dozens of other use cases we've heard customers ask about in the past.</p><p style="text-align: start">To use Hot Swaps, simply install the app at the gateway level, then you will be able to use both the Pinata Web App and the API to map new CIDs to an existing CID. For example, let's say you have an NFT project that you want to launch, but you're not ready to reveal. Rather than having to make an additional smart contract transaction to change the token URI, you can use Hot Swaps and keep the URI in tact while updating the content.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-moderator"><strong>Moderator</strong></h3></div><p style="text-align: start">IPFS is a public, permissionless protocol. This means that while it can host content that should be there, it can also host content that you or your users might find inappropriate. Running a gateway to distribute content has often meant manual content moderation. The Moderator Plugin solves this.</p><p style="text-align: start">You can install this plugin and configure what you’d like to moderate. This will ensure content uploaded to your Pinata account runs through the appropriate moderation filters. Then, when that content is loaded through your gateway, if it doesn’t pass moderation, it is not served.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-content-addressable-attestation"><strong>Content Addressable Attestation</strong></h3></div><p style="text-align: start">Whether it is verifiability of content or provenance of data, we’ve seen an increasing need to prove something about the media we consume. As AI continues to improve, this need will continue to increase. The Content Addressable Attestation plugin helps solve this in an elegant way.</p><p style="text-align: start">When enabled, your gateway will accept POST requests that map to a piece of content where the owner of the gateway can attest ownership and validity of a piece of content. This is done by tracking upload origin, requesting a wallet signature, and mapping it to an IPFS CID. The plugin allows for doing this through the browser or API.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-when-is-it-launching"><strong>When is it Launching?</strong></h2></div><p style="text-align: start">Pinata's Gateway Plugins will be live soon. In the meantime, we're building an interest list and will enable this functionality for people on the list first.</p><p style="text-align: start">If you're interested in using Gateway Plugins as part of your gateway experience, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://tally.so/r/wkY2eZ"><strong><u>please click here</u></strong></a>.</p><p style="text-align: start">If you're a developer that wants to build plugins for Gateway Plugins, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://tally.so/r/w7dyL2"><strong><u>please click here</u></strong></a>.</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/5a066c4d9efa03705e98c8e25bc1b429.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Pinata Partners With Neynar]]></title>
            <link>https://paragraph.com/@pinatacloud/pinata-partners-with-neynar</link>
            <guid>uydTKJYKcb8tS4Y4xafR</guid>
            <pubDate>Mon, 20 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Starting today, Pinata is partnering with Neynar to bring Farcaster APIs to more developers.]]></description>
            <content:encoded><![CDATA[<p>Since 2018, Pinata has focused on delivering the best developer experience in the web3 space. We've built our IPFS service to be both powerful and straightforward. Now, we're excited to announce our partnership with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://neynar.com/"><strong><u>Neynar</u></strong></a> to combine the capabilities of Farcaster and IPFS, enhancing what developers can achieve on the social protocol.</p><p style="text-align: start">From day one, Neynar has impressed us. We've maintained a close relationship with their team and, after three months of exploring the Farcaster developer ecosystem together, we're ready to take the next step.</p><p style="text-align: start">Starting today, Pinata is partnering with Neynar to bring Farcaster APIs to more developers. Neynar's expertise in building developer-focused products for Farcaster is now part of our suite of solutions. This means that developers seeking IPFS and Farcaster solutions will have access to the best options available. Neynar customers can easily integrate IPFS, and Pinata customers will enjoy a seamless Farcaster experience.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-what-does-this-mean-for-you"><strong>What does this mean for you?</strong></h2></div><p style="text-align: start">If you're using Pinata’s Farcaster API, you'll see new responses from our read endpoints. These are now powered by Neynar as part of this partnership. While we aim to avoid breaking changes, this partnership's importance to the Farcaster market warranted this adjustment. We provide an easy guide to help you update your code. Pinata’s Farcaster Auth API remains unchanged, so you can continue creating signers and sending casts as usual.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-ipfs-support"><strong>IPFS support</strong></h2></div><p style="text-align: start">For Neynar users seeking an IPFS solution, our closer collaboration ensures every developer has the best path to a great solution. With nearly six years of experience powering web3’s IPFS needs, we, alongside Neynar, are excited to integrate Farcaster with IPFS. You will soon see guides from Neynar and Pinata that specifically show you how to combine their APIs with Pinata’s IPFS services.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-the-future"><strong>The future</strong></h2></div><p style="text-align: start">Farcaster's future is promising and requires robust developer support. This partnership marks the beginning of Farcaster’s growth. We look forward to supporting the current developer community and onboarding the next generation onto the protocol.</p><p style="text-align: start"><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/"><strong><u>Get started with IPFS for free here</u></strong></a>.</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/3f4e5b2bbafe522aff766bb8cc277bc4.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How To Use IPFS For Memecoins]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-use-ipfs-for-memecoins</link>
            <guid>LjBulf8dPDhKkd1lpINA</guid>
            <pubDate>Wed, 15 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Today, we’re going to walk through how easy it is to upload and associated memecoin images with IPFS by using Pinata.]]></description>
            <content:encoded><![CDATA[<p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-launch-a-memecoin-on-farcaster"><strong><u>I recently wrote about how to launch a memecoin on Farcaster</u></strong></a>, but there are, of course, plenty of memecoins that are not native to <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/what-is-farcaster"><strong><u>Farcaster</u></strong></a>. While not all memecoins share the same distribution mechanisms, many of them do share one important characteristic. The meme images associated with these tokens are stored on IPFS.</p><p style="text-align: start">There are thousands and thousands of memecoins across all blockchains, but they behave differently. For example, a memecoin like Degen on Farcaster doesn’t have images associated with the individual tokens. Instead, Degen leverages images as a community-building tool. Contrast that with a platform like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://pump.fun"><strong><u>pump.fun</u></strong></a>, which allows anyone to launch a memecoin. Each memecoin launched requires an image. The goal is to create funny and engaging memes that are also tokens. Of course, there are variations that run the gamut between these two examples, but images are a center piece to all of them.</p><p style="text-align: start">Today, we’re going to walk through how easy it is to upload and associated memecoin images with IPFS by using Pinata.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-getting-started"><strong>Getting Started</strong></h2></div><p style="text-align: start">We’re going to use Pinata to upload memecoin images to IPFS, and we’re going to use a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-use-dedicated-gateways"><strong><u>dedicated IPFS gateway</u></strong></a> to ensure these images load quickly and reliably every time, no matter where they are served. So, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pinata.cloud/"><strong><u>go ahead and sign up for a free Pinata account here</u></strong></a>.</p><p style="text-align: start">While we will not be deploying smart contracts in this guide, we will show how you create the correct metadata to associate these memecoins with the tokens that will be deployed. We’ll do this for both Ethereum-based blockchains (EVM) and for Solana.</p><p style="text-align: start">You’ll need a code editor, Node.js, and your computer’s terminal app to work on this project. Now, let’s get to it.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-the-code"><strong>The Code</strong></h3></div><p style="text-align: start">We’re going to use Next.js for this project. You could choose to generalize this and extract the pieces to allow you to do something a little more modular like React + Express or React + Cloudflare Workers if you wanted to, but for simplicity, Next.js gets us the frontend code and backend code in one place.</p><p style="text-align: start">In this tutorial, we’re going to let people create their own memecoins. Again, we won’t be touching the blockchain side of the deployment, but we will be building out the meme creation and upload process. This will result in the metadata you need for each memecoin.</p><p style="text-align: start">Let’s create our project using Next.js. Open your terminal and navigate to the folder where you keep all your projects. From there, run this command:</p><pre data-type="codeBlock"><code>npx <span class="hljs-built_in">create</span>-<span class="hljs-built_in">next</span>-app</code></pre><p>Give your project a name (I’m calling mine “memecoin-uploaded”) and follow the prompts. You can choose whatever you want for each prompt, but I’m going with the defaults which includes Typescript, App Router, Src directory, and no ES Lint.</p><p style="text-align: start">Now, change into your project directory:</p><pre data-type="codeBlock"><code><span class="hljs-built_in">cd</span> memecoin-uploader</code></pre><p>If you’re not familiar with Next.js 14, take a look at the project structure. Everything happens inside the <strong>src</strong> folder. Inside that folder, you have an <strong>app</strong> directory where all the individual app pages will be created. For this, we’ll just have one page. But what about our API? We’ll need some backend code, so let’s make that happen.</p><p>Inside the <strong>src</strong> folder create a new folder called <strong>api</strong>. Create another folder inside the <strong>api</strong> folder called <strong>upload</strong>. Then, add a file inside the <strong>key</strong> folder called <strong>route.ts</strong>. This file is going to be where we make post requests to get a one-time use key for upload. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-upload-to-ipfs-from-the-frontend-with-signed-jwts"><strong><u>We’ve written before about creating signed JWTs</u></strong></a> that will allow safe uploads from frontend clients. That’s exactly what we’ll be doing here.</p><p>We’ll need to generate an API key from Pinata to use within our backend code. So, go ahead and sign into Pinata and visit the API keys page. Create a new Admin key. When you’re done you’ll be provided a key, secret, and JWT. Grab the JWT and let’s add it to a <strong>.env</strong> file inside the root of our project (create that file if it doesn’t exist yet):</p><pre data-type="codeBlock"><code><span class="hljs-attr">PINATA_KEY</span>=YOUR_JWT_HERE</code></pre><p>Now, let’s use the Pinata API to create a one-time use key. Go back to your <strong>key/route.ts</strong> file and add the following:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextResponse</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;

export const dynamic <span class="hljs-operator">=</span> <span class="hljs-string">'force-dynamic'</span>

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">POST</span>(<span class="hljs-params">request: Request</span>) </span>{
  <span class="hljs-keyword">try</span> {
    const keyRestrictions <span class="hljs-operator">=</span> {
      keyName: <span class="hljs-string">'Signed Upload JWT'</span>,
      maxUses: <span class="hljs-number">2</span>,
      permissions: {
        endpoints: {
          data: {
            pinList: <span class="hljs-literal">false</span>,
            userPinnedDataTotal: <span class="hljs-literal">false</span>
          },
          pinning: {
            pinFileToIPFS: <span class="hljs-literal">true</span>,
            pinJSONToIPFS: <span class="hljs-literal">true</span>,
            pinJobs: <span class="hljs-literal">false</span>,
            unpin: <span class="hljs-literal">false</span>,
            userPinPolicy: <span class="hljs-literal">false</span>
          }
        }
      }
    }
    const options <span class="hljs-operator">=</span> {
      method: <span class="hljs-string">'POST'</span>,
      headers: {
        accept: <span class="hljs-string">'application/json'</span>,
        <span class="hljs-string">'content-type'</span>: <span class="hljs-string">'application/json'</span>,
        authorization: `Bearer ${process.env.PINATA_KEY}`
      }, 
      body: JSON.stringify(keyRestrictions)
    };

    const jwtRepsonse <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">'https://api.pinata.cloud/users/generateApiKey'</span>, options);
    const json <span class="hljs-operator">=</span> await jwtRepsonse.json();
    const { JWT } <span class="hljs-operator">=</span> json;
    <span class="hljs-keyword">return</span> NextResponse.json({ message: { token: JWT } }, { status: <span class="hljs-number">200</span> });
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)
    <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">NextResponse</span>.<span class="hljs-title">json</span>(<span class="hljs-params">{ message: <span class="hljs-string">"Server error"</span> }, { status: <span class="hljs-number">500</span> }</span>)</span>;
  }
}</code></pre><p>In this code, we set the key restrictions (i.e. the scopes) and we use that in the body of our API request to Pinata to create a key. Notice that we are only allowing <strong>pinFileToIPFS</strong> and <strong>pinJSONToIPFS</strong> endpoints, and the key’s limited use is 2 because we’ll need to upload two files. This means that, once it’s used, a bad actor cannot get ahold of it and use it over and over again to spam your account, making the key infinitely safer to use in the browser than an admin key.</p><p style="text-align: start">One quick note: You’ll notice the line <strong>export const dynamic = 'force-dynamic'</strong>. This ensures that Vercel, or whatever hosting provider you use, doesn’t cache the response from creating your API key. By default it will which means even though you think you’re creating a new key, you’ll just be getting back the previous cached one, which is absolutely not what we want.</p><p style="text-align: start">Now, anyone can access your API in its current form, so you might want to introduce your own authentication on your app. If you do that, you would need to validate the auth token, or whatever is passed in, as part of the request before generating the key. As an example of this, we’ll use Dynamic to set up an embedded wallet on our app, and we’ll send a token generated by Dynamic that we can verify on the server.</p><p style="text-align: start">Let’s go ahead and do that (and more) by moving to our frontend code.</p><p style="text-align: start">In the <strong>src/app</strong> folder, find the <strong>page.tsx</strong> file. This is where we’re going to be setting up our app’s core functionality. Go ahead and remove everything in that file and replace it with this:</p><pre data-type="codeBlock"><code>export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
   <span class="hljs-operator">&lt;</span>main className<span class="hljs-operator">=</span><span class="hljs-string">"min-h-screen bg-black text-white"</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"h-full flex flex-col justify-center w-screen"</span><span class="hljs-operator">&gt;</span>

      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
   <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>main<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Let’s think about what we need to do here. We need to check if a user has connected their wallet (this will be necessary for minting memecoins, which we won’t tackle here). If they are not, we need to let them connect using Dynamic. If they are, we need to present a form that let’s the user add a name, description, and image for their memecoin. Let’s start with implementing the Dynamic wallet logic.</p><p style="text-align: start"><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://dynamic.xyz/"><strong><u>Go to Dynamic’s website and sign up for a free account</u></strong></a>. Once you’ve done that, you’ll land on a dashboard with instructions. The instructions may change, so please refer to their guides. I’m including the instructions as of the time of writing this article. Go ahead and install the Dynamic SDK and dependencies into your project by running:</p><pre data-type="codeBlock"><code>npm install @dynamic<span class="hljs-operator">-</span>labs<span class="hljs-operator">/</span>sdk<span class="hljs-operator">-</span>react<span class="hljs-operator">-</span>core @dynamic<span class="hljs-operator">-</span>labs<span class="hljs-operator">/</span>ethereum</code></pre><p>Once that’s installed, we need to set up the Dynamic provider in our app. Update your <strong>src/app/page.tsx</strong> file to look like this:</p><pre data-type="codeBlock"><code><span class="hljs-string">'use client'</span>
<span class="hljs-keyword">import</span> { <span class="hljs-title">DynamicContextProvider</span>, <span class="hljs-title">DynamicWidget</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@dynamic-labs/sdk-react-core'</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">EthereumWalletConnectors</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@dynamic-labs/ethereum"</span>;

export default <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>DynamicContextProvider
    settings<span class="hljs-operator">=</span>{{
      environmentId: <span class="hljs-string">'YOUR DYNAMIC ENVIRONMENT ID'</span>,
      walletConnectors: [ EthereumWalletConnectors ],
    }}<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>DynamicWidget <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>main className<span class="hljs-operator">=</span><span class="hljs-string">"min-h-screen bg-black text-white"</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"h-full flex flex-col justify-center w-screen"</span><span class="hljs-operator">&gt;</span>

      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
   <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>main<span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>DynamicContextProvider<span class="hljs-operator">&gt;</span>   
  );
}</code></pre><p>You’ll notice the only thing we changed here is we wrapped our entire app in the Dynamic provider. Once you have this set up, you can run your app and sign in with your favorite crypto wallet or create a wallet using your email. Complete the sign in flow on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://localhost">localhost</a>, and you’ll see in your Dynamic dashboard that a user has been created.</p><p style="text-align: start">We need to know if a user is connected or not so we can render the form. Let’s import Dynamic’s hook for managing login status. Add an additional import to the Dynamic React Core dependencies like this:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title class_">DynamicContextProvider</span>, <span class="hljs-title class_">DynamicWidget</span>, useIsLoggedIn } <span class="hljs-keyword">from</span> <span class="hljs-string">'@dynamic-labs/sdk-react-core'</span>;</code></pre><p>Then, right at the top of your function component, add this:</p><pre data-type="codeBlock"><code>const <span class="hljs-attr">isLoggedIn</span> = useIsLoggedIn()<span class="hljs-comment">;</span></code></pre><p>Now, we can simply check the <strong>LoggedIn</strong> boolean to determine if we should allow memecoin creation. In between the empty div in your file, add the following:</p><pre data-type="codeBlock"><code><span class="hljs-operator">&lt;</span>Form <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span></code></pre><p>Then, above your Home component, create a function component called Form like this:</p><pre data-type="codeBlock"><code>const Form <span class="hljs-operator">=</span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  const isLoggedIn <span class="hljs-operator">=</span> useIsLoggedIn();
  const [name, setName] <span class="hljs-operator">=</span> useState(<span class="hljs-string">""</span>)
  const [description, setDescription] <span class="hljs-operator">=</span> useState(<span class="hljs-string">""</span>)
  const [file, setFile] <span class="hljs-operator">=</span> useState<span class="hljs-operator">&lt;</span>any<span class="hljs-operator">&gt;</span>(null)

  const fileRef: any <span class="hljs-operator">=</span> useRef()

  const handleSubmit <span class="hljs-operator">=</span> async (e: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    e.preventDefault()
  }

  const handleNameChange <span class="hljs-operator">=</span> (e: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    setName(e.target.<span class="hljs-built_in">value</span>)
  }

  const handleDescriptionChange <span class="hljs-operator">=</span> (e: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    setDescription(e.target.<span class="hljs-built_in">value</span>)
  }

  const handleFileClick <span class="hljs-operator">=</span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    fileRef?.current?.click()
  }

  const handleFileChange <span class="hljs-operator">=</span> (e: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    setFile(e.target.files[<span class="hljs-number">0</span>])
  }
  
  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"h-full flex flex-col justify-center w-screen"</span><span class="hljs-operator">&gt;</span>
      {
        isLoggedIn <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
        <span class="hljs-operator">&lt;</span>form onSubmit<span class="hljs-operator">=</span>{handleSubmit}<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>label<span class="hljs-operator">&gt;</span>
              Name <span class="hljs-operator">&lt;</span>br <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>input <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> value<span class="hljs-operator">=</span>{name} onChange<span class="hljs-operator">=</span>{handleNameChange} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>label<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>label<span class="hljs-operator">&gt;</span>
              Description <span class="hljs-operator">&lt;</span>br <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>input <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> value<span class="hljs-operator">=</span>{description} onChange<span class="hljs-operator">=</span>{handleDescriptionChange} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>label<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>label<span class="hljs-operator">&gt;</span>
              File <span class="hljs-operator">&lt;</span>br <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>input name<span class="hljs-operator">=</span><span class="hljs-string">"filename"</span> className<span class="hljs-operator">=</span><span class="hljs-string">"hidden"</span> ref<span class="hljs-operator">=</span>{fileRef} <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"file"</span> accept<span class="hljs-operator">=</span><span class="hljs-string">"image/png, image/jpg, image/jpeg, image.gif"</span> onChange<span class="hljs-operator">=</span>{handleFileChange} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>p<span class="hljs-operator">&gt;</span>{file?.<span class="hljs-built_in">name</span> <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-string">""</span>}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>button onClick<span class="hljs-operator">=</span>{handleFileClick}<span class="hljs-operator">&gt;</span>Select file<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>label<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>button <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"submit"</span><span class="hljs-operator">&gt;</span>Upload<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>form<span class="hljs-operator">&gt;</span>
      }
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  )
}</code></pre><p>This is a very simple form that will allow us to collect a name, description, and image file for our memecoin. You can actually fire up your app and test this by running:</p><pre data-type="codeBlock"><code>npm run dev</code></pre><p>You’ll be able to log in with Dynamic and select an image file. But we still need to upload the file and create the metadata necessary for our memecoin. Let’s do that now.</p><p style="text-align: start">We have a <strong>handleSubmit</strong> ready. Let’s use that. Update it to look like this:</p><pre data-type="codeBlock"><code>const handleSubmit <span class="hljs-operator">=</span> async (e: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  e.preventDefault()
  const keyRes <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>key`, {
    method: <span class="hljs-string">"POST"</span>,
    headers: {
      <span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span>
    },
    body: null
  })

  const keyInfo <span class="hljs-operator">=</span> await keyRes.json()

  <span class="hljs-keyword">if</span> (keyInfo <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> keyInfo.message?.token) {
    <span class="hljs-comment">//  Now we can upload</span>
    const formData <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> FormData();
    formData.append(<span class="hljs-string">"file"</span>, file);

    const metadata <span class="hljs-operator">=</span> JSON.stringify({
      name: `${file.<span class="hljs-built_in">name</span>}`,
    });
    formData.append(<span class="hljs-string">"pinataMetadata"</span>, metadata);

    const options <span class="hljs-operator">=</span> JSON.stringify({
      cidVersion: <span class="hljs-number">1</span>,
    });
    formData.append(<span class="hljs-string">"pinataOptions"</span>, options);

    const uploadRes <span class="hljs-operator">=</span> await fetch(
      <span class="hljs-string">"https://api.pinata.cloud/pinning/pinFileToIPFS"</span>,
      {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          Authorization: `Bearer ${keyInfo.message.token}`,
        },
        body: formData,
      },
    );

    const cidData <span class="hljs-operator">=</span> await uploadRes.json()
    console.log(cidData)
  }
}</code></pre><p>We’re calling the API route we created to generate an API key, then we’re using that key after we build up our form data to upload our image. Once the image is uploaded, you’re logging out the IPFS info. However, we want to do more than that. We need to construct the token’s metadata. We’ll do that next, but there’s one other point to understand here…</p><p style="text-align: start">The request to our key generation API is unprotected. You can use Dynamic to get an auth token and verify it, or you can use some other method of your choice, but you should not leave that API endpoint unrestricted in a production environment.</p><p style="text-align: start">Ok, let’s create some metadata.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-evm-erc20-metadata"><strong>EVM ERC20 Metadata</strong></h2></div><p style="text-align: start">For an ERC20 token on an EVM (Ethereum Virtual Machine) compatible blockchain, you’ll want your token’s metadata to be formatted like this:</p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
<span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Token Name"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Token Description"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"external_url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Any website"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"decimals"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">18</span><span class="hljs-punctuation">,</span> <span class="hljs-comment">//total decimal points to support for coin, the more decimals, the smallet the possible denomination</span>
<span class="hljs-attr">"image"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"IPFS URI for image"</span>
<span class="hljs-punctuation">}</span></code></pre><p>This isn’t quite a “standard,” like NFT token metadata is, but many ERC20 project follow this format for uniformity. This metadata will be turned into a contract URI that can be called by anyone who wants to see it. Knowing this, we can take the data we have for our token creation and create a <strong>contractURI</strong> from similarly shaped JSON.</p><p style="text-align: start">Below where we logged out the upload response for our image, add the following:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">contractUriJSON</span> = {
  name: name,
  description: description,
  external_url: <span class="hljs-string">"https://pinata.cloud"</span>,
  decimals: 18,
  image: `ipfs:<span class="hljs-comment">//${cidData.IpfsHash}`</span>
}

<span class="hljs-keyword">const</span> <span class="hljs-variable constant_">jsonRes</span> = await <span class="hljs-title function_ invoke__">fetch</span>(<span class="hljs-string">'https://api.pinata.cloud/pinning/pinJSONToIPFS'</span>, {
  <span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</span>, 
  <span class="hljs-attr">headers</span>: {
    <span class="hljs-string">'Autorization'</span>: `<span class="hljs-attr">Bearer</span>: ${keyInfo.message.token}`, 
    <span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span>
  }, 
  <span class="hljs-attr">body</span>: JSON.<span class="hljs-title function_ invoke__">stringify</span>({
    <span class="hljs-attr">pinataOptions</span>: {
      <span class="hljs-attr">cidVersion</span>: 1, 
    }, 
    <span class="hljs-attr">pinataMetadata</span>: {
      <span class="hljs-attr">name</span>: <span class="hljs-string">"metadata.json"</span>
    },
    <span class="hljs-attr">pinataContent</span>: contractUriJSON
  })
})

<span class="hljs-keyword">const</span> <span class="hljs-variable constant_">uriData</span> = await jsonRes.<span class="hljs-title function_ invoke__">json</span>()
console.<span class="hljs-title function_ invoke__">log</span>(uriData)</code></pre><p>We’re creating a JSON object that matches the metadata format we showed above. Then we are using the same limited time use key we already generated to upload the JSON to IPFS. Then, we are logging out the response.</p><p style="text-align: start">What does this look like for Solana?</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-solana-spl-metadata"><strong>Solana SPL Metadata</strong></h2></div><p style="text-align: start">Solana does have a defined metadata standard for its tokens. This is very similar to NFTs, and it’s not too far off from the ERC20 object we created above. For a Solana SPL token, you’ll need to create an object that looks like this:</p><pre data-type="codeBlock"><code><span class="hljs-punctuation">{</span>
<span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"YOUR TOKEN NAME"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"symbol"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"YOUR TOKEN SYMBOL"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"description"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"YOUR TOKEN DESCRIPTION"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"image"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"YOUR IPFS URI"</span><span class="hljs-punctuation">,</span>
<span class="hljs-attr">"attributes"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-punctuation">]</span> <span class="hljs-comment">//Option attributes</span>
<span class="hljs-punctuation">}</span></code></pre><p>We’re going to skip the attributes in our token and keep it simple. We don’t have a token symbol in our form, so we’ll hardcode that, but you could add one more field to create a symbol. Here’s how this would look in our code. Below the console log that shows the response from uploading the image, add the following:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">const</span> <span class="hljs-variable constant_">splJSON</span> = {
  name: name,
  symbol: <span class="hljs-string">"TKN"</span>,
  description: description,
  image: `ipfs:<span class="hljs-comment">//${cidData.IpfsHash}`</span>
}

<span class="hljs-keyword">const</span> <span class="hljs-variable constant_">jsonRes</span> = await <span class="hljs-title function_ invoke__">fetch</span>(<span class="hljs-string">'https://api.pinata.cloud/pinning/pinJSONToIPFS'</span>, {
  <span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</span>, 
  <span class="hljs-attr">headers</span>: {
    <span class="hljs-string">'Autorization'</span>: `<span class="hljs-attr">Bearer</span>: ${keyInfo.message.token}`, 
    <span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span>
  }, 
  <span class="hljs-attr">body</span>: JSON.<span class="hljs-title function_ invoke__">stringify</span>({
    <span class="hljs-attr">pinataOptions</span>: {
      <span class="hljs-attr">cidVersion</span>: 1, 
    }, 
    <span class="hljs-attr">pinataMetadata</span>: {
      <span class="hljs-attr">name</span>: <span class="hljs-string">"metadata.json"</span>
    },
    <span class="hljs-attr">pinataContent</span>: contractUriJSON
  })
})

<span class="hljs-keyword">const</span> <span class="hljs-variable constant_">uriData</span> = await jsonRes.<span class="hljs-title function_ invoke__">json</span>()
console.<span class="hljs-title function_ invoke__">log</span>(uriData)</code></pre><p>That’s it. Similar to the ERC20 flow, we upload the JSON to IPFS and we now have a URI we can use in our token’s contract.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-whats-next"><strong>What’s next?</strong></h2></div><p style="text-align: start">In a future tutorial, we’ll show you how to deploy an ERC20 token contract as well as a Solana SPL token. For now, though, you have everything you need to start building tools that will get your memecoin’s media hosted on IPFS to preserve the public nature of the coin.</p><p style="text-align: start">This tutorial covered using Dynamic for wallet access, Next.js for server and client code, and Pinata for hosting images and JSON on IPFS. Now, you can create your own custom memecoins. When you are ready to display the memes associated with these coins, you simply need to fetch the image from IPFS using your dedicated gateway. If you remember, the image’s URI format uses the IPFS protocol URI like this: <strong>ipfs://CID</strong>. This creates maximum flexibility because you or anyone else can use any gateway they’d like to load the image. The dedicated IPFS gateway that comes with your Pinata account will be the fastest and most reliable way to load this content. It has a built in CDN and image optimization tools.</p><p style="text-align: start">You’ll be well equipped for memeing to your heart’s content. Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/c1116294482f8d2c7b2688ad3e70b93f.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How To Launch A Memecoin On Farcaster]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-launch-a-memecoin-on-farcaster</link>
            <guid>L3wArk4T9ZgtqOIpsXyD</guid>
            <pubDate>Tue, 14 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn how to use Pinata, Supabase, and Cloudflare to build an efficient way to track memecoin tipping and distribution on Farcaster.]]></description>
            <content:encoded><![CDATA[<p>In crypto, the new cultural zeitgeist is forming around memecoins. What is a memecoin? It’s exactly what it sounds like — a cryptocurrency built around a single meme (or multiple memes in some cases). The earliest and most successful example of a memecoin is Dogecoin. It’s been around for years, showing a staying power normally reserved for more “serious” coins. Today, we’re seeing an entirely new push around memecoins. After years of bubbles focused around the utility of various blockchain initiatives, memecoins offer no promise. Just memes.</p><p style="text-align: start">And much of the drive around memecoins is happening on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/what-is-farcaster"><strong><u>Farcaster</u></strong></a>. The decentralized social protocol saw the launch of the $DEGEN memecoin earlier this year, which seems to have sparked interest from other communities and developers in launching their own coins. A few examples native to Farcaster include Higher, Ham, 747 Airlines, and Bows. There are many more currently active, and there are many more under active development.</p><p style="text-align: start">But what does the process of building, launching, and supporting a memecoin look like, especially when it lives natively within one ecosystem? We’ll explore that in today’s tutorial.</p><p style="text-align: start"><em>Disclaimer: Memecoins can and often do have real financial impact. As such, be sure to ensure you remain regulatory complaint for your region. Pinata does not endorse any specific memecoins nor does it offer financial or legal advice.</em></p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-getting-started"><strong>Getting Started</strong></h2></div><p style="text-align: start">For this tutorial, we’re going to focus very little on the smart contract. I recommend taking a look at any of the available ERC20 tutorials out there as that’s the token type you’ll be using for your memecoin. However, in the real world, you’ll probably want to customize your contract quite a bit. Keep that in mind.</p><p style="text-align: start">Instead, we’re going to focus on the launch and management dynamics which will be a combination of onchain transactions and offchain data handling. As such, you’re going to need a few things:</p><ul><li><p>A <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://app.pinata.cloud/"><strong><u>Pinata account</u></strong></a>. Our free <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/farcaster/farcaster-api/getting-started"><strong><u>Farcaster Read API</u></strong></a> will make it easy to handle queries of the Farcaster network that will help power your memecoin distributions.</p></li><li><p>A <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://cloudflare.com/"><strong><u>free Cloudflare account</u></strong></a>. We’re going to make this very fast and scalable by using Cloudflare workers.</p></li><li><p>A <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://supabase.com/"><strong><u>free Supabase account</u></strong></a>. That’s right, we’re going to use a database to manage our decentralized currency. Actually, we’re just using a database to track allocations of the memecoin.</p></li></ul><p style="text-align: start">You’ll need a good code editor and some experience with the terminal, but that should be it for the accounts you’ll need to sign up for.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-memecoin-manager"><strong>Memecoin Manager</strong></h3></div><p style="text-align: start">Before we start writing code, we should think about what we need to launch and manage our memecoin. When the coin is first launched, there are two paths you can take:</p><ul><li><p>Preminting</p></li><li><p>Minting when people claim</p></li></ul><p style="text-align: start">When preminting, in most cases, a project will allocate tokens for airdrops, claims, and community in general. They may allocate tokens for other purposes as well, such as tipping. When people claim tokens, the tokens are transferred from one wallet to another.</p><p style="text-align: start">In contrast, when minting at the time of claim, there is no premint, so users who claim are minting and paying gas fees for the claim.</p><p style="text-align: start">There are benefits and drawbacks to each approach, but for our tutorial, we’re going to take the latter–minting when people claim.</p><p style="text-align: start">So, we will need to track:</p><ol><li><p>How much each person can claim</p></li><li><p>Offchain transactions that might adjust that claim amount (tipping, for example)</p></li></ol><p style="text-align: start">For this, we’ll use a Supabase PostgreSQL database and a Cloudflare worker script. We are going to be leveraging Farcaster for distribution, so tipping will be key. So we will need to make use of Pinata’s Farcaster APIs to determine if tips have been allocated via comments on posts. We will then need to have some logic that takes tips from one user and applies them to another, assuming the tipper has enough tipping allocation.</p><p style="text-align: start">Let’s write some code and see how this looks in practice. First, we’ll need to create a table in Supabase. Here are the columns you’ll need:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span>
  public.memecoin (
    id <span class="hljs-type">bigint</span> generated <span class="hljs-keyword">by</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">identity</span>,
    created_at <span class="hljs-type">timestamp</span> <span class="hljs-keyword">with</span> <span class="hljs-type">time</span> zone <span class="hljs-keyword">not</span> <span class="hljs-keyword">null</span> <span class="hljs-keyword">default</span> now(),
    updated_at <span class="hljs-type">timestamp</span> <span class="hljs-keyword">with</span> <span class="hljs-type">time</span> zone <span class="hljs-keyword">not</span> <span class="hljs-keyword">null</span> <span class="hljs-keyword">default</span> now(),
    fid <span class="hljs-type">bigint</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">null</span>,
    airdrop_claim <span class="hljs-type">bigint</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">null</span> <span class="hljs-keyword">default</span> <span class="hljs-string">'0'</span>::<span class="hljs-type">bigint</span>,
    tipping_balance <span class="hljs-type">bigint</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">null</span> <span class="hljs-keyword">default</span> <span class="hljs-string">'0'</span>::<span class="hljs-type">bigint</span>,
    tipped <span class="hljs-type">bigint</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">null</span> <span class="hljs-keyword">default</span> <span class="hljs-string">'0'</span>::<span class="hljs-type">bigint</span>,
    address text <span class="hljs-keyword">null</span>,
    username text <span class="hljs-keyword">null</span>,
    display_name text <span class="hljs-keyword">null</span>,
    pfp_url text <span class="hljs-keyword">null</span>,
    <span class="hljs-keyword">constraint</span> memecoin_pkey <span class="hljs-keyword">primary</span> key (id),
    <span class="hljs-keyword">constraint</span> memecoin_fid_key <span class="hljs-keyword">unique</span> (fid)
  ) tablespace pg_default;</code></pre><p>You can either manually create your table in Supabase or you can paste this query into their SQL query editor. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://supabase.com/docs/guides/database/tables"><strong><u>Here’s a guide on doing so</u></strong></a>.</p><p style="text-align: start">Once your table is created, we can spin up our Cloudflare project. This is incredibly easy with the Cloudflare’s Wrangler CLI, so let’s get to it.</p><p style="text-align: start">The CLI is going to create a directory for your project for you, so let’s run the command to initialize the project.</p><pre data-type="codeBlock"><code>npx wrangler <span class="hljs-keyword">init</span></code></pre><p>This process will walk you through creating your project, starting with naming the directory where your project will be housed. In this process, you will also need to decide what template to use. Pick the scheduled worker template:</p><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/26ada8a930038f97574e2c21bd6a6e6a.png" blurdataurl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAANCAIAAABHKvtLAAAACXBIWXMAAAsTAAALEwEAmpwYAAACx0lEQVR4nJWTz2vUQBTHgzkEAsF1DCFkG4hxl23WtBuYdbtmu5ZU11pZaopNTdsIA44QIcVsSetUXYkSEbGXQi+ttJJDD/0Xeuy/0n+gf0AP0h1ZRPSw38PwhvdmPu/HDKNpmmmaiqKIojhcJUlSVVXXdUVRdF2XJElRFFmWRVGktqqq0kAAABpTLBaZf0rX9YuLi8PDQ4zx+fk5ISQMw36/f3l5ube3d3p6enx8TAhJkiQMw93d3SiKTk5O8jx3HAdj7HlenudnZ2eu6zIMw7Ls3wCaAsY4jmMIIT3j+75l1QghCKFOp8OyLMdx7EDMqJJlWdd1hBAhxLbtMAwRQkEQGIaRpmkcx67rGoYRBEE0kGXVGIYZ8ob6L0CSpGKxiDGOoghCmCQJQsj3/UqlQu0sy2zbzrKMEIIxFkVxtAoAABDCb9+/h2E4Pz/fHqjRaARB4Pv+l69fZVkWBGE40pG7BACoQ/jj4OBjv7/R69m27ThOEKxt9K6a8257e3Jiolwu12qTjcbdqXp9bKw4IkAUy9Vqa/bB697GGn51uzJeb03PLy422jPl6h2rXl/wlh8vPJ1qTbvLz5dfIGuqeW2kIq7fuFG922jOzdXuz1abrfrso1prujk3Z83Mms1pVS9Vp+7BmQclo3qrYjxBLx96q+MTkyMAbg5a9PPoiGxttdvt1ZWVrc3Nz58+BaurrcGjitfX321vf/jwvg7hRi9Oer04fjNKiwCwrNrOzo5hGL7v09mOqWoURXmeZ1mGMdY0jRrPlpbeElIqleif4jiOXvLnq6X20HUFcBwny7IkSbrdbqfT8X2/2+2appmmqed5pmmGYbi/v39VTRzT4CiKXNeFEFpWjX5pTdPSNO33+57nIYTa7fZvAMuyPM8DAARB4Hme4zhBEChfEIRCocAPRAOoq1AoDIN5nqdbmisAgOd56qWAX7dF2DDwaRiFAAAAAElFTkSuQmCC" nextheight="404" nextwidth="1010" class="image-node embed"><p>This is going to give us a nice starting point for the cron job we’ll use for our memecoin manager. Now, if you open your project in your favorite code editor, you’re going to find a project src folder with an index.js or index.ts file, depending on whether or not you chose to work in Typescript. I’m going to assume Typescript, so adjust accordingly.</p><p style="text-align: start">If you take a look at your index.ts file, you’ll see Cloudflare’s Wrangler CLI was nice enough to document a lot of the usage patterns for workers in comments. There’s a problem, though. This template assumes a single cron job running on a single cadence. We’re going to run multiple cron jobs that call different functions. Let’s take a look at what our cron trigger functions are going to be and what frequency they will be executed.</p><p style="text-align: start">We want to find all the casts that match what we’re looking for. We should do this pretty frequently because this is how people will receive tips that have been sent to them. For this tutorial, we’ll run this cron job every two minutes.</p><p style="text-align: start">The other function we need to run is a tipping allocation reset. For simplicity, at the end of every day, we’re going to reset everyone’s tipping allocation to 1000. From here, you can add custom rules that control how much each person gets, all while using the same function and same frequency. But we’ll keep it simple.</p><p style="text-align: start">So, let’s set up our index.ts file. In that file, replace everything with:</p><pre data-type="codeBlock"><code><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
	<span class="hljs-function">async <span class="hljs-title">scheduled</span><span class="hljs-params">(event: ScheduledEvent, env: Env, ctx: ExecutionContext)</span>: Promise {</span>
		<span class="hljs-keyword">switch</span> (event.cron) {
			<span class="hljs-keyword">case</span> <span class="hljs-string">"*/2 * * * *"</span>:
				<span class="hljs-comment">// Every two minutes</span>
				console.<span class="hljs-built_in">log</span>(<span class="hljs-string">"Find casts"</span>)
				<span class="hljs-function">await <span class="hljs-title">findCasts</span><span class="hljs-params">(env)</span></span>;
				<span class="hljs-keyword">break</span>;
			<span class="hljs-keyword">case</span> <span class="hljs-string">"0 0 * * *"</span>:
				<span class="hljs-comment">// Every day</span>
				console.<span class="hljs-built_in">log</span>(<span class="hljs-string">"Updating tipping balance"</span>)
				<span class="hljs-function">await <span class="hljs-title">updateDailyTipBalance</span><span class="hljs-params">(env)</span></span>;
				<span class="hljs-keyword">break</span>;
		}
	},
};</code></pre><p>As you can tell, this is creating two scheduled events, one that runs daily and one that runs every two minutes. It’s worth pointing out that you must pass the environment variables that are exposed as arguments to our scheduled function to any functions that we use within our cron flow.</p><p style="text-align: start">You can add as many of these cron functions as you want, but you’ll want to make sure to update your wrangler.toml file to support each cron cadence you add. Open that file and either uncomment the cron section and change it or simply add this:</p><pre data-type="codeBlock"><code><span class="hljs-section">[triggers]</span>
<span class="hljs-attr">crons</span> = [<span class="hljs-string">"*/2 * * * *"</span>, <span class="hljs-string">"0 0 * * *"</span>]</code></pre><p>This file is used when deploying your project to Cloudflare, so if you don’t set this in the wrangler.toml file, then your cron functions will never be executed.</p><p style="text-align: start">Of course, we have set up the triggers, but we haven’t written our functions. Let’s start with the findCasts function. In your index.ts file, add the following:</p><pre data-type="codeBlock"><code>const findCasts <span class="hljs-operator">=</span> async (env: Env) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
	const supabase <span class="hljs-operator">=</span> createClient(env.SUPABASE_URL, env.SUPABASE_KEY)
	<span class="hljs-comment">//	First get the timestamp to query after</span>
	let { data: timestamp, <span class="hljs-function"><span class="hljs-keyword">error</span>: <span class="hljs-title">timestampError</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
		.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'query_timestamp'</span></span>)
		.<span class="hljs-title">select</span>(<span class="hljs-params"><span class="hljs-string">'timestamp'</span></span>)
		.<span class="hljs-title">eq</span>(<span class="hljs-params"><span class="hljs-string">"id"</span>, <span class="hljs-number">1</span></span>)

	<span class="hljs-title"><span class="hljs-keyword">if</span></span> (<span class="hljs-params">timestampError</span>) </span>{
		console.log(<span class="hljs-string">"Timestamp error"</span>)
		<span class="hljs-keyword">throw</span> timestampError
	}

	const timestamp1 <span class="hljs-operator">=</span> timestamp<span class="hljs-operator">!</span>[<span class="hljs-number">0</span>].timestamp
	let resp: any <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">'https://api.pinata.cloud/v3/farcaster/casts?pageSize=2000&amp;reverse=true'</span>, {
		headers: {
			<span class="hljs-string">'Authorization'</span>: `Bearer ${env.PINATA_JWT}`
		}
	});
	const data: CastResponse <span class="hljs-operator">=</span> await resp.json()
	<span class="hljs-comment">//	Get the most recent timestamp</span>
	const newestTimestamp <span class="hljs-operator">=</span> data.casts[<span class="hljs-number">0</span>].timestamp
	const lastTimestamp <span class="hljs-operator">=</span> data.casts[data.casts.<span class="hljs-built_in">length</span> <span class="hljs-operator">-</span> <span class="hljs-number">1</span>].timestamp

	const casts: Cast[] <span class="hljs-operator">=</span> data.casts;
	await handleTippingUpdates(env, casts);
	<span class="hljs-keyword">if</span> (data.next?.cursor <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> timestamp <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-keyword">new</span> Date(timestamp[<span class="hljs-number">0</span>].timestamp) <span class="hljs-operator">&lt;</span><span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> Date(lastTimestamp)) {
		console.log(<span class="hljs-string">"timestamp is old"</span>)
		let hasMore <span class="hljs-operator">=</span> <span class="hljs-literal">true</span>;
		let token <span class="hljs-operator">=</span> data.next.cursor
		<span class="hljs-keyword">while</span> (hasMore) {
			<span class="hljs-keyword">try</span> {
				let resp: any <span class="hljs-operator">=</span> await fetch(`https:<span class="hljs-comment">//api.pinata.cloud/v3/farcaster/casts?pageSize=2000&amp;reverse=true&amp;pageToken=${token}`, {</span>
					headers: {
						<span class="hljs-string">'Authorization'</span>: `Bearer ${env.PINATA_JWT}`
					}
				});

				const newData: CastResponse <span class="hljs-operator">=</span> await resp.json()
				const newCasts: Cast[] <span class="hljs-operator">=</span> newData.casts;

				await handleTippingUpdates(env, newCasts);
				const timestamp2 <span class="hljs-operator">=</span> newData.casts[newData.casts.<span class="hljs-built_in">length</span> <span class="hljs-operator">-</span> <span class="hljs-number">1</span>].timestamp

				<span class="hljs-keyword">if</span> (timestamp2 <span class="hljs-operator">&lt;</span> timestamp1) {
					console.log(<span class="hljs-string">"Timestamps are caught up"</span>)
					hasMore <span class="hljs-operator">=</span> <span class="hljs-literal">false</span>
					await updateTimestamp(env, newestTimestamp)
				} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>newData.next?.cursor) {
					console.log(<span class="hljs-string">"No more page tokens"</span>)
					hasMore <span class="hljs-operator">=</span> <span class="hljs-literal">false</span>
					await updateTimestamp(env, newestTimestamp)
				}
			} <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
				console.log(<span class="hljs-string">"Error in the while loop"</span>)
				console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
				<span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
			}
		}
	}
}</code></pre><p>This is relatively straightforward. We are looping. The easiest, safest thing in programming. Just kidding. You can mess up a lot here, so let’s make sure we understand what’s going on.</p><p style="text-align: start">Note that, as I mentioned before, we’re passing environment variables in as an argument to the function we’re using for the cron job here. Unlike other env systems in Node.js, using envs in Cloudflare workers means simply references them like this:</p><pre data-type="codeBlock"><code></code></pre><p>To set your envs, you can create a file called .dev.vars. Make sure to add this to your .gitignore. The format of this file is the same as any other env file you’ve created.</p><p style="text-align: start">Now, let’s check out the code. We are using the query_timestamp table from Supabase to make sure we have a central source of truth for the timestamp we’ll use to find casts that have happened since. With this timestamp, we know when to stop looping, but let’s explore how.</p><p style="text-align: start">Using the Pinata Farcaster Read API, we can get all casts in reverse chronological order. We can set our page size to make sure we get the most casts in a single request that is allowed. The trick is we need to use the next.cursor portion of the API response to continue fetching casts until we find casts that is before or equal to the timestamp stored in our database.</p><p style="text-align: start">We need to break out of the loop when we have found a matching timestamp, or one that happens before our database timestamp, OR we need to break out of the loop if there happens to not be a next.cursor in the response. But, to be honest, if we get into a situation where we don’t have a next.cursor, then it probably means that we have made a mistake and just accidentally queried all casts in the history of the Farcaster network.</p><p style="text-align: start">If you notice, we call a function called handleTippingUpdates in the loop. This function is important because it’s going to do all the lifting of finding casts that represent tips. Let’s write that function now.</p><pre data-type="codeBlock"><code>const handleTippingUpdates <span class="hljs-operator">=</span> async (env: Env, casts: Cast[]) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
	console.log(<span class="hljs-string">"Searching casts"</span>);
	const supabase <span class="hljs-operator">=</span> createClient(env.SUPABASE_URL, env.SUPABASE_KEY)
	<span class="hljs-keyword">try</span> {
		<span class="hljs-keyword">for</span> (const cast of casts.reverse()) {
			<span class="hljs-keyword">if</span> (cast.content.includes(<span class="hljs-string">"$memecoin"</span>)) {
				let textRegex <span class="hljs-operator">=</span> <span class="hljs-operator">/</span>(\d<span class="hljs-operator">+</span>)\s<span class="hljs-operator">+</span>\$memecoin<span class="hljs-operator">/</span>;				
				let textMatch <span class="hljs-operator">=</span> cast.content.match(textRegex);

				let tipAmount;
				<span class="hljs-keyword">if</span> (textMatch) {
					console.log(<span class="hljs-string">"Text match: "</span>, textMatch)
					tipAmount <span class="hljs-operator">=</span> parseInt(textMatch[<span class="hljs-number">1</span>]);
				} 

				let { data: balanceForTipper, <span class="hljs-function"><span class="hljs-keyword">error</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
					.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'balance'</span></span>)
					.<span class="hljs-title">select</span>(<span class="hljs-params"><span class="hljs-string">'tipping_balance'</span></span>)
					.<span class="hljs-title">eq</span>(<span class="hljs-params"><span class="hljs-string">"fid"</span>, cast.fid</span>)

				<span class="hljs-title"><span class="hljs-keyword">if</span></span> (<span class="hljs-params">balanceForTipper &amp;&amp; balanceForTipper[<span class="hljs-number">0</span>]?.tipping_balance</span>) </span>{
					const tippingBalance <span class="hljs-operator">=</span> balanceForTipper <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> balanceForTipper[<span class="hljs-number">0</span>] ? balanceForTipper[<span class="hljs-number">0</span>].tipping_balance : <span class="hljs-number">0</span>
					await updateTippingBalances(env, tipAmount <span class="hljs-operator">|</span><span class="hljs-operator">|</span> <span class="hljs-number">0</span>, tippingBalance, cast)
				}
			} 
		}
	} <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
		console.log(<span class="hljs-string">"Tipping updates error"</span>)
		console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)
		<span class="hljs-title"><span class="hljs-keyword">throw</span></span> <span class="hljs-title"><span class="hljs-keyword">error</span></span></span>;
	}
}
</code></pre><p>This function checks the cast text to see if there is a mention of the memecoin name. For the sake of this tutorial, the name of the coin is simply “memecoin” but you would check for mentions of your coin’s name. If there is a mention found, we need a regex so that we can find how many of the coin is being tipped.</p><p style="text-align: start">If there is a regex match, we then need to figure out who sent the cast and make sure they have a tipping balance available. We use the database for this and simply query the balance table we created earlier. Next, assuming the tipping balance is sufficient, we will decrease the tipping balance available for the person sending the tip and increase the tipped column for the person receiving the tip. This happens through another function called updateTippingBalances. Let’s write that function now. In the same file, add this:</p><pre data-type="codeBlock"><code>const updateTippingBalances <span class="hljs-operator">=</span> async (env: Env, tipAmount: number, tippingBalance: number, cast: Cast) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
	const supabase <span class="hljs-operator">=</span> createClient(env.SUPABASE_URL, env.SUPABASE_KEY)
	<span class="hljs-keyword">try</span> {
		<span class="hljs-comment">//	Get user to allocate tip to</span>
		const parent <span class="hljs-operator">=</span> cast.parentAuthor ? cast.parentAuthor.fid : null
		<span class="hljs-keyword">if</span> (tipAmount <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> parent <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> tippingBalance <span class="hljs-operator">&gt;</span><span class="hljs-operator">=</span> tipAmount) {
			console.log(<span class="hljs-string">"Tipping!"</span>)
			<span class="hljs-comment">//	Allocated tipped amount</span>
			let { data: balanceForReceiver, <span class="hljs-function"><span class="hljs-keyword">error</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
				.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'balance'</span></span>)
				.<span class="hljs-title">select</span>(<span class="hljs-params"><span class="hljs-string">'tipped'</span></span>)
				.<span class="hljs-title">eq</span>(<span class="hljs-params"><span class="hljs-string">"fid"</span>, parent</span>)

			<span class="hljs-title"><span class="hljs-keyword">if</span></span> (<span class="hljs-params"><span class="hljs-keyword">error</span></span>) </span>{
				console.log(<span class="hljs-string">"Error getting balance for recipient"</span>)
				<span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span>
			}

			<span class="hljs-title">let</span> <span class="hljs-title">isRecipientInDB</span> = <span class="hljs-title">balanceForReceiver</span> &amp;&amp; <span class="hljs-title">balanceForReceiver</span>[0] ? <span class="hljs-title"><span class="hljs-literal">true</span></span> : <span class="hljs-title"><span class="hljs-literal">false</span></span>

			<span class="hljs-title">let</span> <span class="hljs-title">tippedbalance</span> = <span class="hljs-title">balanceForReceiver</span> &amp;&amp; <span class="hljs-title">balanceForReceiver</span>[0] ? <span class="hljs-title">balanceForReceiver</span>[0].<span class="hljs-title">tipped</span> : 0
			<span class="hljs-title">const</span> <span class="hljs-title">updated</span> = <span class="hljs-title">tippedbalance</span> + <span class="hljs-title">tipAmount</span></span>;

			<span class="hljs-keyword">if</span> (isRecipientInDB) {
				const { data: updatedData, <span class="hljs-function"><span class="hljs-keyword">error</span>: <span class="hljs-title">upsertError</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
					.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'balance'</span></span>)
					.<span class="hljs-title">upsert</span>(<span class="hljs-params">{ tipped: updated, fid: parent }, { onConflict: <span class="hljs-string">"fid"</span> }</span>)
					.<span class="hljs-title">select</span>(<span class="hljs-params"></span>)

				<span class="hljs-title"><span class="hljs-keyword">if</span></span> (<span class="hljs-params">upsertError</span>) </span>{
					console.log(<span class="hljs-string">"Updating recipient balance error"</span>)
					console.log(upsertError)
					<span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
				}
			} <span class="hljs-keyword">else</span> {
				<span class="hljs-comment">//	Need to get the user's info and add them to the db</span>
				await getUserDataAndAddToDB(env, parent, <span class="hljs-literal">false</span>, updated)
			}

			<span class="hljs-comment">//	Reduce tipper's balance</span>
			const newTippingBalance <span class="hljs-operator">=</span> tippingBalance <span class="hljs-operator">-</span> tipAmount

			const { data: updatedTipperBalance, <span class="hljs-function"><span class="hljs-keyword">error</span>: <span class="hljs-title">updatedTipperError</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
				.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'balance'</span></span>)
				.<span class="hljs-title">upsert</span>(<span class="hljs-params">{ tipping_balance: newTippingBalance, fid: cast.author.fid }, { onConflict: <span class="hljs-string">"fid"</span> }</span>)
				.<span class="hljs-title">select</span>(<span class="hljs-params"></span>)
		}

		<span class="hljs-title"><span class="hljs-keyword">return</span></span></span>;
	} <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
		console.log(<span class="hljs-string">"Update tipping balances error"</span>)
		console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
		<span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
	}
}</code></pre><p>There’s quite a bit going on in this function, so let’s spend some time here. First, we use it to figure out who should receive the tipped memecoins. This is very simple, thanks to the Pinata API. We just need to grab the parent author FID, which tells us who the person sending the tip is responding to. Now, we need to find that user in the database. This is where we have some branching logic because, depending on how you populate your balance table initially, it’s not guaranteed that everyone receiving tips will be in the database. Let’s check out the logic.</p><p style="text-align: start">If the recipient is already in the database, we simply update the values appropriately with an upsert. Very straightforward. Not much to say here.</p><p style="text-align: start">Now, if the user is not in the database, we need to add them, but we need to add them with values that are defined by how our memecoin project works. For example, does this person get an initial airdrop claim outside of the tip? If not, you need to make sure to add them with a 0 in that column. If they do get an airdrop claim, how much and from what criteria? These are questions you have to answer as part of your question, but the template above is flexible enough to handle any decision. We add the user to the database using a dedicated function. Go ahead and add this function above in the same file:</p><pre data-type="codeBlock"><code>const getUserDataAndAddToDB <span class="hljs-operator">=</span> async (env: Env, fid: number, addAirdrop: boolean, updatedTippedAmount?: number) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
	const supabase <span class="hljs-operator">=</span> createClient(env.SUPABASE_URL, env.SUPABASE_KEY)
	<span class="hljs-keyword">try</span> {
		const userRes <span class="hljs-operator">=</span> await fetch(`https:<span class="hljs-comment">//api.pinata.cloud/v3/farcaster/users/${fid}`, {</span>
			headers: {
				<span class="hljs-string">'Authorization'</span>: `Bearer ${env.PINATA_JWT}`
			}
		})

		const data: any <span class="hljs-operator">=</span> await userRes.json();

		const { user } <span class="hljs-operator">=</span> data;

		const newRecord <span class="hljs-operator">=</span> {
			fid: fid,
			username: user.username,
			display_name: user.display_name,
			pfp_url: user.pfp_url,
			airdrop_claim: addAirdrop ? AIRDROP : <span class="hljs-number">0</span>,
			tipping_balance: addAirdrop ? TIPPING_ALLOTMENT : <span class="hljs-number">0</span>,
			tipped: updatedTippedAmount ? updatedTippedAmount : <span class="hljs-number">0</span>,
			daily_tipping_balance: <span class="hljs-number">0</span>,
			claimed: <span class="hljs-literal">false</span>,
			<span class="hljs-keyword">address</span>: data.verifications <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> data.verifications.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span> ? data.verifications[<span class="hljs-number">0</span>] : data.custody_address
		}

		const { data: insertData, <span class="hljs-function"><span class="hljs-keyword">error</span>: <span class="hljs-title">insertError</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
			.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'balance'</span></span>)
			.<span class="hljs-title">insert</span>(<span class="hljs-params">[newRecord]</span>)
			.<span class="hljs-title">select</span>(<span class="hljs-params"></span>)

		<span class="hljs-title"><span class="hljs-keyword">if</span></span> (<span class="hljs-params">insertError</span>) </span>{
			console.log(<span class="hljs-string">"Insert error"</span>)
			console.log(insertError)
			<span class="hljs-keyword">throw</span> insertError
		}
	} <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
		console.log(<span class="hljs-string">"Get user data and add to db error"</span>)
		console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
		<span class="hljs-keyword">throw</span> <span class="hljs-function"><span class="hljs-keyword">error</span>
	}
}</span></code></pre><p>I have some variables that represent adding an airdrop balance and how much, as well as an initial tipping allotment and whether it should be updated. This is configurability you can choose to ignore or extend. But, ultimately, this function gets the user data from the Pinata Farcaster API based on the user’s FID and inserts it into the database.</p><p style="text-align: start">Let’s return to our updateTippingBalances function. We need to reduce the tipper’s balance. We know they are in the database because we already checked early to make sure they had a tipping balance to use. So, this is a little simpler. We just reduce the tipped amount from their allowance.</p><p style="text-align: start">And that’s it… For finding casts that tip your memecoin and making adjustments. Now we need to write a cron function that updates the daily tipping allowance. This will be much simpler. Add the following function in your index.ts file:</p><pre data-type="codeBlock"><code>const updateDailyTipBalance <span class="hljs-operator">=</span> async (env: Env) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
	const supabase <span class="hljs-operator">=</span> createClient(env.SUPABASE_URL, env.SUPABASE_KEY)
	const { data, <span class="hljs-function"><span class="hljs-keyword">error</span> } = <span class="hljs-title">await</span> <span class="hljs-title">supabase</span>
		.<span class="hljs-title"><span class="hljs-keyword">from</span></span>(<span class="hljs-params"><span class="hljs-string">'balance'</span></span>)
		.<span class="hljs-title">update</span>(<span class="hljs-params">{ tipping_balance: <span class="hljs-number">1000</span> }</span>)
		.<span class="hljs-title">neq</span>(<span class="hljs-params"><span class="hljs-string">"tipping_balance"</span>, <span class="hljs-number">1000</span></span>)

	<span class="hljs-title"><span class="hljs-keyword">if</span></span> (<span class="hljs-params"><span class="hljs-keyword">error</span></span>) </span>{
		console.error(<span class="hljs-string">'Error updating tip_balance:'</span>, <span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
		<span class="hljs-keyword">return</span>;
	}

	console.log(<span class="hljs-string">'Updated tip_balance for all rows:'</span>, data);
}</code></pre><p>Remember, this function will run once a day and, to keep things simple, we are setting the daily tipping balance for everyone to 1000. You will want to create your own logic for this, but you can generally follow the same pattern of running this function daily or weekly or whatever you need.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-conclusion"><strong>Conclusion</strong></h3></div><p style="text-align: start">You’ve made it. You have the cron job infrastructure to manage the entire backend processing of your memecoin’s economy. This was the hard part, young padawan. Your smart contract can be as complex or as simple as you need, but here are a few things to think about.</p><ol><li><p>Will you be airdropping claims to your users or will they be minting them into their wallets?</p></li><li><p>If they are minting them, how will you manage the allowlist? You’ll have a database of users and the balances they receive. A merkle root system would work well here.</p></li><li><p>How often will you have people claim their tokens?</p></li><li><p>Will your token have liquidity initially or organically?</p></li></ol><p style="text-align: start">Creating a memecoin is not as simple as writing a smart contract. You have to manage the “back office” with queries that span the Farcaster network. Luckily, Pinata makes this easy with the Farcaster API. Combine that with easy-to-use tools like Cloudflare workers and Supabase, and you have a winning recipe.</p><p style="text-align: start">Happy Memeing!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/e780252b2b2e4072c48f24fb57732c45.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[How To Build A Lite Client With The Pinata Farcaster API]]></title>
            <link>https://paragraph.com/@pinatacloud/how-to-build-a-lite-client-with-the-pinata-farcaster-api</link>
            <guid>ac4l4HF1RDqvBYKa16pE</guid>
            <pubDate>Fri, 03 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Build your Farcaster client easily with our detailed guide!]]></description>
            <content:encoded><![CDATA[<p>Over the past few months, we’ve written a lot of content on building Farcaster apps, but nothing has evolved more quickly than Farcaster Clients. In our post on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-build-a-farcaster-client"><strong><u>How to Build a Farcaster Client</u></strong></a>, we walked you through how you could go through the whole flow using just the Hub API and manually handling signers, but since then Pinata has made so many aspects of client building easy. That’s how it should be; things like handling auth, sending casts, and building feeds should be easy so that you can focus on what makes your client shine. In this tutorial, we’ll show you the basics of building a lite client, using the latest and greatest from Pinata!</p><div class="relative header-and-anchor"><h2 id="h-setup"><strong>Setup</strong></h2></div><p>As we go through the pieces of building a client, we’ll show you the high level of each piece and how you may want to implement it into your stack or UI components. Additionally you will need the following:</p><div class="relative header-and-anchor"><h3 id="h-pinata-account"><strong>Pinata Account</strong></h3></div><p>The first thing you’ll need is a Pinata account, which you can start for free by signing up <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://app.pinata.cloud/register"><strong><u>here</u></strong></a>. If you want to use managed signers, then you will need a paid plan (<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="mailto:steve@pinata.cloud?subject=I%20read%20your%20blog%20post%2C%20I%27d%20love%20a%20coupon%20code!"><strong><u>hit me up</u></strong></a> if you want a coupon <span data-name="wink" class="emoji" data-type="emoji">😉</span>). Otherwise, you can try handling signers manually with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-sign-in-with-warpcast"><strong><u>this post</u></strong></a>. But, trust me, you’ll want to see how much easier it is in this post. Once you create your account, all you need to do is create an API key with <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/account-management/api-keys"><strong><u>these instructions</u></strong></a>. That’s it!</p><div class="relative header-and-anchor"><h3 id="h-farcaster-account"><strong>Farcaster Account</strong></h3></div><p>If you are going to be creating signers and allowing users to send casts through your app, then you will likely want a Farcaster Account just for your app, similar to how <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://Photocaster.xyz"><strong><u>Photocaster.xyz</u></strong></a> has its own account at <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://warpcast.com/photocast"><strong><u>@photocast</u></strong></a>. With that Farcaster account, you will need both the FID for the account, and the mnemonic phrase that will be used for signing keys that will be assigned to users. Again, all of these are only required if you are making a client that sends casts. If you are doing a read-only client, then we’d love to see it in <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://warpcast.com/~/channel/pinata"><strong><u>/pinata</u></strong></a>!</p><div class="relative header-and-anchor"><h3 id="h-stack"><strong>Stack</strong></h3></div><p>For this guide, we’ll be using Next.js with the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/farcaster/fdk/getting-started"><strong><u>Pinata FDK</u></strong></a>, but most of these principles can be migrated over to other stacks in typescript. If you want to work in another language, then we’ve got you covered there too, as everything done with the FDK can be done through the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.pinata.cloud/farcaster/farcaster-api"><strong><u>Pinata Farcaster API</u></strong></a>. If you do follow along in this Next.js tutorial, our <strong>.env.local</strong> file will look something like this:</p><pre data-type="codeBlock"><code><span class="hljs-comment"># The JWT provided when creating a Pinata API key</span>
PINATA_JWT=
<span class="hljs-comment"># The mnemonic phrase for your Farcaster App account, e.g. "taco salsa burgers fries..."</span>
<span class="hljs-attr">DEVELOPER_MNEMONIC</span>=<span class="hljs-string">""</span>
<span class="hljs-comment"># The FID for your Farcaster App account</span>
DEVELOPER_FID=</code></pre><p>With all of that ready to go, let’s start with getting users signed in.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-farcaster-auth"><strong>Farcaster Auth</strong></h2></div><p style="text-align: start">We’ve covered <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.pinata.cloud/blog/how-to-add-farcaster-auth-to-next-js"><strong><u>how to add Farcaster Auth to your Next.js App</u></strong></a> already, but we’ll do a short recap with some bonus implementations. When users sign in, there will be two steps. One will be through <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/farcasterxyz/auth-monorepo"><strong><u>Auth-Kit by Farcaster</u></strong></a>, and the other will be through Pinata’s Farcaster Auth. The first sign in doesn’t grant write access to your app, but it does provide a signed message that can be used to verify the person is who they say they are on an FID level. With that information, we can either create a new signer for the user, or fetch one that has already been made.</p><p style="text-align: start">To start, we’ll make a component to wrap other pieces of our sign in flow.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Button</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/components/ui/button"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Dialog</span>, <span class="hljs-title">DialogContent</span>, <span class="hljs-title">DialogTrigger</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/components/ui/dialog"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"@farcaster/auth-kit/styles.css"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">AuthKitProvider</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@farcaster/auth-kit"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">SignIn</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/components/sign-in"</span>;

const config <span class="hljs-operator">=</span> {
  rpcUrl: <span class="hljs-string">"https://mainnet.optimism.io"</span>,
  domain: <span class="hljs-string">"farcaster-lazy-client.vercel.app"</span>,
  siweUri: <span class="hljs-string">"https://farcaster-lazy-client.vercel.app/api/retrieveSigner"</span>,
};

export <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Auth</span>(<span class="hljs-params"></span>) </span>{
  const [open, setOpen] <span class="hljs-operator">=</span> useState(<span class="hljs-literal">false</span>);

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>AuthKitProvider config<span class="hljs-operator">=</span>{config}<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>Dialog open<span class="hljs-operator">=</span>{open} onOpenChange<span class="hljs-operator">=</span>{setOpen}<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>DialogTrigger asChild<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>Button className<span class="hljs-operator">=</span><span class="hljs-string">"sm:w-[500px] w-full mt-4"</span> variant<span class="hljs-operator">=</span><span class="hljs-string">"outline"</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">+</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Button<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>DialogTrigger<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span>DialogContent className<span class="hljs-operator">=</span><span class="hljs-string">"sm:max-w-[425px] max-w-[375px]"</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>SignIn <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>DialogContent<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Dialog<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>AuthKitProvider<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Here we setup our <strong>AuthKitProvider</strong> with a config using our info, such as the <strong>rpcUrl</strong>, <strong>domain</strong>, and <strong>siweUri</strong>. Then, using some UI components from <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://ui.shadcn.com/"><strong><u>shadcn/ui</u></strong></a>, we’ll create a popup modal with a <strong>SignIn</strong> component where all the magic happens.</p><pre data-type="codeBlock"><code><span class="hljs-string">"use client"</span>;

<span class="hljs-keyword">import</span> { <span class="hljs-title">QRCode</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react-qrcode-logo"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Button</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./ui/button"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">SignInButton</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@farcaster/auth-kit"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">CastForm</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/components/cast-form"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">useEffect</span>, <span class="hljs-title">useState</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-title">Link</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/link"</span>;

export <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">SignIn</span>(<span class="hljs-params"></span>) </span>{
  const [deepLink, setDeepLink]: any <span class="hljs-operator">=</span> useState();
  const [openQR, setOpenQR] <span class="hljs-operator">=</span> useState(<span class="hljs-literal">false</span>);
  const [fid, setFid]: any <span class="hljs-operator">=</span> useState();
  const [signerId, setSignerId]: any <span class="hljs-operator">=</span> useState();

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSigner</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">try</span> {
      const signerReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>signer`, {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
        },
      });
      const signerRes <span class="hljs-operator">=</span> await signerReq.json();
      setDeepLink(signerRes.deep_link_url);
      setOpenQR(<span class="hljs-literal">true</span>);

      const pollReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>poll?token<span class="hljs-operator">=</span>${signerRes.token}`);
      const pollRes <span class="hljs-operator">=</span> await pollReq.json();
      const pollStartTime <span class="hljs-operator">=</span> Date.now();
      <span class="hljs-keyword">while</span> (pollRes.state <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-string">"completed"</span>) {
        <span class="hljs-keyword">if</span> (Date.now() <span class="hljs-operator">-</span> pollStartTime <span class="hljs-operator">&gt;</span> <span class="hljs-number">120000</span>) {
          console.log(<span class="hljs-string">"Polling timeout reached"</span>);
          alert(<span class="hljs-string">"Request timed out"</span>);
          setOpenQR(<span class="hljs-literal">false</span>);
          <span class="hljs-keyword">break</span>;
        }
        const pollReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>poll?token<span class="hljs-operator">=</span>${signerRes.token}`);
        const pollRes <span class="hljs-operator">=</span> await pollReq.json();
        <span class="hljs-keyword">if</span> (pollRes.state <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"completed"</span>) {
          setDeepLink(null);
          setOpenQR(<span class="hljs-literal">false</span>);
          setSignerId(signerRes.signer_id);
          localStorage.setItem(<span class="hljs-string">"signer_id"</span>, signerRes.signer_id);
          <span class="hljs-keyword">return</span> pollRes;
        }
        await <span class="hljs-keyword">new</span> Promise((resolve) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setTimeout(resolve, <span class="hljs-number">2000</span>));
      }
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    }
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">checkStorage</span>(<span class="hljs-params">signature?: any, message?: any, nonce?: any</span>) </span>{
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">if</span> (typeof window <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-string">"undefined"</span>) {
        const signer <span class="hljs-operator">=</span> localStorage.getItem(<span class="hljs-string">"signer_id"</span>);
        <span class="hljs-keyword">if</span> (signer <span class="hljs-operator">!</span><span class="hljs-operator">=</span> null) {
          setSignerId(signer);
        } <span class="hljs-keyword">else</span> {
          const data <span class="hljs-operator">=</span> JSON.stringify({
            message: message,
            signature: signature,
            nonce: nonce,
          });
          const signerReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>retrieveSigner`, {
            method: <span class="hljs-string">"POST"</span>,
            headers: {
              <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
            },
            body: data,
          });
          const signerRes <span class="hljs-operator">=</span> await signerReq.json();
          <span class="hljs-keyword">if</span> (signerRes.signers <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> signerRes.signers.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>) {
            console.log(<span class="hljs-string">"signer found and set"</span>);
            setSignerId(signerRes.signers[<span class="hljs-number">0</span>].signer_uuid);
            localStorage.setItem(<span class="hljs-string">"signer_id"</span>, signerRes.signers[<span class="hljs-number">0</span>].signer_uuid);
          } <span class="hljs-keyword">else</span> {
            console.log(<span class="hljs-string">"no signer found"</span>);
            <span class="hljs-keyword">return</span>;
          }
        }
      }
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    }
  }

  async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleSignInSuccess</span>(<span class="hljs-params">{ fid, signature, message, nonce } : any</span>)</span>{
    setFid(fid)
    checkStorage(signature, message, nonce)
  }

  useEffect(() <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    checkStorage();
  }, []);

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"mx-auto"</span><span class="hljs-operator">&gt;</span>
      {<span class="hljs-operator">!</span>signerId <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> fid <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col gap-3"</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>Button onClick<span class="hljs-operator">=</span>{createSigner}<span class="hljs-operator">&gt;</span>Create Signer<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Button<span class="hljs-operator">&gt;</span>
          {openQR <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
            <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col gap-3"</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>QRCode
                value<span class="hljs-operator">=</span>{deepLink}
                size<span class="hljs-operator">=</span>{<span class="hljs-number">250</span>}
                logoImage<span class="hljs-operator">=</span><span class="hljs-string">"https://dweb.mypinata.cloud/ipfs/QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng"</span>
                logoWidth<span class="hljs-operator">=</span>{<span class="hljs-number">50</span>}
                logoHeight<span class="hljs-operator">=</span>{<span class="hljs-number">50</span>}
                logoPadding<span class="hljs-operator">=</span>{<span class="hljs-number">5</span>}
                logoPaddingStyle<span class="hljs-operator">=</span><span class="hljs-string">"square"</span>
                qrStyle<span class="hljs-operator">=</span><span class="hljs-string">"dots"</span>
                eyeRadius<span class="hljs-operator">=</span>{<span class="hljs-number">15</span>}
              <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>Link className<span class="hljs-operator">=</span><span class="hljs-string">"w-full"</span> href<span class="hljs-operator">=</span>{deepLink}<span class="hljs-operator">&gt;</span>
                <span class="hljs-operator">&lt;</span>Button className<span class="hljs-operator">=</span><span class="hljs-string">"w-full"</span><span class="hljs-operator">&gt;</span>Mobile Link<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Button<span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Link<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
          )}
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
      )}

      {signerId <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">&lt;</span>CastForm signerId<span class="hljs-operator">=</span>{signerId} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>}

      {<span class="hljs-operator">!</span>fid <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> <span class="hljs-operator">!</span>signerId <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> (
        <span class="hljs-operator">&lt;</span>SignInButton
          onSuccess<span class="hljs-operator">=</span>{handleSignInSuccess}
        <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      )}
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Now, there is a fair bit going on here, and it will probably be the biggest component in your app. But let’s break it down piece by piece. The app will do a few things. First, if there is no <strong>fid</strong> or <strong>signerId</strong> set, the user is going to get the <strong>SignInButton</strong> from <strong>auth-kit</strong> that will get their FID for us. Once we hasendinve the FID, we’ll set it and <strong>checkStorage</strong>. This function will first check if the user has any previous local storage keys we might have set previously, and if not, we’ll make an API request to <strong>/api/retrieveSigner</strong> with info provided from the <strong>onSuccess</strong> of the auth kit sign in, including the <strong>fid</strong>, <strong>signature</strong>, <strong>message</strong>, and <strong>nonce</strong>. These are all crucial to authenticate our Farcaster user before giving them access to a previously issued signer key. Before we look at some of our API routes, we’ll make a quick config file to make it easier to import and re-use the Pinata FDK.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">PinataFDK</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"pinata-fdk"</span>;

export const fdk <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> PinataFDK({
  pinata_jwt: process.env.PINATA_JWT <span class="hljs-keyword">as</span> <span class="hljs-keyword">string</span>,
  pinata_gateway: <span class="hljs-string">""</span>,
  app_fid: `${process.env.DEVELOPER_FID}`,
  app_mnemonic: `${process.env.DEVELOPER_MNEMONIC}`
});</code></pre><p>With that done, let’s look at <strong>/api/retrieveSigner</strong> to see how it’s being used there.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextResponse</span>, <span class="hljs-title">NextRequest</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">createAppClient</span>, <span class="hljs-title">viemConnector</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@farcaster/auth-client"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">fdk</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/config/fdk"</span>

<span class="hljs-title">const</span> <span class="hljs-title">appClient</span> <span class="hljs-operator">=</span> <span class="hljs-title">createAppClient</span>({
  <span class="hljs-title">relay</span>: <span class="hljs-string">"https://relay.farcaster.xyz"</span>,
  <span class="hljs-title">ethereum</span>: <span class="hljs-title">viemConnector</span>()
});


export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">POST</span>(<span class="hljs-params">request: NextRequest</span>) </span>{
  <span class="hljs-keyword">try</span> {
    const body <span class="hljs-operator">=</span> await request.json()
    console.log(body.message)
    const { success, fid, <span class="hljs-function"><span class="hljs-keyword">error</span>, <span class="hljs-title">isError</span> } = <span class="hljs-title">await</span> <span class="hljs-title">appClient</span>.<span class="hljs-title">verifySignInMessage</span>(<span class="hljs-params">{
      nonce: body.nonce,
      domain: <span class="hljs-string">"farcaster-lazy-client.vercel.app"</span>,
      message: body.message,
      signature: body.signature,
    }</span>)</span>;

    <span class="hljs-keyword">if</span>(isError){
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)
      <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-title">NextResponse</span>.<span class="hljs-title">json</span>(<span class="hljs-params"><span class="hljs-keyword">error</span></span>)</span>;
    }

    <span class="hljs-keyword">if</span> (success) {
      const res <span class="hljs-operator">=</span> await fdk.getSigners(fid);
      console.log(res);
      <span class="hljs-keyword">return</span> NextResponse.json(res);
    } <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> NextResponse.json(<span class="hljs-string">"Error verifying signature"</span>);
    }
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> NextResponse.json(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>In this API route, we use <strong>auth-client</strong> from Farcaster to create a new <strong>appClient</strong>. This can be used to <strong>verifySignInMessage</strong> with the info passed from the client. If it passes authentication, then we can fetch our previously issued signers from <strong>fdk.getSigners(fid)</strong> using the FID provided by the signature verification. This is such a great combo because it provides a secure way to let users sign in, get write access, and only have to issue one signer key for your app. Now that we have the key, we can send it back to the client, specifically in the <strong>checkStorage</strong> function.</p><pre data-type="codeBlock"><code>async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">checkStorage</span>(<span class="hljs-params">signature?: any, message?: any, nonce?: any</span>) </span>{
    <span class="hljs-keyword">try</span> {
      <span class="hljs-keyword">if</span> (typeof window <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-string">"undefined"</span>) {
        const signer <span class="hljs-operator">=</span> localStorage.getItem(<span class="hljs-string">"signer_id"</span>);
        <span class="hljs-keyword">if</span> (signer <span class="hljs-operator">!</span><span class="hljs-operator">=</span> null) {
          setSignerId(signer);
        } <span class="hljs-keyword">else</span> {
          const data <span class="hljs-operator">=</span> JSON.stringify({
            message: message,
            signature: signature,
            nonce: nonce,
          });
          const signerReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>retrieveSigner`, {
            method: <span class="hljs-string">"POST"</span>,
            headers: {
              <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
            },
            body: data,
          });
          const signerRes <span class="hljs-operator">=</span> await signerReq.json();
          <span class="hljs-keyword">if</span> (signerRes.signers <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> signerRes.signers.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>) {
            console.log(<span class="hljs-string">"signer found and set"</span>);
            setSignerId(signerRes.signers[<span class="hljs-number">0</span>].signer_uuid);
            localStorage.setItem(<span class="hljs-string">"signer_id"</span>, signerRes.signers[<span class="hljs-number">0</span>].signer_uuid);
          } <span class="hljs-keyword">else</span> {
            console.log(<span class="hljs-string">"no signer found"</span>);
            <span class="hljs-keyword">return</span>;
          }
        }
      }
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    }
  }</code></pre><p>If we do get a signer, then we can put it in local storage for easier access and create a session to be used by the user. This gives us a full loop which we can use when the app is first loaded to check that local storage and re-use that key!</p><p style="text-align: start">Now, if we don’t have any signers for a user, we can give them an option to create a user. This is done through the <strong>createSigner</strong> function.</p><pre data-type="codeBlock"><code>async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSigner</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">try</span> {
      const signerReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>signer`, {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
        },
      });
      const signerRes <span class="hljs-operator">=</span> await signerReq.json();
      setDeepLink(signerRes.deep_link_url);
      setOpenQR(<span class="hljs-literal">true</span>);

      const pollReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>poll?token<span class="hljs-operator">=</span>${signerRes.token}`);
      const pollRes <span class="hljs-operator">=</span> await pollReq.json();
      const pollStartTime <span class="hljs-operator">=</span> Date.now();
      <span class="hljs-keyword">while</span> (pollRes.state <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-string">"completed"</span>) {
        <span class="hljs-keyword">if</span> (Date.now() <span class="hljs-operator">-</span> pollStartTime <span class="hljs-operator">&gt;</span> <span class="hljs-number">120000</span>) {
          console.log(<span class="hljs-string">"Polling timeout reached"</span>);
          alert(<span class="hljs-string">"Request timed out"</span>);
          setOpenQR(<span class="hljs-literal">false</span>);
          <span class="hljs-keyword">break</span>;
        }
        const pollReq <span class="hljs-operator">=</span> await fetch(`<span class="hljs-operator">/</span>api<span class="hljs-operator">/</span>poll?token<span class="hljs-operator">=</span>${signerRes.token}`);
        const pollRes <span class="hljs-operator">=</span> await pollReq.json();
        <span class="hljs-keyword">if</span> (pollRes.state <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"completed"</span>) {
          setDeepLink(null);
          setOpenQR(<span class="hljs-literal">false</span>);
          setSignerId(signerRes.signer_id);
          localStorage.setItem(<span class="hljs-string">"signer_id"</span>, signerRes.signer_id);
          <span class="hljs-keyword">return</span> pollRes;
        }
        await <span class="hljs-keyword">new</span> Promise((resolve) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> setTimeout(resolve, <span class="hljs-number">2000</span>));
      }
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    }
  }</code></pre><p>First, it’s going to make a request to <strong>/api/signer</strong> to make a new signer key via Farcaster Auth, and the code there is very simple.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextResponse</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">fdk</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/config/fdk"</span>;

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">POST</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">try</span> {
    const res <span class="hljs-operator">=</span> await fdk.createSponsoredSigner();
    <span class="hljs-keyword">return</span> NextResponse.json(res);
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> NextResponse.json(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>Once it sends a response, it’s going to give us three important pieces:</p><ul><li><p>A <strong>signer_id</strong> that we will use later as the key to access writes for our users</p></li><li><p>A <strong>deep_link_url</strong> that will be used for the user to approve the key</p></li><li><p>A <strong>token</strong> that will act as the polling token to see if/when the user approves the key.</p></li></ul><p style="text-align: start">With the QR code set, and provided to the user, we can start hitting <strong>/api/poll</strong> with our token, which again the FDK makes this a breeze.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextResponse</span>, <span class="hljs-title">NextRequest</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">fdk</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/config/fdk"</span>;

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">GET</span>(<span class="hljs-params">request: NextRequest</span>) </span>{
  const searchParams <span class="hljs-operator">=</span> request.nextUrl.searchParams;
  <span class="hljs-keyword">try</span> {
    const token: any <span class="hljs-operator">=</span> searchParams.get(<span class="hljs-string">"token"</span>);
    const res <span class="hljs-operator">=</span> await fdk.pollSigner(token);
    console.log(res);
    <span class="hljs-keyword">return</span> NextResponse.json(res);
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> NextResponse.json(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>The results of this call will tell us the status of the poll, with which we’ll begin a temporary loop for 120 seconds, checking every 2 seconds if the user has scanned the QR code and approved the signer in Warpcast. If they do approve, then we’ll set the <strong>signerId</strong> state with the previously derived <strong>signer_id</strong> and we’ll write it to local storage. If not approved, we’ll show an error message that they need to try again.</p><p style="text-align: start">That completes our auth, providing a secure and reliable way for Farcaster apps to create and fetch existing signers. Again, the beauty here is that Pinata is managing those signers. The developer has the choice to use sponsored signers so that the end user doesn’t have to pay warps, and with the ability to authenticate a previous user and fetch their signer ID, a user really only needs one. No need to worry about keys getting lost in local storage or risking handling private keys in your own database. With that said, what good is a signer if you can’t send a cast? Let’s do that next.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-sending-casts"><strong>Sending Casts</strong></h2></div><p style="text-align: start">With our <strong>signerId</strong> ready to rock and roll, let's take a quick peer at the submit function in our form component.</p><pre data-type="codeBlock"><code>async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onSubmit</span>(<span class="hljs-params">values: z.infer&lt;typeof formSchema&gt;</span>) </span>{
    <span class="hljs-keyword">try</span> {
      setLoading(<span class="hljs-literal">true</span>)
      const data <span class="hljs-operator">=</span> JSON.stringify({
        signerId: signerId,
        castMessage: values.cast,
      });
      const submitMessage <span class="hljs-operator">=</span> await fetch(<span class="hljs-string">"/api/cast"</span>, {
        method: <span class="hljs-string">"POST"</span>,
        headers: {
          contentType: <span class="hljs-string">"application/json"</span>,
        },
        body: data,
      });
      const messageJson <span class="hljs-operator">=</span> await submitMessage.json();
      console.log(messageJson);
      setLoading(<span class="hljs-literal">false</span>);
      <span class="hljs-keyword">if</span>(<span class="hljs-operator">!</span>submitMessage.ok){
        alert(<span class="hljs-string">"Error sending cast"</span>);
        <span class="hljs-keyword">return</span>
      }
      setCastComplete(<span class="hljs-literal">true</span>);
    } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
      console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
      alert(<span class="hljs-string">"Error sending cast"</span>);
      setLoading(<span class="hljs-literal">false</span>);
    }
  }</code></pre><p>Sending a cast with the FDK really doesn’t get much easier, as we simply build what we want our cast to look like and send it over an API route. In this example, we’re just doing text posts, but depending how you want to build your casts with quotes, mentions, or media, you can absolutely do that here too. For now, we’ll just use our <strong>signerId</strong> and our <strong>castMessage</strong> from our form input, then send it to <strong>/api/cast</strong>.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">NextResponse</span>, <span class="hljs-title">NextRequest</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"next/server"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">fdk</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/config/fdk"</span>

<span class="hljs-title">export</span> <span class="hljs-title">async</span> <span class="hljs-title"><span class="hljs-keyword">function</span></span> <span class="hljs-title">POST</span>(<span class="hljs-title">request</span>: <span class="hljs-title">NextRequest</span>) {
  <span class="hljs-title"><span class="hljs-keyword">try</span></span> {
    <span class="hljs-title">const</span> <span class="hljs-title">body</span> <span class="hljs-operator">=</span> <span class="hljs-title">await</span> <span class="hljs-title">request</span>.<span class="hljs-title">json</span>();
    const message <span class="hljs-operator">=</span> body.castMessage;
    console.log(body)

    const res <span class="hljs-operator">=</span> await fdk.sendCast({
      castAddBody: {
        text: message,
        parentUrl: <span class="hljs-string">"https://warpcast.com/~/channel/pinata"</span>
      },
      signerId: body.signerId,
    });
    <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>res.hash) {
      <span class="hljs-keyword">return</span> NextResponse.json(
        { <span class="hljs-built_in">Error</span>: <span class="hljs-string">"Failed to send cast"</span> },
        { status: <span class="hljs-number">500</span> },
      );
    } <span class="hljs-keyword">else</span> {
      const hash <span class="hljs-operator">=</span> res.hash
      <span class="hljs-keyword">return</span> NextResponse.json({ hash }, { status: <span class="hljs-number">200</span> });
    }
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> NextResponse.json(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
  }
}</code></pre><p>The API route is just as simple, where we parse the body and use <strong>fdk.sendCast</strong> with the structure of our cast and the <strong>signerId</strong>. Here, we just default to sending the cast to the <strong>/pinata</strong> channel, but we could make this something the user specifies if we wanted to. Then we just check if a hash is returned, and if so, then we send a success back to the client. Piece of cake! Now that the cast is sent, we want to be able to see it, so let’s build a feed.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-building-a-feed"><strong>Building a Feed</strong></h2></div><p style="text-align: start">The Farcaster API makes it seamless to build a feed of posts, allowing speed and flexibility. Let’s take a look at this example feed component.</p><pre data-type="codeBlock"><code><span class="hljs-keyword">import</span> { <span class="hljs-title">Avatar</span>, <span class="hljs-title">AvatarImage</span>, <span class="hljs-title">AvatarFallback</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/components/ui/avatar"</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Embed</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"@/components/embed"</span>;

export const dynamic <span class="hljs-operator">=</span> <span class="hljs-string">'force-dynamic'</span>

async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">cronFeed</span>(<span class="hljs-params">channel: any, pageSize: any</span>) </span>{
  <span class="hljs-keyword">try</span> {
    const result <span class="hljs-operator">=</span> await fetch(
      `https:<span class="hljs-comment">//api.pinata.cloud/v3/farcaster/casts?channel=${channel}&amp;pageSize=${pageSize}`,</span>
      {
        next: { revalidate: <span class="hljs-number">60</span> },
        method: <span class="hljs-string">"GET"</span>,
        headers: {
          Authorization: `Bearer ${process.env.PINATA_JWT}`,
        },
      },
    );
    <span class="hljs-keyword">if</span> (<span class="hljs-operator">!</span>result.ok) {
      <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"failed to fetch data"</span>);
    }
    const resultData <span class="hljs-operator">=</span> await result.json();
    <span class="hljs-keyword">return</span> resultData;
  } <span class="hljs-keyword">catch</span> (<span class="hljs-function"><span class="hljs-keyword">error</span>) </span>{
    console.log(<span class="hljs-function"><span class="hljs-keyword">error</span>)</span>;
    <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">error</span></span>;
  }
}

export async <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Feed</span>(<span class="hljs-params"></span>) </span>{
  const feed <span class="hljs-operator">=</span> await cronFeed(<span class="hljs-string">"diet-coke"</span>, <span class="hljs-number">50</span>);

  <span class="hljs-keyword">return</span> (
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">&gt;</span>
      {feed.casts.map((cast: any) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> (
        <span class="hljs-operator">&lt;</span>div
          className<span class="hljs-operator">=</span><span class="hljs-string">"flex gap-4 sm:w-[500px] w-[350px] flex-row items-start"</span>
          key<span class="hljs-operator">=</span>{cast.hash}
        <span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>Avatar<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>AvatarImage src<span class="hljs-operator">=</span>{cast.author.pfp_url} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>AvatarFallback<span class="hljs-operator">&gt;</span>CN<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>AvatarFallback<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>Avatar<span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex flex-col items-start w-full"</span><span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>div className<span class="hljs-operator">=</span><span class="hljs-string">"flex gap-2"</span><span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>p className<span class="hljs-operator">=</span><span class="hljs-string">"font-bold"</span><span class="hljs-operator">&gt;</span>{cast.author.display_name}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
              <span class="hljs-operator">&lt;</span>p className<span class="hljs-operator">=</span><span class="hljs-string">"text-gray-600"</span><span class="hljs-operator">&gt;</span>@{cast.author.username}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span>p className<span class="hljs-operator">=</span><span class="hljs-string">"pb-2"</span><span class="hljs-operator">&gt;</span>{cast.text.replace(<span class="hljs-operator">/</span>https?:\<span class="hljs-operator">/</span>\<span class="hljs-operator">/</span>\S<span class="hljs-operator">+</span><span class="hljs-operator">/</span>i, <span class="hljs-string">''</span>)}<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
            {cast.embeds <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
              cast.embeds.<span class="hljs-built_in">length</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span> ? (
              <span class="hljs-operator">&lt;</span>Embed embedObject<span class="hljs-operator">=</span>{cast.embeds[<span class="hljs-number">0</span>]} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
            ) : null}
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>div<span class="hljs-operator">&gt;</span>
      ))}
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
  );
}</code></pre><p>Since we’re using Next.js with App router, we’ve made this a server component to fetch the feed, then display it. Inside <strong>cronFeed</strong> we have an API call that gets casts from a specified channel, and how many posts we want returned. Thanks to our query params <strong>&amp;topLevel=true&amp;reverse=true</strong> we will only get the latest posts and the top level posts (instead of posts and the replies). Then, we just map over those casts with some nice styles and a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/PinataCloud/farcaster-lazy-client/blob/main/components/embed.tsx"><strong><u>special Embed component</u></strong></a> that can handle links, images, or other media.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-wrapping-up"><strong>Wrapping Up</strong></h2></div><p style="text-align: start">In the end, we have a client for the “lazy” developer, but what we really mean is the “speedy” developer. All of these tools are designed to handle the hardest parts of building a client and making them easy so that you can excel at building the special aspects of your client, whether that be a media focused client or a channel specific one. To see this client in action, visit the app <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://diet-cast.vercel.app/"><strong><u>here</u></strong></a>, and feel free to browse the code for it <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/PinataCloud/diet-cast"><strong><u>here</u></strong></a>. Our goal is to make Farcaster easy, but also scale as it grows into a flourishing, sufficiently decentralized, social media.</p><p style="text-align: start">Happy Casting!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Pinata)</author>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/647a6757b2c405043ce074699f73668a.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Announcing Crypto Payments]]></title>
            <link>https://paragraph.com/@pinatacloud/announcing-crypto-payments</link>
            <guid>tuS91WDYL4xnIqK2mFjW</guid>
            <pubDate>Tue, 23 Apr 2024 21:39:44 GMT</pubDate>
            <description><![CDATA[Pinata now supports beta crypto payments for annual plans!]]></description>
            <content:encoded><![CDATA[<p>We’re always working to give developers the flexibility and convenience they need. To stay in tune with their needs, we’re constantly gathering feedback from our customers and other builders utilizing IPFS. We’ve learned that some developers are increasingly interested in the option to pay for their Pinata plan upfront with crypto. While we’d love to support this, we know that many customers may still prefer to use credits cards, so with that, we’re thrilled to announce the beta release of crypto payment support. As this is beta, expect some bumps along the way as we refine and improve the experience.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-the-need-to-knows"><strong>The Need-To-Knows</strong></h2></div><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-annual-plans"><strong>Annual Plans</strong></h3></div><p style="text-align: start">Should you choose to pay for your Pinata plan using crypto, you’ll see that there is no longer a monthly subscription option. All plans paid for via crypto will be an upfront, annual plan.</p><p style="text-align: start">Plans paid for with credit card will still remain on a monthly subscription basis.</p><div class="relative header-and-anchor"><h3 style="text-align: start" id="h-handling-overages"><strong>Handling Overages</strong></h3></div><p style="text-align: start">Once you’ve selected to pay with crypto, you’ll pay for the base plan upfront via a quick and intuitive checkout flow. You’ll then handle overages separately on a monthly basis that will be billed to your account. In this initial version, overages will be paid via credit card still. So when you complete the crypto payment flow, you’ll need to add a credit card just in case you have any overages.</p><p style="text-align: start">We’re excited to introduce this annual pay with crypto option - a beginning step towards maximum payment flexibility for our customers.</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/121f7c649b1800dd0f529cc0c2548224.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Introducing Analytics]]></title>
            <link>https://paragraph.com/@pinatacloud/introducing-analytics</link>
            <guid>QZVhHtClWTPTIBTUqw3c</guid>
            <pubDate>Mon, 22 Apr 2024 15:56:35 GMT</pubDate>
            <description><![CDATA[Introducing Pinata Analytics: revolutionizing IPFS with detailed engagement and bandwidth insights.]]></description>
            <content:encoded><![CDATA[<p>We communicate with our customers daily, receiving feedback and feature requests that range from the obvious to the unexpected. One piece of feedback that was obvious, but difficult to pull off technically, was usage analytics. Today, we’ve surmounted that technical challenge and are excited to announce Pinata Analytics!</p><p style="text-align: start">Our mission is to empower developers in effortlessly building and scaling businesses with IPFS. With Pinata Analytics, we’re taking a significant step forward in providing comprehensive insights into the content that you upload and retrieve from Pinata. Prior to this release, extracting detailed usage and engagement data was challenging, leaving developers to navigate their IPFS journeys without clear visibility. Now, armed with detailed analytics on requests and bandwidth, developers can make informed decisions to drive their businesses forward.</p><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-enhanced-insights"><strong>Enhanced Insights</strong></h2></div><p style="text-align: start">In the new Pinata Analytics tab, you’ll discover:</p><ol><li><p><strong>Streamlined Usage Metrics:</strong> We've migrated usage metrics from the billing page to the Analytics tab for improved accessibility and clarity.</p></li><li><p><strong>Detailed Request Engagement and Bandwidth Analysis:</strong> Gain comprehensive insights into request traffic and bandwidth data, categorized by day, country, file, and device. This includes analysis of top operating systems, browsers, and referrers to understand user interactions better.</p></li><li><p><strong>Versatile Viewing Periods:</strong> Both requests and bandwidth analytics tabs offer viewing periods based on the current billing cycle, the previous cycle, as well as insights from the past 30 and 90 days.</p></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/76a1fdb6891b9b51732711e89da7b56e.png" class="image-node embed"><figcaption htmlattributes="[object Object]" class="">Screenshot of a Traffic by day Dashboard by countries</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/d3851fea477a4e6baef910bea230f7d4.png" class="image-node embed"><figcaption htmlattributes="[object Object]" class="">Screenshot of Bandwidth by day Dashboard by countries</figcaption></figure><div class="relative header-and-anchor"><h2 style="text-align: start" id="h-the-data-details"><strong>The Data Details</strong></h2></div><p style="text-align: start">Pinata Analytics is a feature exclusive to the Fiesta Plan. While all Pinata Plans will still continue to have access to the Usage section, only Fiesta Plan users can leverage the full potential of Pinata Analytics. If you’re currently on the Free or Picnic plan, consider upgrading to Fiesta to unlock these powerful insights. We can’t wait for you to experience Pinata Analytics firsthand!</p><p style="text-align: start">Happy Pinning!</p>]]></content:encoded>
            <author>pinatacloud@newsletter.paragraph.com (Lindsey)</author>
            <enclosure url="https://img.paragraph.com/cdn-cgi/image/format=auto/https://storage.googleapis.com/papyrus_images/3b83db56781a87bd3b3748c4fa8b41f1.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>