<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TechTom]]></title><description><![CDATA[Posts about technology by Tom]]></description><link>https://rtomas.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 09:48:14 GMT</lastBuildDate><atom:link href="https://rtomas.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Redefining payments through Reown and Direct Binance Integration]]></title><description><![CDATA[“Pay with Exchange” is a payment flow that enables users to pay in crypto directly from their CEX accounts (e.g. Binance), without needing to first…]]></description><link>https://rtomas.hashnode.dev/redefining-payments-through-reown-and-direct-b</link><guid isPermaLink="true">https://rtomas.hashnode.dev/redefining-payments-through-reown-and-direct-b</guid><category><![CDATA[reown]]></category><category><![CDATA[payments]]></category><category><![CDATA[crypto]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[binance]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Tue, 21 Oct 2025 00:58:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1761008193706/89e017d8-2c44-4f91-972d-59d9860fcfd6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>In the Web3 payments space, reducing friction is critical. Traditional flows force users to move funds from exchanges into self-custodial wallets—adding extra steps, risk, and drop-off. What if users could pay <em>directly</em> from their exchange accounts (like Binance) — no intermediate wallet, no copying addresses?</p>
<p>That’s exactly what <strong>Pay with Exchange</strong> enables. This feature, part of Reown, lets users transact straight from their centralized exchange (CEX) accounts, with minimal friction and maximum security.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/OETuoZ7dz9Q">https://youtu.be/OETuoZ7dz9Q</a></div>
<p> </p>
<h2 id="heading-what-is-pay-with-exchange">What Is “Pay with Exchange”?</h2>
<p>“Pay with Exchange” is a payment flow that enables users to pay in crypto directly from their CEX accounts (e.g. Binance), without needing to first withdraw funds to a separate wallet.</p>
<p>It’s part of Reown’s Payments offering and is bundled alongside the traditional “Pay with Self-Custodial Wallets” or extension wallet flow.</p>
<p>In essence:</p>
<ul>
<li><p>The user remains inside their exchange UI (or is redirected there)</p>
</li>
<li><p>They authorize a withdrawal from their exchange to the merchant’s address</p>
</li>
<li><p>The merchant (or payment system) receives the funds on-chain</p>
</li>
<li><p>The system reconciles the payment just like any other on-chain transaction</p>
</li>
</ul>
<h2 id="heading-key-advantages-why-use-pay-with-exchange">Key Advantages (Why Use Pay with Exchange)</h2>
<p>This section highlights the core benefits.</p>
<h3 id="heading-1-reduced-friction-higher-conversion">1. <strong>Reduced Friction → Higher Conversion</strong></h3>
<p>One of the biggest causes of abandonment in crypto payments is the step where users must move funds from exchanges to wallets. “Pay with Exchange” eliminates that intermediate step. Fewer clicks, fewer context switches, fewer points of failure.</p>
<h3 id="heading-2-access-where-assets-actually-live">2. <strong>Access Where Assets Actually Live</strong></h3>
<p>Statistics show that a large share of crypto holders keep their assets in centralized exchanges. Reown claims <strong>~72% of crypto users hold funds in exchanges</strong>. Offering “Pay with Exchange” taps into that supply directly.</p>
<h3 id="heading-3-no-wallet-setup-required">3. <strong>No Wallet Setup Required</strong></h3>
<p>For users unfamiliar or uncomfortable with self-custodial wallets, “Pay with Exchange” offers a more approachable path. They don’t need to install, manage keys, or deal with wallet UX.</p>
<h3 id="heading-4-security-amp-trust">4. <strong>Security &amp; Trust</strong></h3>
<ul>
<li><p>The merchant / app never handles user credentials or private keys.</p>
</li>
<li><p>Users transact within the trusted exchange interface — which they are already comfortable with</p>
</li>
<li><p>The underlying on-chain settlement means transparency, irrevocability, and auditability</p>
</li>
</ul>
<h3 id="heading-5-seamless-fallbacks-amp-flow-flexibility">5. <strong>Seamless Fallbacks &amp; Flow Flexibility</strong></h3>
<p>If the exchange balance is insufficient, the flow can present an on-ramp (buy crypto) at that moment, keeping the user in a smooth journey.</p>
<p>You can also combine “Pay with Exchange” and “Pay with Wallets” under one integration, letting the user choose the best option.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>“Pay with Exchange” bridges the gap between centralized exchanges and on-chain payments, making crypto transactions faster, simpler, and more accessible. By removing wallet setup friction and meeting users where their funds already are, it drives higher conversions and trust. With Reown’s Pay, businesses can now offer a seamless Web3 payment experience — one that feels as effortless as traditional online payments, but powered by crypto.</p>
<h2 id="heading-feedback"><strong>Feedback</strong></h2>
<p>You can share your feedback in our <a target="_blank" href="https://discord.gg/reown">Discord</a> or raise a ticket in our <a target="_blank" href="https://github.com/reown-com/appkit/issues">GitHub Repository</a></p>
<h2 id="heading-reference">Reference</h2>
<ul>
<li><p>Reown Pay with Exchange | <a target="_blank" href="https://reown.com/solutions/payments">https://reown.com/solutions/payments</a></p>
</li>
<li><p>Docs | <a target="_blank" href="https://docs.reown.com/appkit/payments/overview">https://docs.reown.com/appkit/payments/overview</a></p>
</li>
<li><p>Github Example | <a target="_blank" href="https://github.com/reown-com/appkit-web-examples/tree/main/react/react-wagmi-appkit-pay">https://github.com/reown-com/appkit-web-examples/tree/main/react/react-wagmi-appkit-pay</a></p>
</li>
<li><p>Demo | <a target="_blank" href="https://appkit-pay-ecommerce-demo.reown.com/checkout">https://appkit-pay-ecommerce-demo.reown.com/checkout</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Universal Connector to use WalletConnect QR Code]]></title><description><![CDATA[Guide on how to use Reown AppKit to implement WalletConnect QR code.]]></description><link>https://rtomas.hashnode.dev/universal-connector-to-use-walletconnect-qr-code</link><guid isPermaLink="true">https://rtomas.hashnode.dev/universal-connector-to-use-walletconnect-qr-code</guid><category><![CDATA[reown]]></category><category><![CDATA[walletconnect]]></category><category><![CDATA[appkit]]></category><category><![CDATA[Qrcode]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Tue, 30 Sep 2025 19:06:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1759259120717/a8798f76-4ca8-4b7e-b496-7982799aa4e8.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you are planning to build a dApp that connects client wallets using <code>WalletConnect QR</code> in a chain-agnostic environment, the best way is to use our Universal Connector, which simplifies the integration process, provides flexibility across multiple networks, and ensures a consistent user experience.</p>
<p>In this guide, you will learn how to:</p>
<ul>
<li><p>Use Universal Connector to connect a wallet using WalletConnect QR Code</p>
</li>
<li><p>Configure supported networks for your dApp</p>
</li>
<li><p>Manage session state for connected wallets</p>
</li>
</ul>
<p><img src="http://localhost:3001/images/walletconnectQR.jpg" alt="WalletConnect QR Code" class="image--center mx-auto" /></p>
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<ul>
<li><p>A fundamental understanding of JavaScript and React.</p>
</li>
<li><p>Obtain a new project Id on Reown Dashboard at <a target="_blank" href="https://dashboard.reown.com/"><strong>https://dashboard.reown.com</strong></a></p>
</li>
</ul>
<h2 id="heading-final-project"><strong>Final project</strong></h2>
<p>Download the full project to try it directly on your computer using <code>Universal Connector</code>.<br /><a target="_blank" href="https://github.com/reown-com/appkit-web-examples/tree/main/react/react-core-universal-connector">https://github.com/reown-com/appkit-web-examples/tree/main/react/react-core-universal-connector</a></p>
<p>Also you can try the demo online : <a target="_blank" href="https://react-core-universal-connector.vercel.app/">https://react-core-universal-connector.vercel.app/</a></p>
<h2 id="heading-final-project-1"><strong>Final project</strong></h2>
<p>In order to set up the project, you need to install the following packages:</p>
<p><code>pnpm add @reown/appkit @reown/appkit-universal-connector @reown/appkit-common</code></p>
<p>or</p>
<p><code>npm install @reown/appkit @reown/appkit-universal-connector @reown/appkit-common</code></p>
<h2 id="heading-start-building-with-universal-connector"><strong>Start building with Universal Connector</strong></h2>
<p>You can configure with the networks you want to support. For more information, please visit <a target="_blank" href="https://docs.reown.com/advanced/multichain/rpc-reference/cosmos-rpc"><strong>RPC Reference</strong></a> <a target="_blank" href="https://docs.reown.com/advanced/multichain/rpc-reference/cosmos-rpc">section from</a> our docs. We recommend creating a <strong>config file</strong> to establish a singleton instance for the <code>Universal Connector</code>.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { AppKitNetwork } <span class="hljs-keyword">from</span> <span class="hljs-string">'@reown/appkit/networks'</span>
<span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { CustomCaipNetwork } <span class="hljs-keyword">from</span> <span class="hljs-string">'@reown/appkit-common'</span>
<span class="hljs-keyword">import</span> { UniversalConnector } <span class="hljs-keyword">from</span> <span class="hljs-string">'@reown/appkit-universal-connector'</span>

<span class="hljs-comment">// Get projectId from https://dashboard.reown.com</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> projectId = <span class="hljs-keyword">import</span>.meta.env.VITE_PROJECT_ID || <span class="hljs-string">"b56e18d47c72ab683b10814fe9495694"</span> <span class="hljs-comment">// this is a public projectId only to use on localhost</span>

<span class="hljs-keyword">if</span> (!projectId) {
  <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'Project ID is not defined'</span>)
}

<span class="hljs-comment">// Example: configure Sui mainnet</span>
<span class="hljs-keyword">const</span> suiMainnet: CustomCaipNetwork&lt;<span class="hljs-string">'sui'</span>&gt; = {
  id: <span class="hljs-number">784</span>,
  chainNamespace: <span class="hljs-string">'sui'</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">const</span>,
  caipNetworkId: <span class="hljs-string">'sui:mainnet'</span>,
  name: <span class="hljs-string">'Sui'</span>,
  nativeCurrency: { name: <span class="hljs-string">'SUI'</span>, symbol: <span class="hljs-string">'SUI'</span>, decimals: <span class="hljs-number">9</span> },
  rpcUrls: { <span class="hljs-keyword">default</span>: { http: [<span class="hljs-string">'https://fullnode.mainnet.sui.io:443'</span>] } }
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getUniversalConnector</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> universalConnector = <span class="hljs-keyword">await</span> UniversalConnector.init({
    projectId,
    metadata: {
      name: <span class="hljs-string">'Universal Connector'</span>,
      description: <span class="hljs-string">'Universal Connector'</span>,
      url: <span class="hljs-string">'https://appkit.reown.com'</span>,
      icons: [<span class="hljs-string">'https://appkit.reown.com/icon.png'</span>]
    },
    networks: [
      {
        methods: [<span class="hljs-string">'sui_signPersonalMessage'</span>],
        chains: [suiMainnet <span class="hljs-keyword">as</span> CustomCaipNetwork],
        events: [],
        <span class="hljs-keyword">namespace</span>: <span class="hljs-string">'sui'</span>
      }
    ]
  })

  <span class="hljs-keyword">return</span> universalConnector
}
</code></pre>
<p>As you can see, we are importing the <code>UniversalConnector</code> class from the <code>@reown/appkit-universal-connector</code> package. Then you can use the projectId that you can get from the <a target="_blank" href="https://dashboard.reown.com/"><strong>Reown Dashboard</strong></a>.</p>
<p>After that you can configure the networks you want to support. The method <code>init</code> receives the projectId, the metadata and the networks you want to support.</p>
<p>In the <code>App.tsx</code> file you can add :</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { useState, useEffect } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>
<span class="hljs-keyword">import</span> { getUniversalConnector } <span class="hljs-keyword">from</span> <span class="hljs-string">'./config'</span> <span class="hljs-comment">// previous config file</span>
<span class="hljs-keyword">import</span> { UniversalConnector } <span class="hljs-keyword">from</span> <span class="hljs-string">'@reown/appkit-universal-connector'</span>

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [universalConnector, setUniversalConnector] = useState&lt;UniversalConnector&gt;()
  <span class="hljs-keyword">const</span> [session, setSession] = useState&lt;<span class="hljs-built_in">any</span>&gt;()


  <span class="hljs-comment">// Initialize the Universal Connector on component mount</span>
  useEffect(<span class="hljs-function">() =&gt;</span> {
    getUniversalConnector().then(setUniversalConnector)
  }, [])

  <span class="hljs-comment">// Set the session state in case it changes</span>
  useEffect(<span class="hljs-function">() =&gt;</span> {
    setSession(universalConnector?.provider.session)
  }, [universalConnector?.provider.session])
</code></pre>
<p>This ensures the Universal Connector is initialized when the component mounts. The session state updates whenever the connected wallet session changes. With this setup, you’re now ready to build wallet connections in a chain-agnostic way using WalletConnect QR codes.</p>
<h2 id="heading-connect-a-wallet"><strong>Connect a Wallet</strong></h2>
<p>The following function initializes the connection and stores the session:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> handleConnect = <span class="hljs-keyword">async</span> () =&gt; {
    <span class="hljs-keyword">if</span> (!universalConnector) {
        <span class="hljs-keyword">return</span>
    }

    <span class="hljs-keyword">const</span> { session: providerSession } = <span class="hljs-keyword">await</span> universalConnector.connect();
    setSession(providerSession);
};
</code></pre>
<p>Once the wallet is connected, the session information (such as accounts and namespaces) will be available in your app. You can then use this session to perform actions like signing messages or sending transactions.</p>
<h2 id="heading-sign-a-message"><strong>Sign a Message</strong></h2>
<p>Once your wallet is connected, you can also use the Universal Connector to sign messages. This is useful for authentication or verifying ownership of an address.</p>
<p>Here’s an example of how to sign a personal message on Sui:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Function to sign a message on Sui</span>
<span class="hljs-keyword">const</span> handleSignSUIMsg = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">if</span> (!universalConnector) {
    <span class="hljs-keyword">return</span>
  }

  <span class="hljs-keyword">const</span> message = <span class="hljs-string">"Hello Reown AppKit!"</span> <span class="hljs-comment">// message to sign</span>
  <span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">const</span> account = session?.namespaces[<span class="hljs-string">'sui'</span>]?.accounts[<span class="hljs-number">0</span>]
    <span class="hljs-keyword">if</span> (!account) {
      <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'No account found'</span>)
    }

    <span class="hljs-keyword">const</span> result = <span class="hljs-keyword">await</span> universalConnector.request(
      {
        method: <span class="hljs-string">'sui_signPersonalMessage'</span>,
        params: [message]
      },
      <span class="hljs-string">'sui:mainnet'</span>
    )
    <span class="hljs-comment">// eslint-disable-next-line no-console</span>
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'&gt;&gt; Sui Sign Message result'</span>, result)
  } <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-comment">// eslint-disable-next-line no-console</span>
    <span class="hljs-built_in">console</span>.error(<span class="hljs-string">'&gt;&gt; Sui Sign Message error'</span>, error)
  }
}
</code></pre>
<p>You can trigger this function with a simple button:</p>
<pre><code class="lang-typescript">&lt;button onClick={handleSignSUIMsg}&gt;
  Sign Message
&lt;/button&gt;
</code></pre>
<p>This will prompt the connected wallet to sign the message “Hello Reown AppKit!” and log the result in the console.</p>
<h2 id="heading-disconnect-a-wallet"><strong>Disconnect a Wallet</strong></h2>
<p>It’s important to give users the option to disconnect their wallet from your dApp. This clears the active session and ensures the wallet is no longer linked until the user chooses to reconnect.</p>
<p>Here’s a simple function to handle disconnection:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> handleDisconnect = <span class="hljs-keyword">async</span> () =&gt; {
  <span class="hljs-keyword">if</span> (!universalConnector) {
    <span class="hljs-keyword">return</span>
  }
  <span class="hljs-keyword">await</span> universalConnector.disconnect()
  setSession(<span class="hljs-literal">null</span>)
}
</code></pre>
<p>When called, this will terminate the session and reset the state in your app. You can bind it to a “Disconnect” button in your UI to make it accessible to users.</p>
]]></content:encoded></item><item><title><![CDATA[Best JS library to use with Web3auth: Viem, ethers or web3.js]]></title><description><![CDATA[In the rapidly evolving world of web development and blockchain technology, choosing the right JavaScript library is crucial for building efficient and…]]></description><link>https://rtomas.hashnode.dev/best-js-library-to-use-with-web3auth-viem-ethers-or-web3js</link><guid isPermaLink="true">https://rtomas.hashnode.dev/best-js-library-to-use-with-web3auth-viem-ethers-or-web3js</guid><category><![CDATA[library]]></category><category><![CDATA[Web3]]></category><category><![CDATA[web3.js]]></category><category><![CDATA[viem]]></category><category><![CDATA[ethers]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Thu, 23 May 2024 01:28:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1715951832100/09eadd95-9cc6-4b51-aefd-1e31309937f8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the rapidly evolving world of web development and blockchain technology, choosing the right JavaScript library is crucial for building efficient and secure applications. With the integration of blockchain functionalities becoming more prevalent, libraries like Viem, Web3.js, and Ethers have become essential tools for developers. This article explores these libraries in the context of Web3Auth, a decentralized authentication platform that leverages the blockchain for secure user authentication without compromising privacy.</p>
<p><img src="https://lh7-us.googleusercontent.com/G9tg3uZOt0d_nfdRRFx3MJcpaGsZnrr4A3IP9rnLb-p0H1cNvJx9w1QO0aXrzP6hgtGQwK5NYSLsyreCzfkSa_9LaXgtUxtnSRmxl0q7ZZzg4WAlpQznyY80-SeGaMNR5RUxBPgDDC3hUO1O9x76Kpc" alt /></p>
<p><img src="https://lh7-us.googleusercontent.com/VrHhE92w9XrfgWYhv9QmfRJxTtSxoDD8K3dvbJzYWcCcFOX_FcysBpKew0EMnThVU1TEclnAs9QG22w0WBKl3QXslQG5bnXz4gWyqz_Mayh8xXNCT2Be1s9ICWWrYcFoMDKmWZqE8VVFRUn6iYHOuuc" alt /></p>
<h2 id="heading-viem-a-rising-star-in-blockchain-integration">Viem: A rising star in blockchain integration</h2>
<p>Viem, although relatively new to the scene, is quickly making a name for itself among developers who prioritize smooth integration with different blockchains. Viem offers a robust framework that simplifies the process of building decentralized applications (dApps). Its architecture is tailored for high performance and is particularly beneficial for projects that require real-time data from the blockchain.</p>
<p>web: <a target="_blank" href="https://viem.sh/%EF%BF%BCGitub">https://viem.sh/<br />github</a>: <a target="_blank" href="https://github.com/wevm/viem%EF%BF%BCdocs">https://github.com/wevm/viem<br />docs</a>: <a target="_blank" href="https://viem.sh/docs/getting-started">https://viem.sh/docs/getting-started</a></p>
<h2 id="heading-web3js-the-veteran-player">Web3.js: The Veteran Player</h2>
<p>Web3.js has been the backbone of Ethereum-related web projects for many years. As a collection of libraries that allow you to interact with a local or remote Ethereum node using HTTP, IPC, or WebSocket, it provides the necessary tools to send transactions, interact with smart contracts, and access blockchain data. Its widespread adoption and support have made it a reliable choice for developers integrating Web3Auth. However, it's worth noting that despite its robust features and reliability, Viem has recently surpassed Web3.js in terms of downloads, indicating a shift in developer preferences.</p>
<p>web: <a target="_blank" href="https://web3js.org/%EF%BF%BCGithub">https://web3js.org/<br />github</a>: <a target="_blank" href="https://github.com/web3/web3.js%EF%BF%BCdocs">https://github.com/web3/web3.js<br />docs</a>: <a target="_blank" href="https://docs.web3js.org/">https://docs.web3js.org/</a></p>
<h2 id="heading-ethersjs-leading-the-pack">Ethers.js: Leading the pack</h2>
<p>Ethers.js is the most downloaded library among the three, signifying its widespread popularity and trust within the developer community. It is a compact and complete library designed to interact with the Ethereum Blockchain and its ecosystem. The library is renowned for its ease of use, comprehensive features, and fine-tuned control over blockchain operations. Ethers.js supports fully typed custom contracts and has a straightforward accessible API.</p>
<p>web: <a target="_blank" href="https://ethers.org/%EF%BF%BCGithub">https://ethers.org/<br />github</a>: <a target="_blank" href="https://github.com/ethers-io/ethers.js%EF%BF%BCdocs">https://github.com/ethers-io/ethers.js<br />docs</a>: <a target="_blank" href="https://docs.ethers.org/">https://docs.ethers.org/</a></p>
<h2 id="heading-comphttpsgithubcomethers-ioethersjsarison-and-considerationhttpsdocsethersorgs"><a target="_blank" href="https://github.com/ethers-io/ethers.js">Comp</a><a target="_blank" href="https://docs.ethers.org/">arison and Consideration</a>s</h2>
<p>When choosing a JavaScript library for Web3Auth integration, several factors need consideration:</p>
<ul>
<li><p>Popularity and Community Support: Ethers.js leads with the highest download numbers, suggesting a large community and continuous updates. But web3.js has a lot of stars on Github. So both communities are working great and having two big libraries is great for decentralization and not only depending on one.</p>
</li>
<li><p>Ease of Use: Ethers.js and Viem are praised for their user-friendly APIs, which are crucial for developers aiming for quick deployments and maintenance.</p>
</li>
<li><p>Feature Set: All three libraries offer comprehensive features, but Ethers.js often receives praise for its detailed and developer-friendly documentation and features.</p>
</li>
<li><p>Integration with Wagmi and Rainbowkit: Wagmi was built on top of Viem and Rainbowkit was built on top of Wagmi, so if you are going to choose any of these libraries. It would be an easy decision to go for Viem.</p>
</li>
</ul>
<h2 id="heading-code">Code</h2>
<p>Let’s make a simple comparison of how to get the public address:</p>
<h3 id="heading-ethers">Ethers</h3>
<ul>
<li><a target="_blank" href="https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-modal-sdk/blockchain-connection-examples/evm-modal-example/src/ethersRPC.ts">Full-example in web3auth using EVM</a><a target="_blank" href="https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-modal-sdk/blockchain-connection-examples/evm-modal-example/src/viem.ts">PnP Modal</a></li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { ethers } <span class="hljs-keyword">from</span> <span class="hljs-string">"ethers"</span>;
…
<span class="hljs-keyword">const</span> ethersProvider = <span class="hljs-keyword">new</span> ethers.BrowserProvider(<span class="hljs-built_in">this</span>.provider);
<span class="hljs-keyword">const</span> signer = <span class="hljs-keyword">await</span> ethersProvider.getSigner();

<span class="hljs-comment">// Get the user's Ethereum public address</span>
<span class="hljs-keyword">const</span> address = signer.getAddress();
</code></pre>
<h3 id="heading-web3js">web3.js</h3>
<ul>
<li><a target="_blank" href="https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-modal-sdk/blockchain-connection-examples/evm-modal-example/src/web3RPC.ts">Full-example in web3auth using EVM PnP Modal</a></li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Web3 <span class="hljs-keyword">from</span> <span class="hljs-string">"web3"</span>;
…
<span class="hljs-keyword">const</span> web3 = <span class="hljs-keyword">new</span> Web3(<span class="hljs-built_in">this</span>.provider);

<span class="hljs-comment">// Get the user's Ethereum public address</span>
<span class="hljs-keyword">const</span> address = <span class="hljs-keyword">await</span> web3.eth.getAccounts();
</code></pre>
<h3 id="heading-viem">Viem</h3>
<ul>
<li><a target="_blank" href="https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/web-modal-sdk/blockchain-connection-examples/evm-modal-example/src/viem.ts">Full-example in web3auth using EVM PnP Modal</a></li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { createWalletClient, custom} <span class="hljs-keyword">from</span> <span class="hljs-string">'viem'</span>
<span class="hljs-keyword">import</span> { mainnet } <span class="hljs-keyword">from</span> <span class="hljs-string">'viem/chains'</span>
…
<span class="hljs-keyword">const</span> walletClient = createWalletClient({
            <span class="hljs-attr">chain</span>: mainnet,
            <span class="hljs-attr">transport</span>: custom(<span class="hljs-built_in">this</span>.provider)
          });

<span class="hljs-keyword">const</span> address = <span class="hljs-keyword">await</span> walletClient.getAddresses();
</code></pre>
<h2 id="heading-how-to-implement-in-web3auth-pnp-sdk">How to implement in Web3auth PnP SDK</h2>
<p>In our EVM examples, you can choose which file you are going to use and decide the library to connect the blockchain. Comment and uncomment your preferred library and start using it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> RPC <span class="hljs-keyword">from</span> <span class="hljs-string">"./web3RPC"</span>; <span class="hljs-comment">// for using web3.js</span>
<span class="hljs-comment">//import RPC from "./ethersRPC"; // for using ethers.js</span>
<span class="hljs-comment">//import RPC from "./viemRPC"; // for using viem</span>
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, while Web3.js has been a staple in Ethereum development, Ethers.js currently leads in popularity and downloads, reflecting its robustness and developer trust. However, Viem, with its recent surge in downloads surpassing Web3.js, is proving to be a strong contender, especially for developers looking for libraries that integrate Wagmi. Each library has its strengths and specialties, and the choice largely depends on specific project requirements, developer familiarity, and the particular features needed for integration with Web3Auth.</p>
]]></content:encoded></item><item><title><![CDATA[The Bridge Between Web2 and Web3]]></title><description><![CDATA[Nowadays, big tech companies manage huge volumes of visitors that are very used to the username/password login style. These companies are using the same…]]></description><link>https://rtomas.hashnode.dev/the-bridge-between-web2-and-web3</link><guid isPermaLink="true">https://rtomas.hashnode.dev/the-bridge-between-web2-and-web3</guid><category><![CDATA[wallet]]></category><category><![CDATA[Web3]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Wed, 20 Mar 2024 16:08:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1710950801673/28ae057d-c288-407d-91a0-fc93dd03b541.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Nowadays, big tech companies manage huge volumes of visitors that are very used to the username/password login style. These companies are using the same vision to authenticate and most have chosen Auth0 to do it. It’s clear that companies prefer to outsource the authentication process and not to manage the security in-house.</p>
<p>The question I’m trying to open up is how these companies are going to introduce their users to web3 and whether they should do it or not.</p>
<p>If they don’t do it, probably a competitor would enter the game and try to take advantage. </p>
<p>The competitors could be:</p>
<ul>
<li><p>Building Efficient/attractive loyalty programs.</p>
</li>
<li><p>Building Micropayment between users</p>
</li>
<li><p>Sharing revenue from advertisement with users</p>
</li>
<li><p>Developing  any other process that we can’t yet imagine on top of a blockchain.</p>
</li>
</ul>
<p>Since the last implementation in Ethereum, some L2 have had a significantly low cost to make transfers, so right now the cost of gas for a transaction is almost irrelevant. We can affirm that this bull market is a great moment for some big fish to let their users dive into crypto.</p>
<h2 id="heading-simplifying-user-onboarding"><strong>Simplifying user onboarding</strong></h2>
<p>One of the first obstacles in the adoption of Web3 is user onboarding. The concept of digital wallets, private keys, and blockchain transactions can overwhelm even the most techie users. Simplifying this process by providing a familiar authentication experience is crucial. New users should use something more familiar to their existing social accounts. This makes it easier to start using Web3 apps and gets more people interested.</p>
<h3 id="heading-enhancing-security-without-sacrificing-usability"><strong>Enhancing security without sacrificing usability</strong></h3>
<p>Security is crucial in Web3, where users have more control over their data. Web3Auth uses advanced cryptographic techniques to ensure that users enjoy the ease of traditional logins, and their data and digital assets remain secure. This dual focus on security and usability addresses one of the biggest concerns for companies looking to make the leap to Web3: protecting their users without making the process uncomfortable.</p>
<h1 id="heading-streaming-platforms"><strong>Streaming platforms</strong></h1>
<p><img src="https://lh7-us.googleusercontent.com/KeettrB9-zDvmRsaJ4mTfXnwppWHvA-yz22tWf1sUFXPpejc_11x7pW10c7kj_3tANCebqPnC-gzTsPWVMwRbuUIFVoQe-DnwoEgajzVCBxtFVqNPvW8zIjaDBr6WOlRIg3FX06Z3PGrWLZOd6QDV94" alt /></p>
<h3 id="heading-the-revolutionary-move-paying-viewers-with-tokens"><strong>The Revolutionary Move: Paying Viewers with Tokens</strong></h3>
<p>Imagine a scenario where Netflix, or a similar platform, uses Web3Auth to create a seamless way for users to build their own digital wallet at login. Now add to this vision the innovative approach of rewarding users with Netflix's own token for watching movies and watching ads. This concept could fundamentally change the viewer’s experience and engagement in a number of ways.</p>
<h3 id="heading-increase-user-engagement-and-satisfaction"><strong>Increase user engagement and satisfaction</strong></h3>
<p>Rewarding users for the time they spend watching ads could dramatically increase engagement and satisfaction. The act of compensation transforms the experience from passive consumption to active participation. Users feel valued and directly benefit from their attention and engagement, fostering a more positive association with the platform and its advertising.</p>
<h3 id="heading-encouraging-a-community-driven-ecosystem"><strong>Encouraging a community-driven ecosystem</strong></h3>
<p>This model could also encourage the growth of a vibrant, community-driven ecosystem around the Netflix platform. Users could trade tokens, discuss the best ways to earn them, or even create content around them. This aspect could turn viewers into active participants and brand ambassadors, organically promoting the platform and its content.</p>
<h3 id="heading-addressing-ad-skepticism"><strong>Addressing Ad Skepticism</strong></h3>
<p>The introduction of ads on a platform previously free of them can lead to user skepticism and dissatisfaction. However, compensating users for watching ads could mitigate these negative perceptions. By offering a tangible reward, Netflix can ease the transition and highlight the value exchange.</p>
<h1 id="heading-social-networks"><strong>Social Networks</strong></h1>
<h3 id="heading-rewarding-creativity-and-engagement"><strong>Rewarding Creativity and Engagement</strong></h3>
<p>Social media platforms thrive on user-generated content and engagement. By introducing a token-based reward system, platforms can incentivise the creation of high-quality content and meaningful interactions. Users can earn tokens for creating popular content, engaging with posts, or even participating in community-driven events and challenges. This encourages a richer content ecosystem and rewards users for their contributions.</p>
<h3 id="heading-enhancing-user-retention-and-satisfaction"><strong>Enhancing User Retention and Satisfaction</strong></h3>
<p>The introduction of a reward system could significantly boost user retention and satisfaction. Knowing that their time and creativity are valued and directly rewarded, users are likely to feel more connected to the platform. This sense of ownership and participation can foster a more engaged and loyal community, which is crucial for the long-term success of any social media platform.</p>
<h3 id="heading-setting-a-new-standard-for-social-media-monetization"><strong>Setting a New Standard for Social Media Monetization</strong></h3>
<p>By rewarding users for their contributions, Twitter, Instagram, or TikTok can pioneer a new model of social media monetisation that benefits both the platform and its users. This approach challenges the traditional ad-revenue-centric models by diversifying revenue streams and distributing value more equitably among users. It also opens up new avenues for advertisers and brands to engage with the platform, possibly through the purchase of tokens or sponsorship of specific content and challenges.</p>
<h1 id="heading-chat-apps"><strong>Chat Apps</strong></h1>
<h3 id="heading-facilitating-microtransactions-and-peer-to-peer-payments"><strong>Facilitating microtransactions and Peer-to-Peer payments</strong></h3>
<p>The introduction of decentralised wallets opens up several possibilities for microtransactions and peer-to-peer payments directly within the app interface. Users could pay for services, donate to creators, or split bills with friends—all within the same app they use daily for chatting. This convenience could significantly boost the adoption of digital currencies for everyday transactions, bridging the gap between traditional finance and the complicated world of cryptocurrencies.</p>
<h3 id="heading-building-a-more-inclusive-financial-ecosystem"><strong>Building a More Inclusive Financial Ecosystem</strong></h3>
<p>By making it incredibly easy for users to own and use a crypto wallet, WhatsApp and Telegram can play a crucial role in promoting financial inclusion. Many of their users in developing countries might not have easy access to traditional banking services but do have access to a smartphone. With <a target="_blank" href="http://www.web3auth.io">Web3Auth</a>, these users can participate in the digital economy, send and receive money, and access financial services that were previously out of reach.</p>
<h1 id="heading-conclusion"><strong>Conclusion</strong></h1>
<p>To wrap it all up, we're at a really interesting point where the old internet (Web2) and the new, exciting blockchain-based internet (Web3) are starting to merge. It's like we're building bridges between two lands. One is familiar with lots of users who like easy logins, like using their email or a social account. The other land is new, with lots of promise for privacy, security, and cool ways to use money online. <a target="_blank" href="http://www.web3auth.io">Web3Auth</a> is like a magical gate that helps people easily move from the old land to the new one without having to learn all the complicated stuff about how the gate works.</p>
<p>Think about how cool it would be if your favorite streaming site, like Netflix, started giving you digital coins just for watching shows. Or imagine posting on social media and getting paid in tokens that you can actually use. And what if, in apps like WhatsApp or Telegram, you could send money to a friend as easily as sending a sticker? All of this can be done without making you jump through hoops to set it up.</p>
<p><a target="_blank" href="http://www.web3auth.io">Web3Auth</a> is making it possible for companies to offer these exciting features without scaring their users with the hard parts of blockchain tech. It's important for these big companies to start thinking about how to introduce these features. If they don't, someone else will, bringing in all kinds of new ideas we're just starting to imagine, like paying users for watching ads or sharing profits.</p>
<p>With everything getting cheaper to do on the blockchain, especially with the latest updates making transactions cost almost nothing, there's no better time for companies to jump in. This isn't just about making things easier or safer; it's about opening up a whole new world of possibilities for users and companies alike. It's about making the internet a place where you get more control and even get paid for your time and creativity. And of course it’s about marketing and becoming different from your competition.</p>
<p>So as we move forward, the big question isn't if companies will make this shift, but when and how well they will do it. The organisations that get on board now will be the ones leading the way into this exciting future.</p>
]]></content:encoded></item><item><title><![CDATA[Farcaster , the next boom on web3]]></title><description><![CDATA[All the eyes of crypto are looking to this new decentralized social network: Farcaster]]></description><link>https://rtomas.hashnode.dev/farcaster-authentication-web3auth</link><guid isPermaLink="true">https://rtomas.hashnode.dev/farcaster-authentication-web3auth</guid><category><![CDATA[warpcast]]></category><category><![CDATA[Web3]]></category><category><![CDATA[authentication]]></category><category><![CDATA[farcaster]]></category><category><![CDATA[social network]]></category><category><![CDATA[lensprotocol]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Tue, 13 Feb 2024 14:52:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707670896091/9d51eb6e-0364-4ad2-a5fc-3d537d547705.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Since the <a target="_blank" href="https://warpcast.com/web3auth">Web3auth</a> decided that all communications will be also in <a target="_blank" href="http://farcaster.xyz">farcaster.xyz</a>, I started to dig inside the protocol.</p>
<p>Farcaster is a decentralized social network, that has an initial fee of 5u$s per year. This payment is like a pre-paid gas. To interact with the network, you can use the most used app, <a target="_blank" href="https://warpcast.com/"><strong>Warpcast</strong></a>. When you re<a target="_blank" href="https://warpcast.com/">gister i</a>n it, you'll receive 50 Warps to be used, for example to mint a NFT inside the platform.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707670374968/e6bdd211-0a5e-4f26-a253-3c7dd3fea34c.jpeg" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">🚀</div>
<div data-node-type="callout-text">It's important to inform that <a target="_blank" href="https://warpcast.com/web3auth">Web3auth</a> has just enabled the login process through Fascaster 🎉 ! <a target="_blank" href="https://web3auth.io/docs/content-hub/blog/farcaster-integration-web3auth">More info in the blog.</a></div>
</div>

<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707834900864/035276e3-862f-454b-93c5-072c6c289126.png" alt class="image--center mx-auto" /></p>
<p>If you're interested in how it works, please check out our <a target="_blank" href="https://demo.web3auth.io/">demo</a>.</p>
<h2 id="heading-frames-feature">Frames feature</h2>
<p>This social network has a pretty nice feature called Frames that allows developer to embed interactive experiences, using &lt;metatags&gt;. You can embed them in your post to create polls, live feeds, subscriber box or interactive galleries.</p>
<p>For all HTML experts, a frame is a set of &lt;meta&gt; tags inside the &lt;head&gt; of the page. The frame tag extends the <strong>OpenGraph protocol</strong> that is used by almost all social web pages that want to show a preview of a link.</p>
<p>Here is a simple example of a frame with an image, four buttons, and a link to a URL:</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">'utf-8'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'viewport'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'width=device-width, initial-scale=1'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">'next-size-adjust'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'vNext'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame:image'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'{imageUrl}'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame:button:1'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'{button1Text}'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame:button:2'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'{button2Text}'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame:button:3'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'{button3Text}'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame:button:4'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'{button4Text}'</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">'fc:frame:post_url'</span> <span class="hljs-attr">content</span>=<span class="hljs-string">'{apiUrl}'</span> /&gt;</span>
</code></pre>
<p>Another interesting feature is that Farcaster allows a button action called "<a target="_blank" href="https://warpcast.notion.site/Frames-Mint-action-Public-cea0d2249e3e41dbafb2e9ab23107275"><strong>Mint</strong></a><a target="_blank" href="https://warpcast.notion.site/Frames-Mint-action-Public-cea0d2249e3e41dbafb2e9ab23107275">", t</a>hat sends a POST to the url with signed information that you can validate in your server.</p>
<blockquote>
<p>When a user clicks a button on a frame, the app makes a POST request to the frame server with a <a target="_blank" href="https://docs.farcaster.xyz/reference/frames/spec#frame-signature"><strong>frame signature</strong> which proves</a> that the request came from the user. The server must respond with a new frame that is sent back to the user.</p>
<p>-- Frame documentation</p>
</blockquote>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"fc:frame:button:1"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"Mint"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"fc:frame:button:1:action"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"mint"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"fc:frame:button:1:target"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"eip155:7777777:0x060f3edd18c47f59bd23d063bbeb9aa4a8fec6df&lt;:token_id&gt;"</span> /&gt;</span>
</code></pre>
<p>The target must have a CAIP-10 format that is <strong>chain_id + ":" + account_address</strong> and you can add the token_id to mint to the user address at the end.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707671232187/4f1f02af-bbce-45a0-bbb8-3d04a163aa27.jpeg" alt class="image--center mx-auto" /></p>
<p>Another metatag is input:text, where you can enter an input and create a subscriber frame without reloading or open a popup. <a target="_blank" href="https://warpcast.notion.site/Frames-Text-Input-Public-27c9f0d61903486d89b6d932dd0d6a22"><strong>Read more in the specification</strong></a>.</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">property</span>=<span class="hljs-string">"fc:frame:input:text"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"Enter a message..."</span> /&gt;</span>
</code></pre>
<h2 id="heading-build-a-frame"><strong>Build a frame</strong></h2>
<p>If you want to build a frame, you can follow up my example from a personal project called "Colors for the peace". Each time you click in "more colors ...", a set of new peace colors will be loaded.</p>
<p>Github: <a target="_blank" href="https://github.com/rtomas/peace-frame-farcaster">https://github.com/rtomas/peace-frame-farcaster</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707751319649/fd404259-4656-4a8c-a51a-6dc477745eb1.png" alt class="image--center mx-auto" /></p>
<p>If you want to do more research, this video would help you to create an NFT Mint project: <a target="_blank" href="https://www.youtube.com/watch?v=771Sym9FgXw&amp;ab_channel=thirdweb">https://www.youtube.com/watch?v=771Sym9FgXw&amp;ab_channel=thirdweb</a></p>
<p>After building the frame you can validate it in two ways::</p>
<ul>
<li><p>The official online website: <a target="_blank" href="https://warpcast.com/~/developers/frames">https://warpcast.com/~/developers/frames</a></p>
</li>
<li><p>Locally using: <a target="_blank" href="https://framesjs.org/">https://framesjs.org/</a></p>
</li>
</ul>
<h2 id="heading-references">References:</h2>
<ul>
<li><p><a target="_blank" href="https://framesjs.org/">htt</a><a target="_blank" href="https://farcaster.xyz/">ps://farcaster.x</a><a target="_blank" href="https://warpcast.com/~/developers/frames">yz/</a></p>
</li>
<li><p><a target="_blank" href="https://warpcast.com/~/developers/frames">Frames spec</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=67nxKVvXItM&amp;ab_channel=Bankless">Bankless Video with the founder Dan Romero</a></p>
</li>
<li><p><a target="_blank" href="https://warpcast.com/~/developers/frames">https://warpcast.c</a><a target="_blank" href="https://warpcast.com/">om/</a></p>
</li>
<li><p><a target="_blank" href="https://framesjs.org/">https://ogp.me/</a></p>
</li>
<li><p><a target="_blank" href="https://vercel.com/docs/functions/og-image-generation">Open Graph (OG) Image Generation</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Web3 Onboarding: How Pre-generated Wallets are going to change the Game]]></title><description><![CDATA[Now a days I'm working in Web3Auth, and we have launched a new Wallet Service, that you I recommend you to check out. This service packs several features…]]></description><link>https://rtomas.hashnode.dev/web3-onboarding-how-pre-generated-wallets-are-going-to-change-the-game</link><guid isPermaLink="true">https://rtomas.hashnode.dev/web3-onboarding-how-pre-generated-wallets-are-going-to-change-the-game</guid><category><![CDATA[Web3]]></category><category><![CDATA[authentication]]></category><category><![CDATA[wallet]]></category><category><![CDATA[Ethereum]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Mon, 05 Feb 2024 15:14:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706822437548/3c1055f4-0fea-4843-9171-65f3c4d6f9cc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Now a days I'm working in <a target="_blank" href="http://Web3Auth.io">Web3Auth</a>, and we have launched a new <a target="_blank" href="https://web3auth.io/docs/content-hub/blog/web3auth-wallet-services.">Wallet Service</a>, that you I recommend you to check out. This service packs several features, but there's one in particular that is a game changer for bringing new people into the Web3 space.</p>
<p><strong>Pre-generated Wallets</strong>, my favorite feature, allows you to create user wallets using just an email or social account, bypassing traditional signup. Users gain instant ownership of the assets in their non-custodial wallets as soon as they log into your Dapp.</p>
<p>It allows you to create user wallets using just an email or social account, bypassing traditional signup. Users can claim these wallets later, simplifying the onboarding process. You can take a look at our <a target="_blank" href="https://web3auth.io/docs/sdk/wallet-services/pregenerate-wallet">interactive documentation</a>.</p>
<p>Any project, can now send tokens directly to their users' wallets, requiring nothing less than an email address.</p>
<p>It's crucial to mention that Web3Auth <strong>does NOT handle or store any private keys</strong>. Web3auth ensures everything stays <strong>decentralized</strong>. Learn more about our protocol here: <a target="_blank" href="https://web3auth.io/docs/infrastructure/">Web3Auth Protocol</a>.</p>
<p>For example, I see a huge potential for universities or online courses to use this to issue NFT diplomas directly, for a similar payment system like Paypal or for loyalty programs.</p>
<p>I ran into this issue once at a another company, where they wanted to give an NFT to someone who didn't know about crypto wallets. We had to create a wallet for them back then. Those days are gone, here is a perfect use case for onboarding more people to Web3.</p>
<p>If you think our wallet services could be a great integration to your project or your are curious to find out more? Chat with us at <a target="_blank" href="https://t.co/hOJqGQbV2U">http://w3a.link/hello</a></p>
]]></content:encoded></item><item><title><![CDATA[Web3Auth Integration with Microsoft Authentication]]></title><description><![CDATA[After some time of research on how to securely store the private keys, I found out about the web3auth project. They are building a Wallet As A Service…]]></description><link>https://rtomas.hashnode.dev/web3auth-integration-with-microsoft-authentication</link><guid isPermaLink="true">https://rtomas.hashnode.dev/web3auth-integration-with-microsoft-authentication</guid><category><![CDATA[Web3]]></category><category><![CDATA[wallet]]></category><category><![CDATA[authentication]]></category><category><![CDATA[Firebase]]></category><category><![CDATA[Microsoft]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Fri, 15 Dec 2023 21:34:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702675968041/742d0acc-d14e-4faf-a93a-0a5dcffbea49.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>After some time of research on how to securely store the private keys, I found out about the <a target="_blank" href="https://web3auth.io/">web3auth</a> project. They are building a Wallet As A Service product that is non-custodial without the seed phase. You can try the Tor.us wallet at this link <a target="_blank" href="https://tech.tor.us/">https://tech.tor.us/</a> and see how they split the private key into a social login (like Google, Reddit, etc), a user's device and a private input. And as long as you have 2 of these 3, you will be able to reconstruct your private key.</p>
<p>Please also check out my <a target="_blank" href="https://rtomas.hashnode.dev/key-kiss-key-keep-it-safe-secure">Key Kiss project</a> to learn more about another way to store the wallet's private key.</p>
<p>In this tutorial, we will integrate web3auth with Microsoft login via Firebase in a Next.js App (typescript). Once authenticated, we'll explore interactions with the Polygon blockchain, demonstrating the integration of secure authentication and blockchain functionality.</p>
<p>Here are the links for the <a target="_blank" href="https://github.com/rtomas/web3auth-interact">Github</a> and the <a target="_blank" href="https://web3auth-interact.vercel.app/">Web-Demo</a>.</p>
<p>Let's get started with the step-by-step process</p>
<h3 id="heading-step-1-set-up-your-nextjs-app"><strong>Step 1: Set Up Your Next.js App</strong></h3>
<p>Start by setting up a Next.js app using TypeScript. Make sure Node.js is installed. Go to your dev directory and run <code>npx create-next-app@latest</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702662116842/8b2aa3eb-672a-463d-8b71-88d9807b41b8.png" alt class="image--center mx-auto" /></p>
<p>Since we will be using the Web No-Modal SDK you need to install the web3auth packages (<a target="_blank" href="https://web3auth.io/docs/sdk/pnp/web/no-modal/install">documentation</a>) and others (web3.js, firebase and dotenv) executing:</p>
<p><code>cd web3auth-interact</code> (or the name of your project)</p>
<p><code>npm install --save web3 firebase dotenv @web3auth/no-modal @web3auth/base @web3auth/ethereum-provider @web3auth/openlogin-adapter</code></p>
<p>Also, the Github Repository can be cloned with the command</p>
<p><code>git clone https://github.com/rtomas/web3auth-interact.git</code> and then <code>npm install</code></p>
<h3 id="heading-step-2-configure-firebase"><strong>Step 2: Configure Firebase</strong></h3>
<p>Navigate to the <a target="_blank" href="https://console.firebase.google.com/">Firebase Console</a> and click Add project.</p>
<ul>
<li><p>After creating it in some very simple steps (you don't need to enable analytics), we would click the web icon (&lt;/&gt;) and <strong>register</strong> our app nickname.</p>
</li>
<li><p>Then you would get some important information. Please check the <a target="_blank" href="https://github.com/rtomas/web3auth-interact/blob/main/config/firebase.ts">Github project</a> on how the files could be ordered in different directories so the project information could be stored like this <a target="_blank" href="https://github.com/rtomas/web3auth-interact/blob/main/config/firebase.ts">file</a>.</p>
<pre><code class="lang-typescript">  <span class="hljs-comment">// /config/firebase.ts</span>
  <span class="hljs-keyword">const</span> firebaseConfig = {
    apiKey: <span class="hljs-string">"...."</span>,
    authDomain: <span class="hljs-string">"web3auth-polygon.firebaseapp.com"</span>,
    projectId: <span class="hljs-string">"web3auth-polygon"</span>,
    storageBucket: <span class="hljs-string">"web3auth-polygon.appspot.com"</span>,
    messagingSenderId: <span class="hljs-string">"....."</span>,
    appId: <span class="hljs-string">"......"</span>
  };
</code></pre>
</li>
<li><p>Add <strong>Microsoft</strong> as a "sign-in method" navigating to the Authentication -&gt; Sign-in method -&gt; Add Provider. Firebase would give you the <code>redirect URL</code> and ask you for the <code>Application ID</code> and <code>Application secret</code>, that you'll get in the next step.</p>
</li>
<li><p>Get the Firebase API Key inside the project settings and add it to the <code>.env.local</code> in the <code>NEXT_PUBLIC_FIREBASE_API_KEY</code> field.</p>
</li>
</ul>
<h3 id="heading-step-3-configure-microsoft-entra"><strong>Step 3: Configure Microsoft Entra</strong></h3>
<p>Go to <a target="_blank" href="https://entra.microsoft.com/">https://entra.microsoft.com/</a> (the product for all identity solutions from Microsoft) to create a new application. It's important to include the Web Redirect URI that you get from the Firebase configuration. After that, you will receive the <code>Application ID</code> and <code>Application secret</code>.</p>
<h3 id="heading-step-4-configure-web3auth"><strong>Step 4: Configure Web3Auth</strong></h3>
<p>Finally, we would <strong>create a project</strong> through the <a target="_blank" href="https://dashboard.web3auth.io/">web3auth dashboard</a>. The information should be:</p>
<ul>
<li><p>Products: <strong>Plug &amp; play</strong></p>
</li>
<li><p>Platform: <strong>Web Application</strong></p>
</li>
<li><p>Environment: <strong>Sapphire_devnet</strong> (only for test environment)</p>
</li>
<li><p>Chain: <strong>EVM Based Chain</strong></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702668956378/1da0a60f-4fb4-4eac-9080-f10604824fd0.png" alt class="image--center mx-auto" /></p>
<p>The <code>Client ID</code> must be copied into the <code>.env.local</code> file.</p>
<p>Don't forget to add your web domain to the <strong>Whitelist Domain</strong> in the project details.</p>
<h4 id="heading-configure-a-firebase-custom-authentication-verifier">Configure a Firebase Custom Authentication Verifier</h4>
<p>Into the Custom Authentication tab, you can create a <strong>Verifier</strong> with this information:</p>
<ul>
<li><p>Login Provider: <strong>Custom Providers</strong></p>
</li>
<li><p>JWKS Endpoint: <strong>https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com</strong></p>
</li>
<li><p>Verifier ID: <strong>Email</strong></p>
</li>
<li><p>The following are the JWT validation fields needed for the Firebase JWT validation:</p>
<ul>
<li><p>Type <code>iss</code> as a field and <a target="_blank" href="https://securetoken.google.com/FIREBASE-PROJECT-ID"><code>https://securetoken.google.com/FIREBASE-PROJECT-ID</code></a> as a value (the name entered to the project).</p>
</li>
<li><p>Next, type <code>aud</code> as a field and <code>FIREBASE-PROJECT-ID</code> as a value.</p>
</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1702669813541/1c1291ea-45ee-47b2-9d6a-2a562d4d7fc4.png" alt class="image--center mx-auto" /></p>
<p>To end the process you need to add the name of the verifier to the <code>.env.local</code> to the field <code>NEXT_PUBLIC_WEB3AUTH_VERIFIER_ID</code> .</p>
<h3 id="heading-step-5-implement-web3auth-and-microsoft-authentication"><strong>Step 5: Implement Web3Auth and Microsoft Authentication</strong></h3>
<p>After we pass through the difficult task of configuring the three different protocols, we can start with the code.</p>
<p>When the webpage loads, you would need to initialize the web3auth and notice if it's connected or not. web3AuthConfig and openloginAdapter are variables that get the information from <a target="_blank" href="https://github.com/rtomas/web3auth-interact/tree/main/config">configuration files</a>.</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// import configuration files</span>
<span class="hljs-keyword">import</span> { firebaseConfig } <span class="hljs-keyword">from</span> <span class="hljs-string">"@/config/firebase"</span>;
<span class="hljs-keyword">import</span> { web3AuthConfig, openloginAdapter } <span class="hljs-keyword">from</span> <span class="hljs-string">"@/config/web3auth"</span>;

...

<span class="hljs-comment">// conect to polygon testnet network on page load</span>
<span class="hljs-keyword">const</span> initOnPageLoad = <span class="hljs-keyword">async</span> () =&gt; {
        <span class="hljs-comment">// load the configuration file and init the No-Modal SDK</span>
        <span class="hljs-keyword">const</span> web3auth = <span class="hljs-keyword">new</span> Web3AuthNoModal(web3AuthConfig);
        web3auth.configureAdapter(openloginAdapter);
        <span class="hljs-keyword">await</span> web3auth.init();

        <span class="hljs-keyword">if</span> (web3auth.connected) {
            setLoggedIn(<span class="hljs-literal">true</span>);
        }
};
</code></pre>
<p>Also when the button Login is clicked we call the function <code>login()</code></p>
<pre><code class="lang-typescript">    <span class="hljs-comment">// Login with web3auth</span>
    <span class="hljs-keyword">const</span> login = <span class="hljs-keyword">async</span> () =&gt; {
        <span class="hljs-keyword">const</span> loginRes = <span class="hljs-keyword">await</span> signInWithMicrosoft();
        <span class="hljs-keyword">const</span> idToken = <span class="hljs-keyword">await</span> loginRes.user.getIdToken(<span class="hljs-literal">true</span>);

        <span class="hljs-keyword">const</span> web3authProvider = <span class="hljs-keyword">await</span> web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
            loginProvider: <span class="hljs-string">"jwt"</span>,
            extraLoginOptions: {
                id_token: idToken,
                verifierIdField: <span class="hljs-string">"email"</span>,
                domain: domain,
            },
        });

        setProvider(web3authProvider);
    };

   <span class="hljs-comment">// Call sign-in with microsoft popup through firebase</span>
    <span class="hljs-keyword">const</span> signInWithMicrosoft = <span class="hljs-keyword">async</span> (): <span class="hljs-built_in">Promise</span>&lt;UserCredential&gt; =&gt; {
        <span class="hljs-keyword">try</span> {
            <span class="hljs-comment">// Initialize Firebase</span>
            <span class="hljs-keyword">const</span> app = initializeApp(firebaseConfig);
            <span class="hljs-keyword">const</span> auth = getAuth(app);
            <span class="hljs-keyword">const</span> oAuthProvider = <span class="hljs-keyword">new</span> OAuthProvider(<span class="hljs-string">"microsoft.com"</span>);
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"oAuthProvider"</span>, oAuthProvider);
            oAuthProvider.setCustomParameters({
                prompt: <span class="hljs-string">"consent"</span>,
            });
            <span class="hljs-comment">// raise the popup to login with microsoft</span>
            <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> signInWithPopup(auth, oAuthProvider);
            <span class="hljs-keyword">return</span> res;
        } <span class="hljs-keyword">catch</span> (err) {
            <span class="hljs-built_in">console</span>.error(err);
            <span class="hljs-keyword">throw</span> err;
        }
    };

<span class="hljs-comment">// when the state Provider is changed, we set web3 state to start </span>
<span class="hljs-comment">// connecting the blockchain</span>
useEffect(<span class="hljs-function">() =&gt;</span> {
        <span class="hljs-keyword">if</span> (provider != <span class="hljs-literal">null</span>) setWeb3(<span class="hljs-keyword">new</span> Web3(provider));
}, [provider]);
</code></pre>
<h3 id="heading-step-6-interact-with-the-polygon-blockchain"><strong>Step 6: Interact with the Polygon Blockchain</strong></h3>
<p>Perform actions such as signing messages, sending transactions, reading from a smart contract, and deploying a smart contract on the Polygon blockchain.</p>
<p>Here are examples of how to read and write to the blockchain, but you can see all the functions in the <a target="_blank" href="https://github.com/rtomas/web3auth-interact/blob/main/pages/index.tsx">Github repository</a> or check out the <a target="_blank" href="https://web3auth.io/docs/connect-blockchain/polygon">web3auth documentation</a>.</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Read a smart contract and get the value of the counter</span>
    <span class="hljs-keyword">const</span> getCounterValueFromSmartContract = <span class="hljs-keyword">async</span> () =&gt; {
        <span class="hljs-comment">// ABI and Address from the contract are in the config file</span>
        <span class="hljs-keyword">const</span> contract = <span class="hljs-keyword">new</span> web3.eth.Contract(<span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(ABI)), counterAddress);

        <span class="hljs-comment">// Read message from smart contract</span>
        <span class="hljs-keyword">const</span> count = <span class="hljs-keyword">await</span> contract.methods.get().call();
    };
</code></pre>
<pre><code class="lang-typescript"> <span class="hljs-comment">// Update a state of smart contract, incrementing the counter</span>
    <span class="hljs-keyword">const</span> incrementCounterValueFromSmartContract = <span class="hljs-keyword">async</span> () =&gt; {
        <span class="hljs-comment">// ABI and Address from the contract are in the config file</span>
        <span class="hljs-keyword">const</span> contract = <span class="hljs-keyword">new</span> web3!.eth.Contract(<span class="hljs-built_in">JSON</span>.parse(<span class="hljs-built_in">JSON</span>.stringify(ABI)), counterAddress);

        <span class="hljs-comment">// change state from a smart contract</span>
        <span class="hljs-comment">// calling the method inc</span>
        <span class="hljs-keyword">await</span> contract.methods.inc().send({
            <span class="hljs-keyword">from</span>: address,
        });
    };
</code></pre>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<p>After using web3auth and trying to build my first app, I realized that this is a great tool to bring new people into the blockchain ecosystem. I thought about a lot of people who want to have an NFT, but don't want to learn how to create and keep their wallets secure. They could start from this point and in the future find a way to continue as they want, but always being the only owner of their assets.</p>
<p>Find the GitHub project here: <a target="_blank" href="https://github.com/rtomas/web3auth-interact">https://github.com/rtomas/web3auth-interact</a></p>
<p>References</p>
<ul>
<li><p><a target="_blank" href="https://web3auth.io/docs/content-hub/guides/firebase">https://web3auth.io/docs/content-hub/guides/firebase</a></p>
</li>
<li><p><a target="_blank" href="https://web3auth.io/docs/content-hub/guides/firebase">https://web3auth.io/docs/connect-blockchain/polygon</a></p>
</li>
<li><p><a target="_blank" href="https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal">https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Animated Image on-chain]]></title><description><![CDATA[Building a smart contract in solidity to keep our image inside the blockchain]]></description><link>https://rtomas.hashnode.dev/animated-image-on-chain</link><guid isPermaLink="true">https://rtomas.hashnode.dev/animated-image-on-chain</guid><category><![CDATA[Animated]]></category><category><![CDATA[Smart Contracts]]></category><category><![CDATA[Solidity]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[NFT]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Fri, 03 Nov 2023 20:41:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1699043270690/544f7261-7fe7-4584-aabd-f24a67a35a4b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>(may-2024 -&gt; updated to Polygon Amoy Testnet)</p>
<h3 id="heading-idea">Idea</h3>
<p>I was thinking about the idea of what would happen if I could have an animated image on-chain where you can update every pixel in any layer.</p>
<p>In my opinion, when you start creating new ideas, you could deal with some kind of interesting solution or a way to solve uncommon problems.</p>
<p>Before I started with the project, I looked up some similar repositories online. As I didn´t find any similar project, I decided to start coding it.</p>
<h3 id="heading-problem">Problem</h3>
<p>Everyone is building almost all NFT animated collections in IPFS. Of course, you can do it for free or use some paid services to upload your Animated GIF. But I like the idea of keeping all the projects inside the blockchain so you don't have to rely in other protocols. Also, this project allows you to build a 32x32 pixels image with 50 layers.</p>
<p>Of course, the main problem with this challenge is the amount of gas that people would spend every time someone updates a full Layer but I think we can do it anyway :).</p>
<h3 id="heading-solution">Solution</h3>
<p>After building the first example I could solve the problem with the smart contract and the front-end in next.js. You can check the animated image from a sunset at: <a target="_blank" href="https://animated-on-chain.vercel.app/">https://animated-on-chain.vercel.app/</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698691848362/a5008320-b451-4deb-990a-cac79487a880.png" alt class="image--center mx-auto" /></p>
<p>Looking at our test results, we found that each frame update costs a bit in gas, about 0.026 MATIC (819416 gwei *32 Y-pixels). If we send the whole frame in one go, it's a little cheaper, at about 0.025 MATIC. It's not super cheap, especially if you want to upload 30 frames.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698691748920/2c37f119-7c3e-46ff-8f46-643934cb6b7a.png" alt class="image--center mx-auto" /></p>
<p>Also, you have to compare that some IPFS that are working well would start to charge you when you have a bandwidth that exceeds 5 or 10 GB each month. So this could be a good solution to pay one and forget. This is because reading is free in the blockchain, we will only pay the gas to upload/update it.</p>
<h3 id="heading-next-steps">Next steps</h3>
<ul>
<li><p>I would update the smart contract to be ERC721 compatible, so anyone could buy and trade it in the marketplace like openSea.</p>
</li>
<li><p>Make more with different astronomic events.</p>
</li>
<li><p>Upload the app that generates the JSON to ease the upload of the animation of any video.</p>
</li>
</ul>
<p>References</p>
<ul>
<li><p>Smart Contract Github: <a target="_blank" href="https://github.com/rtomas/animatedImageOnChain-SC">https://github.com/rtomas/animatedImageOnChain-SC</a></p>
</li>
<li><p>UI Github: <a target="_blank" href="https://github.com/rtomas/animatedImageOnChain-UI">https://github.com/rtomas/animatedImageOnChain-UI</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[key-kiss (key keep it safe/secure)]]></title><description><![CDATA[A two-factor secure way to store your wallets private key]]></description><link>https://rtomas.hashnode.dev/key-kiss-key-keep-it-safe-secure</link><guid isPermaLink="true">https://rtomas.hashnode.dev/key-kiss-key-keep-it-safe-secure</guid><category><![CDATA[wallet]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[private key]]></category><category><![CDATA[Secure]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Tue, 17 Oct 2023 22:09:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1697570921405/1a92015b-2c4d-404c-860f-4898e514a696.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-problem">Problem</h3>
<p>When I started to get in touch with Crypto, I couldn't believe that the best solution to save your wallet's private key was a paper with 12 words in order. So I have always thought of another way to do it, but none of them were enough secure for me. So if someone stole your paper, they would have access to all your tokens and you couldn't do anything to stop it.</p>
<h3 id="heading-idea">Idea</h3>
<p>Seeing that the web2 world was adopting a two-factor authentication with tokens, I thought about what would happen if we split the private key into 2 parts. In this approach, one part would be securely stored, while the other would only be accessible through an entirely separate process.</p>
<p>My brainstorming led me to a unique concept. I found this kind of game where you put 2 sheets one on top of the other and you can see what is behind when you leave blank spaces.</p>
<h3 id="heading-solution">Solution</h3>
<p>I took advantage of the fact that I was about to start the ETHGlobal online hackathon and I had some free time to do it. This solution is a first iteration that hopefully I can improve over time.</p>
<p>The project consists of 2 parts:</p>
<ol>
<li><p>A CLI (<strong>deterministic image</strong>), built in Rust, creates an image with a deterministic order depending on your password.</p>
</li>
<li><p>A web app (<strong>secret kiss paper</strong>) that lets you choose the blank slots of your private key in each column.</p>
</li>
</ol>
<h3 id="heading-how-it-works">How it works</h3>
<p><strong>| Create the deterministic image and the secret kiss paper |</strong></p>
<ol>
<li><p>Generate a new deterministic image with your password. Execute the CLI.</p>
<ul>
<li><p><code>git clone</code> <a target="_blank" href="https://github.com/rtomas/key-kiss.git"><code>https://github.com/rtomas/key-kiss.git</code></a></p>
</li>
<li><p><code>cd secret-image-cli</code></p>
</li>
<li><p><code>cargo run</code></p>
</li>
</ul>
</li>
</ol>
<p><a target="_blank" href="https://user-images.githubusercontent.com/944960/273965001-c1b78d1b-5d1d-42f8-8c14-8d1c30a683e9.gif"><img src="https://user-images.githubusercontent.com/944960/273965001-c1b78d1b-5d1d-42f8-8c14-8d1c30a683e9.gif" alt="secret image" /></a></p>
<ol>
<li><p>Print the image. (example of the generated image).</p>
<p> You have cols with all the possibilities in a different order for each of the 64 characters from the private key.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697579299094/5a21970b-d25f-446d-a4b6-a60342a40e13.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Delete the PNG file.</p>
</li>
<li><p>Get your private key in metamask.</p>
</li>
</ol>
<p><a target="_blank" href="https://user-images.githubusercontent.com/944960/273359237-a77ffe8a-a546-43d6-9cc3-3eef007aa3ff.gif"><img src="https://user-images.githubusercontent.com/944960/273359237-a77ffe8a-a546-43d6-9cc3-3eef007aa3ff.gif" alt="267444635-eb064cfd-ceef-4e53-93a7-673e5625c434" /></a></p>
<ol>
<li><p>Create the "secret kiss paper" like the image below from your private key in this link: <a target="_blank" href="https://editor.p5js.org/rtomas/full/o1YL8Iw6J">https://editor.p5js.org/rtomas/full/o1YL8Iw6J</a></p>
<p> <img src="https://user-images.githubusercontent.com/944960/273359252-e021044e-cce5-4f4f-911b-ef67121557f0.png" alt="269683838-eb00723d-a66e-4cbe-8c17-a536fa875ef5" /></p>
</li>
<li><p>Burn 🔥 or cut ✂ the paper with the letters.</p>
</li>
<li><p>Keep the "secret kiss paper" in a safe place.</p>
</li>
<li><p>Create a "secret kiss METAL" (soon!).</p>
</li>
</ol>
<p><strong>| Recovery|</strong></p>
<ol>
<li><p>Generate the <strong>deterministic image</strong> with your password.</p>
<ul>
<li><p><code>git clone</code> <a target="_blank" href="https://github.com/rtomas/key-kiss.git"><code>https://github.com/rtomas/key-kiss.git</code></a></p>
</li>
<li><p><code>cd secret-image-cli</code></p>
</li>
<li><p><code>cargo run</code></p>
</li>
</ul>
</li>
<li><p>Put the "secret kiss paper" with the "deterministic image" printed or with the screen and watch your private key.</p>
</li>
</ol>
<p><img src="https://user-images.githubusercontent.com/944960/273359270-18e57ada-6e5f-4aeb-a446-6843145e6564.gif" alt="269778499-5e8034fd-7b43-4d8b-9ba5-788af10b0a69" /></p>
<h1 id="heading-links">Links:</h1>
<ul>
<li><p>GitHub repository: <a target="_blank" href="https://github.com/rtomas/key-kiss">https://github.com/rtomas/key-kiss</a></p>
</li>
<li><p>My linkedin: <a target="_blank" href="https://www.linkedin.com/in/tomas-rawski/">https://www.linkedin.com/in/tomas-rawski/</a></p>
</li>
<li><p>My art webpage: <a target="_blank" href="https://www.tomasrawski.com.ar/">https://www.tomasrawski.com.ar/</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Embracing Financial Transparency: Open Payroll]]></title><description><![CDATA[In recent years, a growing number of organizations have committed to financial transparency, recognizing the benefits of sharing information about earnings…]]></description><link>https://rtomas.hashnode.dev/embracing-financial-transparency-open-payroll</link><guid isPermaLink="true">https://rtomas.hashnode.dev/embracing-financial-transparency-open-payroll</guid><category><![CDATA[Payroll]]></category><category><![CDATA[polkadot]]></category><category><![CDATA[Blockchain]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Tue, 18 Jul 2023 13:30:32 GMT</pubDate><content:encoded><![CDATA[<p>In recent years, a growing number of organizations have committed to financial transparency, recognizing the benefits of sharing information about earnings with their employees and stakeholders. Tech workers' cooperatives in the Argentine Federation of Cooperatives <a target="_blank" href="https://facttic.org.ar/">FACTTIC</a> are a notable example of this trend, providing detailed financial information to members.</p>
<p>In addition to cooperatives, several companies have positioned themselves as "open numbers" enterprises, providing employees with access to information about the salaries of both workers and owners <a target="_blank" href="https://cultura.10pines.com/#numeros-abiertos">Ten Pines</a> is a good example of this trending culture. <a target="_blank" href="https://buffer.com/resources/revenue-dashboard/">Buffer</a>, for instance, publishes the salaries of all its employees on its website, and <a target="_blank" href="https://www.tableau.com/solutions/customer/whole-foods-market-democratizes-data-across-460-retail-stores-with-tableau">Whole Foods</a> allows employees to access financial information on a need-to-know basis. These efforts reflect a growing recognition of the importance of financial transparency in promoting trust and accountability within organizations.</p>
<p>We are launching Open Payroll, our goal is to meet the needs of organizations that wish to make transparent payments during a given period.</p>
<p>The payroll contract is owned entirely by its creator. This creator could be a DAO address, a multisig or a single person. The contract manages a treasury from which all the payments are deducted. There is a base amount and a set of multipliers associated with the addresses of the payees.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689687134781/5d25cdc1-16a0-4794-a539-06fe73741c1a.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-how-base-payment-and-multipliers-work"># How base payment and multipliers work</h1>
<p>The base payment is the number of tokens that all beneficiaries have as a starting point, and depending on the different types of multipliers, it will result in a final amount to be claimed.</p>
<p>For example, if the base payment is 1000 tokens, and there are multipliers such as seniority (2) and experience in the project (0.5), the calculation would be as follows: base payment (1000) * (seniority (2) + experience in the project (0.5)) = total for the period (2500 tokens).</p>
<p>You can manage the multipliers as you wish. Another example could be if the total sum of the multipliers is 1, the beneficiary would have the base payment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689687146627/2c03b0e4-55ac-4ceb-9aba-e056614a13e7.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-start-paying-through-open-payroll"># Start Paying through Open Payroll</h1>
<p>If you have a company and want to start using the payroll system, follow these steps:</p>
<ol>
<li><p>Enter the front-end app at: <a target="_blank" href="https://open-payroll.vercel.app/">https://open-payroll.vercel.app/</a>.</p>
</li>
<li><p>Connect your Polkadot-compatible favorite wallet.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686595464/83b3da5c-d195-42c5-963d-756cfc646de4.jpeg" alt class="image--center mx-auto" /></p>
</li>
<li><p>Click on the sidebar and choose the option “My contracts”.</p>
</li>
<li><p>Click on “Create new contract”.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686622045/50088c2d-74bd-43e0-a8ab-0024d6cb04b4.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Fill in the required information:</p>
<p> a. Contract Name &amp; Email <em>(The information is stored locally in your browser and not on the blockchain</em></p>
<p> b. Base Payment<br /> c. Periodicity</p>
<p> d. Multipliers to be used</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686960823/82ef8854-c599-4a9c-a1c9-8b6d2c2ba78d.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>On the last page, you can add the beneficiaries with their respective multiplier values. (The name of the beneficiaries will remain locally).</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686678570/6d1afa8a-af67-4dec-9133-a577cd1a4154.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Once you create the contract, you will need to transfer tokens to the contract so the beneficiaries can start claiming them.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689687154592/020bb972-be51-4674-9a77-0df87a88baa1.png" alt class="image--center mx-auto" /></p>
<p>In the Contract list, you will see all the contracts you have saved in your portfolio, with some information like funds in the contract, state, and funds needed for the next payment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686710012/39ee5fb1-5969-47d1-ad1e-d1d330001f38.png" alt class="image--center mx-auto" /></p>
<p>By entering into a contract, the owner will be able to perform:</p>
<ul>
<li><p>Modify the existing parameters in the contract.</p>
</li>
<li><p>Add, update or remove beneficiaries.</p>
</li>
<li><p>Add or remove multipliers.</p>
</li>
<li><p>Pause the contract, temporarily suspend the claim process, and halt any further payment disbursements.</p>
</li>
<li><p>Resume the contract, restoring its functionality.</p>
</li>
<li><p>Change the owner of the contract.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686749330/63cbbf26-ab4a-4d38-be5e-49c86277b7ef.png" alt class="image--center mx-auto" /></p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686804608/867dd3c7-3f0a-4da6-8cf4-e856e877d117.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689687160753/d3c68e17-73f3-4b43-9d5e-4ab09c6f1cff.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-claim-a-payment"># Claim a payment</h1>
<p>When you are trying to claim a payment, you need to follow these steps:</p>
<ol>
<li><p>Connect your wallet and go to the claim section in the sidebar.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689686832006/c2cb36d6-d59a-4947-999b-ba956209a2d5.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Copy the contract address into the textbox and click on “Find”.</p>
</li>
<li><p>The contract will be added to the list and you can claim partial or the total amount of tokens.</p>
</li>
</ol>
<h1 id="heading-conclusion"># <strong>Conclusion</strong></h1>
<p>In conclusion, Open Payroll offers a revolutionary solution for organizations seeking financial transparency and trust within their ranks. As more companies and cooperatives adopt the concept of "open numbers," we are proud to be at the forefront of this cultural shift.</p>
<p>By providing a user-friendly platform that allows companies to create and manage payroll contracts with customizable multipliers, we empower organizations to make fair and equitable payments to their employees and stakeholders. The base payment, combined with various multipliers, ensures that individuals are rewarded appropriately based on their skills, experience, and contributions.</p>
<p>Our commitment to security and privacy means that all contract information is stored locally in users' browsers, ensuring confidentiality while still allowing seamless interactions with the contract.</p>
<p>The power of financial transparency lies in the hands of our users, and we aim to facilitate a culture of trust, accountability, and fairness within organizations. Open Payroll invites you to join the growing movement of companies and cooperatives embracing financial transparency for a more inclusive and productive future.</p>
<p>Thank you for considering Open Payroll as your partner in fostering financial transparency and empowering your workforce. Together, let's build a more open and equitable world.</p>
<p>Also special thanks to the W3F for supporting the project.</p>
<p><strong>DISCLAIMER: UNAUDITED SMART CONTRACT</strong></p>
<p>This smart contract has not undergone any auditing process. You must use it with caution and at your own risk. The creators and developers bear no responsibility for any potential issues or losses resulting from its use. Please exercise due diligence and proceed with care when interacting with this contract.</p>
<p><a target="_blank" href="https://github.com/polkadrys/openPayroll/blob/main/disclaimer.md">Read complete disclaimer</a>.</p>
<h1 id="heading-links">Links:</h1>
<ul>
<li><p><a target="_blank" href="https://open-payroll.vercel.app/">https://open-payroll.vercel.app/</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/polkadrys/openPayroll">Smart Contract GitHub project</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/polkadrys/open-payroll-web/">Front-end GitHub project</a></p>
</li>
<li><p><a target="_blank" href="https://web3.foundation/">https://web3.foundation/</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Make unit test in a smart contract developed in ink ! 🦑]]></title><description><![CDATA[I highly recommend you to read my two previous tutorials Analyze, compile and deploy a smart contract and Create a smart contract in ink! Nowadays in…]]></description><link>https://rtomas.hashnode.dev/make-unit-test-in-a-smart-contract-developed-in-ink</link><guid isPermaLink="true">https://rtomas.hashnode.dev/make-unit-test-in-a-smart-contract-developed-in-ink</guid><category><![CDATA[ink]]></category><category><![CDATA[Rust]]></category><category><![CDATA[polkadot]]></category><category><![CDATA[Smart Contracts]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Mon, 10 Jul 2023 18:21:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688845947269/6815f076-ea93-41cf-9cf3-b88ec623780c.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I highly recommend you to read my two previous tutorials <a target="_blank" href="https://hashnode.com/post/clj8uyonu000009l2gep0eg68">Analyze, compile and deploy a smart contract</a> and <a target="_blank" href="https://hashnode.com/post/cljufebf0000609mjd2d05a88">Create a smart contract in ink!</a></p>
<p>Nowadays in version 4.x of ink! there is no way to divide the smart contract code and the tests. So at the end of the contract, we will add all our unit tests:</p>
<pre><code class="lang-rust">    <span class="hljs-meta">#[cfg(test)]</span>
    <span class="hljs-keyword">mod</span> tests {
        <span class="hljs-comment">/// Imports all the definitions from the outer scope so we can use them here.</span>
        <span class="hljs-keyword">use</span> super::*;

        <span class="hljs-comment">// !!!!!</span>
        <span class="hljs-comment">// Here we are going to add all our tests</span>
        <span class="hljs-comment">// !!!!!  </span>
    }
</code></pre>
<p>Let's start writing the tests:</p>
<pre><code class="lang-rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">create_contract</span></span>() -&gt; OpenColors {
    <span class="hljs-keyword">let</span> sender = default_accounts().alice;
    set_sender(sender);

    <span class="hljs-comment">// initial_colors -&gt; function with pre.defined colors</span>
    OpenColors::new(initial_colors()) 
}

<span class="hljs-meta">#[ink::test]</span>
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">basic_contract_creation</span></span>() {
    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> open_colors = create_contract();
    <span class="hljs-built_in">assert_eq!</span>(
        open_colors.get_last_color(),
        <span class="hljs-literal">Some</span>(Color {
            r: <span class="hljs-number">255</span>,
            g: <span class="hljs-number">255</span>,
            b: <span class="hljs-number">255</span>
        })
    );
    <span class="hljs-built_in">assert_eq!</span>(open_colors.get_colors_list(), initial_colors());
    <span class="hljs-built_in">assert_eq!</span>(open_colors.colors_added_per_user.get(alice()).unwrap(), <span class="hljs-number">2</span>);
    <span class="hljs-built_in">assert_eq!</span>(open_colors.owner, alice());
}
</code></pre>
<p>The function to be tested, we must have the attribute <code>#[ink::test]</code> before the declaration.</p>
<p>The first check that the <code>assert_eq</code> is doing is to check if the contract call to <code>get_last_color()</code> is the same to a specific color.</p>
<pre><code class="lang-rust"><span class="hljs-meta">#[ink::test]</span>
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">add_a_color</span></span>() {
    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> open_colors = create_contract();

    set_sender(bob());
    <span class="hljs-comment">// call the contract to add an specific color</span>
    open_colors.add_color(Color { r: <span class="hljs-number">255</span>, g: <span class="hljs-number">0</span>, b: <span class="hljs-number">0</span> });

    <span class="hljs-keyword">let</span> final_colors = <span class="hljs-built_in">vec!</span>[
        Color { r: <span class="hljs-number">0</span>, g: <span class="hljs-number">0</span>, b: <span class="hljs-number">0</span> },
        Color {
            r: <span class="hljs-number">255</span>,
            g: <span class="hljs-number">255</span>,
            b: <span class="hljs-number">255</span>,
        },
        Color { r: <span class="hljs-number">255</span>, g: <span class="hljs-number">0</span>, b: <span class="hljs-number">0</span> },
    ];
    <span class="hljs-built_in">assert_eq!</span>(open_colors.get_colors_list(), final_colors);
    <span class="hljs-built_in">assert_eq!</span>(open_colors.colors_added_per_user.get(bob()).unwrap(), <span class="hljs-number">1</span>);
    <span class="hljs-built_in">assert_eq!</span>(open_colors.last_color, <span class="hljs-literal">Some</span>(Color { r: <span class="hljs-number">255</span>, g: <span class="hljs-number">0</span>, b: <span class="hljs-number">0</span> }));
}
</code></pre>
<p>The test function <code>add_a_color</code>, create a default contract, set who is going to be the sender of the next executions and call the contract to add a specific color. Later on, the function checks the total list of colors with an array, the number of colors added by Bob and the last color.</p>
<pre><code class="lang-rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">alice</span></span>() -&gt; AccountId {
   default_accounts().alice
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">bob</span></span>() -&gt; AccountId {
    default_accounts().bob
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">set_sender</span></span>(sender: AccountId) {
    ink::env::test::set_caller::&lt;ink::env::DefaultEnvironment&gt;(sender);
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">default_accounts</span></span>() -&gt; ink::env::test::DefaultAccounts&lt;ink::env::DefaultEnvironment&gt; {
    ink::env::test::default_accounts::&lt;ink::env::DefaultEnvironment&gt;()
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">advance_n_blocks</span></span>(n: <span class="hljs-built_in">u32</span>) {
    <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-number">0</span>..n {
        ink::env::test::advance_block::&lt;ink::env::DefaultEnvironment&gt;();
    }
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">get_current_block</span></span>() -&gt; <span class="hljs-built_in">u32</span> {
    ink::env::block_number::&lt;ink::env::DefaultEnvironment&gt;()
}

<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">get_balance</span></span>(account_id: AccountId) -&gt; Balance {
    ink::env::test::get_account_balance::&lt;ink::env::DefaultEnvironment&gt;(account_id)
                .expect(<span class="hljs-string">"Cannot get account balance"</span>)
}
</code></pre>
<p>These are some functions that could help you to code faster some unit tests.</p>
<p>Full smart contract and test code: <a target="_blank" href="https://github.com/rtomas/openColors/blob/main/lib.rs"><strong>https://github.com/rtomas/openColors/blob/main/lib.rs</strong></a></p>
<p>Finally, execute in the terminal <code>cargo test</code> to run and validate all the tests.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688851446633/2494a1ea-1413-4478-8f81-202d74f7a692.jpeg" alt class="image--center mx-auto" /></p>
<p>Reference:</p>
<ul>
<li><a target="_blank" href="https://use.ink/basics/contract-testing">Ink! Test Documentation</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Create a smart contract in ink! 🦑]]></title><description><![CDATA[Using Open Dream Colors as our project to analice in deep]]></description><link>https://rtomas.hashnode.dev/create-a-smart-contract-in-ink</link><guid isPermaLink="true">https://rtomas.hashnode.dev/create-a-smart-contract-in-ink</guid><category><![CDATA[ink]]></category><category><![CDATA[Rust]]></category><category><![CDATA[polkadot]]></category><category><![CDATA[Smart Contracts]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Sat, 08 Jul 2023 19:55:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688577364484/94932368-f56d-4a04-882d-52ec7fc9caec.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You can read my <a target="_blank" href="https://rtomas.hashnode.dev/analyze-compile-and-deploy-a-smart-contract-on-a-polkadot-parachain">previous tutorial</a> to understand a little more about how to analyze, compile and deploy a smart contract developed in ink!</p>
<p>The idea of this tutorial is to follow the creation of a smart contract and understand the different parts of it. We are adding this tutorial as part of the art project "Open Dream Colors" which can be seen in <a target="_blank" href="https://opencolors.tomasrawski.com.ar/">https://opencolors.tomasrawski.com.ar/</a></p>
<h3 id="heading-create-the-smart-contract-project">Create the smart contract project</h3>
<p>Run in your terminal <code>cargo contract new openColors</code></p>
<h3 id="heading-think-and-create-the-storage-of-the-smart-contract">Think and create the storage of the smart contract</h3>
<p>As you may be planning to write your smart contract, it's a good practice to think about which should be the storage structure, the public functions that would change that storage, the functions that only would read from it and the private functions.</p>
<p>When you are starting it's a good practice to take in mind:</p>
<ul>
<li><p>Use already-written tools or code where possible, like <a target="_blank" href="https://openbrush.brushfam.io/">OpenBrush</a></p>
</li>
<li><p>Sometimes it's good to prioritize clarity and simplicity over performance.</p>
</li>
<li><p>Consider gas costs when you are thinking about a function, building or modifying the storage.</p>
</li>
<li><p>Be careful when making external contract calls.</p>
</li>
<li><p>Test the smart contract as much as you can. (<a target="_blank" href="https://rtomas.hashnode.dev/make-unit-test-in-a-smart-contract-developed-in-ink">see the next tutorial about testing</a>)</p>
</li>
<li><p>If possible, have your smart contract audited by a 3rd-party company.</p>
</li>
<li><p>Stay informed about new vulnerabilities.</p>
</li>
</ul>
<p>So we would add these items to our storage:</p>
<ul>
<li><p>List of colors</p>
</li>
<li><p>The last color added</p>
</li>
<li><p>The number of colors that each wallet has</p>
</li>
<li><p>Total colors added</p>
</li>
<li><p>The owner of the contract</p>
</li>
</ul>
<pre><code class="lang-rust">    <span class="hljs-comment">// a Struct for the color with Red, Green and blue values: 0-255</span>
    <span class="hljs-meta">#[derive(scale::Encode, scale::Decode, Eq, PartialEq, Debug, Clone)]</span>
    <span class="hljs-meta">#[cfg_attr(feature = <span class="hljs-meta-string">"std"</span>, derive(scale_info::TypeInfo, StorageLayout,))]</span>
    <span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Color</span></span> {
        r: <span class="hljs-built_in">u8</span>,
        g: <span class="hljs-built_in">u8</span>,
        b: <span class="hljs-built_in">u8</span>,
    }

    <span class="hljs-meta">#[ink(storage)]</span>
    <span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">OpenColors</span></span> {
        <span class="hljs-comment">// All the colors in order</span>
        colors_list: <span class="hljs-built_in">Vec</span>&lt;Color&gt;,
        <span class="hljs-comment">// The last color added</span>
        last_color: <span class="hljs-built_in">Option</span>&lt;Color&gt;,
        <span class="hljs-comment">// The amount of colors per Account</span>
        colors_added_per_user: Mapping&lt;AccountId, <span class="hljs-built_in">u32</span>&gt;,
        <span class="hljs-comment">// the amount of colors added</span>
        total_colors_added: <span class="hljs-built_in">u32</span>,
        <span class="hljs-comment">// the owner of the contract that can reset it</span>
        owner: AccountId,
    }
</code></pre>
<p>More info about storage behavior in ink!: <a target="_blank" href="https://use.ink/basics/storing-values">https://use.ink/basics/storing-values</a> &amp; <a target="_blank" href="https://use.ink/datastructures/mapping/">https://use.ink/datastructures/mapping/</a></p>
<p>The struct <code>Color</code> is a custom structure that has to implement several traits, that the compiler would guide to or you can see the documentation: <a target="_blank" href="https://use.ink/datastructures/custom-datastructure">https://use.ink/datastructures/custom-datastructure</a>.</p>
<p>This custom trait, <code>Color</code> has 3 properties to store the value of each amount of color and the <code>OpenColors</code> struct uses a <code>Vec&lt;Color&gt;</code> to maintain the list of colors in order. The <code>last_color</code> property has the <code>Option&lt;Color&gt;</code> structure to allow us to have a <code>None</code> value when no colors have been added yet to the contract.</p>
<p>The mapping structure in Ink! is very similar to the one in Solidity and I recommend reading the provided link above for a better understanding of the functionality. Unlike a <code>Vec</code>, accessing information from a mapping will only retrieve the specific piece of information requested, rather than the entire set of data.</p>
<h3 id="heading-implement-the-functions-that-will-interact-with-the-struct-storage">Implement the functions that will interact with the struct storage</h3>
<p>Inside <code>impl OpenColors { ... }</code> there are all the functions. First, here is the constructor:</p>
<pre><code class="lang-rust">        <span class="hljs-comment">/// Constructor that initializes with the initial colors send in a vector</span>
        <span class="hljs-meta">#[ink(constructor)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>(initial_colors: <span class="hljs-built_in">Vec</span>&lt;Color&gt;) -&gt; <span class="hljs-keyword">Self</span> {
            <span class="hljs-comment">// instanciate the storage with the default values</span>
            <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> instance = Self::default();

            <span class="hljs-comment">// set the owner</span>
            <span class="hljs-keyword">let</span> user = Self::env().caller();
            instance.owner = user;

            <span class="hljs-keyword">if</span> initial_colors.is_empty() {
                <span class="hljs-keyword">return</span> instance;
            }

            <span class="hljs-comment">// add the last color</span>
            instance.last_color = initial_colors.last().cloned();
            <span class="hljs-comment">// add the vector and the amount of colors to the diff. storage</span>
            <span class="hljs-keyword">let</span> colors_added =
                instance.colors_added_per_user.get(user).unwrap_or(<span class="hljs-number">0</span>) + initial_colors.len() <span class="hljs-keyword">as</span> <span class="hljs-built_in">u32</span>;
            instance.colors_added_per_user.insert(user, &amp;colors_added);
            instance.colors_list = initial_colors.clone();
            instance.total_colors_added = initial_colors.len() <span class="hljs-keyword">as</span> <span class="hljs-built_in">u32</span>;

            instance
        }

        <span class="hljs-comment">/// Set Default values with no colors</span>
        <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">default</span></span>() -&gt; <span class="hljs-keyword">Self</span> {
            <span class="hljs-keyword">Self</span> {
                owner: Self::env().caller(),
                colors_list: <span class="hljs-built_in">Vec</span>::new(),
                last_color: <span class="hljs-literal">None</span>,
                colors_added_per_user: Mapping::new(),
                total_colors_added: <span class="hljs-number">0</span>,
            }
        }
</code></pre>
<p><code>self.env().caller()</code> -&gt; Return the Account of the wallet that is calling the function.</p>
<p>A function that only return the list of colors doesn't spend any gas, because is only a reading function and we are not changing the state of the blockchain:</p>
<pre><code class="lang-rust">        <span class="hljs-comment">/// Get the list of the colors </span>
        <span class="hljs-meta">#[ink(message)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">get_colors_list</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>) -&gt; <span class="hljs-built_in">Vec</span>&lt;Color&gt; {
            <span class="hljs-comment">// simple return the vector that is in the storage</span>
            <span class="hljs-keyword">self</span>.colors_list.clone()
        }
</code></pre>
<p>The function has a public property (<code>pub</code>) and the attribute <code>#[ink(message)]</code>, so everyone can call it.</p>
<pre><code class="lang-rust">        <span class="hljs-comment">/// add a color at the end of the vector and update counters</span>
        <span class="hljs-meta">#[ink(message)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">add_color</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>, color: Color) {
            <span class="hljs-keyword">let</span> account = <span class="hljs-keyword">self</span>.env().caller();
            <span class="hljs-comment">// add to the list</span>
            <span class="hljs-keyword">self</span>.colors_list.push(color.clone());

            <span class="hljs-comment">// increment the amount of colors per user</span>
            <span class="hljs-keyword">let</span> amount_of_color = <span class="hljs-keyword">self</span>
                .colors_added_per_user
                .get(<span class="hljs-keyword">self</span>.env().caller())
                .unwrap_or(<span class="hljs-number">0</span>)
                + <span class="hljs-number">1</span>;
            <span class="hljs-comment">// insert into the mapping</span>
            <span class="hljs-keyword">self</span>.colors_added_per_user.insert(account, &amp;amount_of_color);
            <span class="hljs-keyword">self</span>.last_color = <span class="hljs-literal">Some</span>(color.clone());
            <span class="hljs-keyword">self</span>.total_colors_added += <span class="hljs-number">1</span>;

            <span class="hljs-comment">// emit the event of the color added</span>
            <span class="hljs-keyword">self</span>.env().emit_event(ColorAdded {
                account_id: account,
                color,
            });
        }
</code></pre>
<p>The function <code>add_color</code> received a parameter with the color to add at the end of the list and updates all the count storages.</p>
<p>In the end, it calls the <code>emit_event</code> function to emit an event so that the Interfaces can listen to it and know how to behave in that case. It's very important for the protocols that are indexing the blockchain and can easily index the information by only reading the events.</p>
<p>So a good practice will be to raise an event every time there is a change in the state of the blockchain and try to add all the information to the event. In this case, we share the <code>account_id</code> which calls the function and the color that the user added.</p>
<p>Finally, we have a private function that we can be call when we need to ensure (inside a function) that the <strong>owner of the contract</strong> is calling that extrinsic:</p>
<pre><code class="lang-rust">    <span class="hljs-comment">/// Ensure_owner ensures that the caller is the owner of the contract</span>
    <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">ensure_owner</span></span>(&amp;<span class="hljs-keyword">self</span>) -&gt; <span class="hljs-built_in">Result</span>&lt;(), Error&gt; {
        <span class="hljs-keyword">let</span> account = <span class="hljs-keyword">self</span>.env().caller();
        <span class="hljs-comment">// Only owners can call this function</span>
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">self</span>.owner != account {
            <span class="hljs-keyword">return</span> <span class="hljs-literal">Err</span>(Error::NotOwner);
        }
        <span class="hljs-literal">Ok</span>(())
    }
</code></pre>
<p>We can add an Enum of errors with the macros that we see above and the struct for every event must have the attribute <code>#[ink(event)]</code></p>
<pre><code class="lang-rust">    <span class="hljs-meta">#[derive(scale::Encode, scale::Decode, Eq, PartialEq, Debug, Clone)]</span>
    <span class="hljs-meta">#[cfg_attr(feature = <span class="hljs-meta-string">"std"</span>, derive(scale_info::TypeInfo))]</span>
    <span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">enum</span> <span class="hljs-title">Error</span></span> {
        <span class="hljs-comment">// The caller is not the owner of the contract</span>
        NotOwner,
    }

    <span class="hljs-comment">/// called when someone add a color</span>
    <span class="hljs-meta">#[ink(event)]</span>
    <span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">ColorAdded</span></span> {
        <span class="hljs-meta">#[ink(topic)]</span>
        account_id: AccountId,
        color: Color,
    }
</code></pre>
<p>Full smart contract code: <a target="_blank" href="https://github.com/rtomas/openColors/blob/main/lib.rs">https://github.com/rtomas/openColors/blob/main/lib.rs</a></p>
<p>Reference:</p>
<ul>
<li><p><a target="_blank" href="https://rtomas.hashnode.dev/analyze-compile-and-deploy-a-smart-contract-on-a-polkadot-parachain">Tutorial to compile and deploy a smart contract</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com/post/clf6y32df000f09lb67zz7q8v">Polkadot Learning Path</a></p>
</li>
<li><p><a target="_blank" href="https://rtomas.hashnode.dev/make-unit-test-in-a-smart-contract-developed-in-ink">Tutorial: Make unit test in a smart contract developed in ink !</a></p>
</li>
</ul>
<p>Links :</p>
<ul>
<li><a target="_blank" href="https://consensys.github.io/smart-contract-best-practices/">https://consensys.github.io/smart-contract-best-practices/</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[¿Cómo usar la obra 🌈 "Open Dream Colors" 🛌 (El color de tus sueños) con tu propia billetera virtual y pedir por los tokens ROCs ?]]></title><description><![CDATA[Una guía interactiva para principiantes]]></description><link>https://rtomas.hashnode.dev/como-usar-la-obra-open-dream-colors-el-color-de-tus-suenos-con-tu-propia-billetera-virtual-y-pedir-por-los-tokens-rocs</link><guid isPermaLink="true">https://rtomas.hashnode.dev/como-usar-la-obra-open-dream-colors-el-color-de-tus-suenos-con-tu-propia-billetera-virtual-y-pedir-por-los-tokens-rocs</guid><category><![CDATA[Rust]]></category><category><![CDATA[polkadot]]></category><category><![CDATA[Art]]></category><category><![CDATA[Smart Contracts]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Wed, 05 Jul 2023 18:54:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688583348231/ed182d1d-5c9a-46a3-a7c5-1b6389c8d7bc.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>La obra es un proyecto educacional que combina la creatividad con la tecnología. Sirve como una plataforma interactiva para que las personas puedan explorar y entender los conceptos de blockchain. Los participantes están invitados a aprender los fundamentos de esta tecnología que es descentralizada y sus potenciales aplicaciones.</p>
<p>Van a poder contribuir con el color de sus sueños en un canvas compartido y digital. Cada color agregado es grabado en la blockchain, asegurando transparencia e inmutabilidad en el color y en el orden de aparición. Colaborando en una experiencia descentralizada y colaborativa.</p>
<p>Mediante este proyecto, las personas no solo obtienen conocimiento, sino experiencia de ser participantes de esta experiencia artística.</p>
<h3 id="heading-paso-1-or-instalar-la-billetera-virtual">paso 1 | Instalar la billetera virtual 🎢</h3>
<p>Instalar una billetera compatible con el ecosistema Polkadot en tu navegador. Yo actualmente estoy usando <a target="_blank" href="https://www.subwallet.app/"><strong>Subwallet</strong></a>, principalmente porque es compatible con Ethereum.</p>
<p>Pero podes probar tambien otras como <a target="_blank" href="https://www.talisman.xyz/"><strong>Talisman</strong></a>, que por el momento solo sirven para Polkadot.</p>
<ol>
<li><p>Vamos a la web}: <a target="_blank" href="https://www.subwallet.app/download.html"><strong>https://www.subwallet.app/download.html</strong></a></p>
</li>
<li><p>Seleccionamos el navegador:</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688400945868/8a0b4fd3-4d5e-4eca-abe3-2d4393e9df38.png?auto=compress,format&amp;format=webp" alt /></p>
<p> Para Chrome, serás redirigido a la página para instalar la extensión y clickeamos en "Add to Chrome".</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688400610384/c22e5ace-75c5-4a45-985a-0a03ad1c93d3.png?auto=compress,format&amp;format=webp" alt /></p>
<p> Luego en "Create a new account" (Crear una nueva cuenta) e ingresar una password, que se nos preguntará cada vez que ingresemos a la aplicación.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688400903585/689c04a2-6653-404c-8870-37f9b40aa53c.png?auto=compress,format&amp;format=webp" alt /></p>
<p> Ahora el sistema va a generar una billetera virtual. Vas a tener que escribir las palabras en una hoja de papel, manteniendo el mismo orden. Es importante que guardes estas palabras ya que van a ser tu backup para acceder a la billetera en caso de cualquier problema.</p>
</li>
</ol>
<h3 id="heading-paso-2-or-pedir-por-monedas-roc-gratuitas">paso 2 | Pedir por monedas Roc (gratuitas) 🤑</h3>
<p>Para interactuar con la aplicación obra (agregar un color al canvas), vas a necesitar tener la moneda Roc y así pagar el precio del gas. Siempre que modifiquemos el estado de la blockchain, se nos va a cobrar. En este caso pagamos con monedas de prueba. Ya que esta aplicación corre sobre una blockchain de pruebas, dentro del ecosistema de Polkadot.</p>
<ol>
<li><p>Hacemos click en nuestro navegador en el icono de Subwallet.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688402065967/3b75615c-b436-4be8-b7ac-6f25bf7ac5b8.png?auto=compress,format&amp;format=webp" alt /></p>
<p> Presionamos el icono que nos muestra la imagen de abajo.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688402360981/cf594e2e-7f52-4cb2-9e5d-ad65c09d02a8.png?auto=compress,format&amp;format=webp" alt /></p>
<p> Buscamos por la moneda "ROC" y presionamos nuevamente el icono de copiar. Esto nos guardará en el portapapeles una dirección de nuestra billetera virtual similar a esta : "5E9sZJHejrpZ6Ge5srT3sio9yJTuqrCBBgcwKxf63yd3viER"</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688402873207/a9096277-6474-4273-8ae7-0077863b5bae.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
<li><p>Ahora nos dirigimos en nuestro navegador a <a target="_blank" href="https://use.ink/faucet/"><strong>https://use.ink/faucet/</strong></a> para pedir los tokens (monedas) ROC a nuestra billetera. Copiamos la dirección y presionamos en "Request". Recibiremos en menos de 1 minuto la respuesta "Your funds have been sent" (Los fondos fueron enviados)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688402972850/54e35122-c1a6-4d25-bd7d-0c1ba3ac2067.png?auto=compress,format&amp;format=webp" alt /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688403031517/8f1fb33b-95e4-4d00-a4e9-2161c2595c26.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
</ol>
<h3 id="heading-paso-3-or-interactuar-con-el-contrato">paso 3 | Interactuar con el contrato 🕺🏻</h3>
<ol>
<li><p>Ir a <a target="_blank" href="https://opencolors.tomasrawski.com.ar/"><strong>https://opencolors.tomasrawski.com.ar/</strong></a> y clickear en la fecha de arriba a la</p>
</li>
<li><p>Click en "Connect to Subwallet" (Conectar con la billetera Subwallet)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688403194695/0ba167a1-1d58-40b7-bedc-5b722793f3a9.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
<li><p>Elegimos la cuenta y presionamos en "Connect" (Conectar)</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688403321096/e72073e0-82c6-4a87-9d04-0a52e705793d.png?auto=compress,format&amp;format=webp" alt /></p>
<p> Ahora verás la cuenta conectada al sitio.</p>
</li>
<li><p>Elegimos el color de tus sueños y presionamos en "Add color" (agregar un color).</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688403447775/5155c676-932a-4f6f-a0bf-518b7a6deaed.png?auto=compress,format&amp;format=webp" alt /></p>
</li>
<li><p>Luego la billetera nos pedirá que aprobemos la transacción, pagando por el gas. Presionamos en "Approve" (aprobar)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688403802969/225bf2c9-3b15-4521-91bf-3fe5477f7270.png?auto=compress,format&amp;format=webp" alt /></p>
<ol>
<li>En menos de un minuto recibiremos el mensaje de abajo que nos informa que nuestra transacción fue finalizada y el color agregado al estado de la blockchain. Por ende se mostrará en el canvas.</li>
</ol>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688403738450/319ae7d9-8c39-4f44-98fe-24148f659ad4.png?auto=compress,format&amp;format=webp" alt /></p>
<p><strong>Felicitaciones! Acabas de interactuar con un contrato inteligente en el Ecosistema Polkadot 🙌🏼 🎉 🕺🏻</strong></p>
<p><em>Si queres saber mas de la transacción, podes ver el explorador de blockchain :</em> <a target="_blank" href="http://polkadot.js.org/apps/#/explorer/query/0x413"><strong><em>polkadot.js.org/apps/#/explorer/query/0x413</em></strong></a><a target="_blank" href="https://polkadot.js.org/apps/#/explorer/query/0x413af3aa5d854be7c18f040b1a4b7b48a71136f4aa3917a49afea15f6529630a"><strong><em>..</em></strong></a></p>
<p><em>Cuando agregas un color al canvas, estas pagando aproximadamente 0.0005 ROC cada vez.</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688404213720/767aae78-66f2-47e8-bd97-f79c31cf932f.png?auto=compress,format&amp;format=webp" alt /></p>
<p>Para mas información de mis obras podes visitar mi sitio web: <a target="_blank" href="http://www.tomasrawski.com.ar"><strong>www.tomasrawski.com.ar</strong></a></p>
]]></content:encoded></item><item><title><![CDATA[Analyze, compile and deploy a Smart Contract on a Polkadot parachain 🛤]]></title><description><![CDATA[Analyze, compile and deploy a Smart Contract on a Polkadot parachain called]]></description><link>https://rtomas.hashnode.dev/analyze-compile-and-deploy-a-smart-contract-on-a-polkadot-parachain</link><guid isPermaLink="true">https://rtomas.hashnode.dev/analyze-compile-and-deploy-a-smart-contract-on-a-polkadot-parachain</guid><category><![CDATA[Smart Contracts]]></category><category><![CDATA[ink]]></category><category><![CDATA[Rust]]></category><category><![CDATA[polkadot]]></category><category><![CDATA[parachain]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Fri, 23 Jun 2023 17:40:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687487231749/a0b2f104-ddb1-47a3-9320-5bd03d77f650.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For this tutorial, we are going to use <a target="_blank" href="https://use.ink/">Ink</a>! as our Rust language to develop <a target="_blank" href="https://use.ink/smart-contracts-polkadot">smart contracts in the Polkadot ecosystem</a>. But it's good to know that you can do it in any language that compiles to wasm.</p>
<p>We'll use parachains that have the <a target="_blank" href="https://paritytech.github.io/substrate/master/pallet_contracts/index.html">Contract Pallet</a> installed in their substrate configuration. This pallet allows us to execute <a target="_blank" href="https://webassembly.org/">WebAssembly</a>.</p>
<p>Let's start our journey :</p>
<h3 id="heading-setup-environment">Setup Environment 🎨</h3>
<ol>
<li><p>Install Rust &amp; cargo: Visit the official Rust website (<a target="_blank" href="https://doc.rust-lang.org/cargo/getting-started/installation.html">https://doc.rust-lang.org/cargo/getting-started/installation.html</a>) and follow the installation instructions for your operating system.</p>
</li>
<li><p>Install <em>cargo-contract</em> with the information in the readme of the github repository (<a target="_blank" href="https://github.com/paritytech/cargo-contract">https://github.com/paritytech/cargo-contract</a>), this will install the CLI tool which helps you develop smart contracts.</p>
</li>
<li><p>In the terminal, go to your dev directory and run <code>cargo contract new state_variable</code>. You would create a directory with the name of the project and inside a default project. (<a target="_blank" href="https://github.com/paritytech/ink-examples/blob/main/flipper/lib.rs">Github: Flipper default proyect</a>)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687446525852/8559fc83-f157-4d55-85bb-8dd02dfa31cc.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Install a Polkadot-compatible wallet extension for your browser. I recommend any of these: <a target="_blank" href="https://www.talisman.xyz/">Talisman</a>, <a target="_blank" href="https://www.subwallet.app/">Subwallet</a> or <a target="_blank" href="https://polkadot.js.org/extension/">polkadot.js</a>. For this guide, I recommend Subwallet, because you can see the amount of ROC that you have in your wallet.</p>
</li>
</ol>
<h3 id="heading-test-and-build-the-example-smart-contract"><strong>Test and build the example smart contract 🩺</strong></h3>
<p>When you open your code, you will see an example already made in the <em>lib.rs file.</em></p>
<ol>
<li><p>Check if the tests are working with the command <code>cargo test</code>.<br /> <em>It would take a while the first time to compile all the files.</em></p>
</li>
<li><p>Build (in debug mode) the wasm file with <code>cargo contract build</code><br /> <em>It would also take a while the first time to compile all the files.</em><br /> <em>In debug mode, we would see the print lines</em> <code>ink::env::debug_println!("magic number: {}", value);</code> <em>in our node console.</em></p>
</li>
</ol>
<h3 id="heading-analyze-the-different-parts-of-the-smart-contracts">Analyze the <strong>different parts of the smart contracts 👓</strong></h3>
<p>The first line <code>#![cfg_attr(not(feature = "std"), no_std, no_main)]</code> is a conditional attribute directive used in ink! smart contracts to configure the code compilation based on whether the standard library is available or not. If the standard library is not available (<code>not(feature = "std")</code>), it instructs the compiler to compile the code without linking the standard library (<code>no_std</code>). Additionally, it specifies that the contract does not have a <code>main</code> function (<code>no_main</code>), as the entry point is provided by the ink! framework.</p>
<p>The other two lines are the opening to start writing our contract.<br /><code>#[ink::contract]</code> &amp; <code>mod state_variable {</code></p>
<pre><code class="lang-rust">    <span class="hljs-meta">#[ink(storage)]</span>
    <span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">StateVariable</span></span> {
        value: <span class="hljs-built_in">bool</span>,
    }
</code></pre>
<p>In this part of the code, we define the storage of the SC. In this default use case, there is a single boolean value.</p>
<pre><code class="lang-rust">    <span class="hljs-keyword">impl</span> StateVariable {
        <span class="hljs-meta">#[ink(constructor)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>(init_value: <span class="hljs-built_in">bool</span>) -&gt; <span class="hljs-keyword">Self</span> {
            <span class="hljs-keyword">Self</span> { value: init_value }
        }

        <span class="hljs-meta">#[ink(constructor)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">default</span></span>() -&gt; <span class="hljs-keyword">Self</span> {
            Self::new(<span class="hljs-built_in">Default</span>::default())
        }

        <span class="hljs-meta">#[ink(message)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">flip</span></span>(&amp;<span class="hljs-keyword">mut</span> <span class="hljs-keyword">self</span>) {
            <span class="hljs-keyword">self</span>.value = !<span class="hljs-keyword">self</span>.value;
        }

        <span class="hljs-meta">#[ink(message)]</span>
        <span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">get</span></span>(&amp;<span class="hljs-keyword">self</span>) -&gt; <span class="hljs-built_in">bool</span> {
            <span class="hljs-keyword">self</span>.value
        }
    }
</code></pre>
<p>Here is the implementation of the struct.</p>
<p>We would use the macro <code>#[ink(constructor)]</code> to define the constructors and the macro <code>#[ink(message)]</code> to write the public functions <code>pub</code>.</p>
<p>Later on, we have the tests inside de <code>mod tests</code></p>
<p>Each test that would be evaluated when we run <code>cargo test</code>, must start with the macro <code>#[ink::test]</code></p>
<pre><code class="lang-rust">    <span class="hljs-meta">#[ink::test]</span>
    <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">default_works</span></span>() {
        <span class="hljs-keyword">let</span> state_variable = StateVariable::default();
        <span class="hljs-built_in">assert_eq!</span>(state_variable.get(), <span class="hljs-literal">false</span>);
    }
</code></pre>
<h3 id="heading-compile-your-smart-contract">Compile your smart contract 🛞</h3>
<p>Now we can run in our terminal <code>cargo contract build --release</code>. You should see these results and have that 3 files.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687484919416/8a3ab06b-6e87-4120-8a52-d71f16a758f7.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-deploy-to-rococo">Deploy to Rococo 🛫</h3>
<p>We would deploy our contracts to "Contracts parachain", which is a substrate parachain that has installed the pallet contract. This parachain uses the Rococo relay chain's native token (<code>ROC</code>).</p>
<ol>
<li><p>You have to ask for some <code>ROC</code> in the <a target="_blank" href="https://use.ink/faucet">https://use.ink/faucet</a> to pay for the gas that will cost to upload the contract.</p>
</li>
<li><p>Navigate to <a target="_blank" href="https://contracts-ui.substrate.io/">https://contracts-ui.substrate.io/</a> and select from the combo the option: <code>Contracts (Rococo)</code></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687486231724/9d813d24-dd1c-43bb-80bd-5819ec4cd20c.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Click on "Add New Contract" and then "Upload New Contract Code".</p>
</li>
<li><p>Select your account, completed a contract name (only local information) and select the <code>.contract</code> file that you generated in the compile section.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687486458460/2621b557-5b24-4b46-a189-bf75cfa54b76.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Select the constructor that you want to call and click on "next"</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687486726526/5c78ed9d-c625-4cad-a82e-f5f8b601a83d.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Finally, click "Upload and instantiate" 🙌🏼</p>
<h3 id="heading-links">Links:</h3>
</li>
</ol>
<ul>
<li><p><a target="_blank" href="https://use.ink/t">https://use.ink/</a></p>
</li>
<li><p><a target="_blank" href="https://rtomas.hashnode.dev/polkadot-learning-path">Polkadot Learning Path</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Polkadot Learning Path 👩‍🏫]]></title><description><![CDATA[I have been exploring the Polkadot Ecosystem and there is a lot of information on the web. However, after completing the Polkadot Blockchain Academy, I…]]></description><link>https://rtomas.hashnode.dev/polkadot-learning-path</link><guid isPermaLink="true">https://rtomas.hashnode.dev/polkadot-learning-path</guid><category><![CDATA[polkadot]]></category><category><![CDATA[learning]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[dot]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Mon, 13 Mar 2023 14:53:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687546979675/0d513c7f-f9b1-4fef-b652-016011727d58.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I have been exploring the Polkadot Ecosystem and there is a lot of information on the web. However, after completing the <a target="_blank" href="https://polkadot.network/development/academy/?academy_ref_id=PBA076513T">Polkadot Blockchain Academy</a>, I realized that organizing all this information was crucial. That's why I have created a repository on Github to help others navigate the Polkadot infrastructure and understand how it differs from other blockchains.</p>
<p>Please feel free to contribute to my repository.</p>
<p>Polkadot Github Learning Path: <a target="_blank" href="https://github.com/rtomas/polkadot-learning-path">https://github.com/rtomas/polkadot-learning-path</a></p>
<hr />
<p>Last update -&gt; June 22, 2023<br />(please, always visit the link above for the last version)</p>
<h2 id="heading-cryptography">Cryptography</h2>
<p>It would be great to know cryptography before going in-depth into Polkadot. Here are some resources to get you started:</p>
<h4 id="heading-public-key-cryptography">Public key cryptography</h4>
<ol>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=GSIDS_lvRv4">Public Key Cryptography</a> [Video] (Duration: 7 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.globalsign.com/en/ssl-information-center/what-is-public-key-cryptography">What is Public-key Cryptography?</a> [Text] (Est. time: 4 minutes)</p>
</li>
</ol>
<h4 id="heading-digital-signatures">Digital signatures</h4>
<ol>
<li><p><a target="_blank" href="https://www.tutorialspoint.com/cryptography/cryptography_digital_signatures.htm">Cryptography Digital Signatures</a> [Text] (Est. time: 10 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=JR4_RBb8A9Q">What are Digital Signatures and How Do They Work?</a> [Video] (Duration: 3 minutes)</p>
</li>
</ol>
<h4 id="heading-cryptographic-hashing">Cryptographic hashing</h4>
<ol>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=IGSB9zoSx70">What is Hashing on the Blockchain?</a> [Video] (Duration: 5 minutes)</p>
</li>
<li><p><a target="_blank" href="https://learn.bybit.com/blockchain/what-is-hashing-in-blockchain/">What is Hashing in Blockchain?</a> [Text] (Est. time: 9 minutes)</p>
</li>
</ol>
<h2 id="heading-blockchain">Blockchain</h2>
<ol>
<li><p><a target="_blank" href="https://www.investopedia.com/terms/b/blockchain.asp">Blockchain Explained</a> [Text] (Est. time: 26 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=_160oMzblY8">Blockchain - A visual demo</a> [Video] (Duration: 18 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=CRe_oDtfRLw">Introduction to Libp2p</a> from 2018 but Good [Video] (Duration: 20 minutes)</p>
</li>
<li><p>Consensus</p>
<ul>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=s8Wbt0b8bwY">Two General Problem</a> [Video] (Duration: 10 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=_fgW2IM6ctM">The Byzantine Problem</a> [Video] (Duration: 8 minutes)</p>
</li>
</ul>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=hRLC6xIpIZY">Proof of Stake</a> [Video] (Duration: 10 minutes)</p>
</li>
</ol>
<h2 id="heading-polkadot">Polkadot</h2>
<h4 id="heading-theory">Theory</h4>
<ol>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=BQ60bTU1bPg&amp;t=3s">What is Polkadot?</a> [Video] (Duration: 6 minutes)</p>
</li>
<li><p><a target="_blank" href="https://wiki.polkadot.network/docs/learn-architecture">Architecture</a> [Text] (Est. time:5 minutes)</p>
</li>
<li><p><a target="_blank" href="https://wiki.polkadot.network/docs/learn-validator">Validator</a> [Text] (Est. time: 5 minutes)</p>
</li>
<li><p><a target="_blank" href="https://wiki.polkadot.network/docs/learn-parachains">Parachains</a> [Text] (Est. time: 15 minutes)</p>
</li>
<li><p>Consensus in Polkadot</p>
<ul>
<li><p><a target="_blank" href="https://wiki.polkadot.network/docs/learn-consensus">Wiki</a> [Text] (Est. time: 20 minutes)</p>
</li>
<li><p><a target="_blank" href="https://medium.com/polkadot-network/polkadot-consensus-part-1-introduction-3e3cd6237243">Introduction</a> [Text]</p>
</li>
<li><p><a target="_blank" href="https://medium.com/polkadot-network/polkadot-consensus-part-2-grandpa-fb1963ef6c70">Grandpa</a> [Text]</p>
</li>
<li><p><a target="_blank" href="https://medium.com/polkadot-network/polkadot-consensus-part-3-babe-dcc2e0dd8878">Babe</a> [Text]</p>
</li>
</ul>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=_wjAYivFQBU">Nominated Proof of Stake (NPoS)</a> [Video] (Duration: 20 minutes)</p>
</li>
<li><p><a target="_blank" href="https://wiki.polkadot.network/docs/learn-wasm">WASM</a> [Text]</p>
</li>
<li><ul>
<li><p><a target="_blank" href="https://docs.substrate.io/fundamentals/why-substrate/">Substrate Text</a> [Text]</p>
<ul>
<li><a target="_blank" href="https://www.youtube.com/watch?v=-6BBIr-DmI4">Substrate Video</a> [Video]</li>
</ul>
</li>
</ul>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/live/-6BBIr-DmI4?feature=share&amp;t=1352">Forkless Upgrades in Polkadot</a> [Video]</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=tBvxn8WfcFI">Polkadot OpenGov</a> [Video] (Est. time: 45 minutes)</p>
</li>
<li><p>Light clients</p>
<ul>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=4x4PD9ihCvw">Browser-embedded light clients</a> [Video] Duration 9min</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=oaidhA5eL_8">Talisman: Powering the Paraverse with Light Clients</a> [Video]</p>
</li>
</ul>
</li>
<li><p><a target="_blank" href="https://wiki.polkadot.network/docs/learn-xcm">XCM</a> [Text] (Est. time: 30 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.blake2.net/">Blake2 vs Sha2</a> [Text] (Est. time: 5 minutes)</p>
</li>
<li><p><a target="_blank" href="https://www.twitch.tv/videos/1737983583">Zombienet</a> [Video] (Est. time: 1 hour)</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/live/_J6BsbOaedw?feature=share&amp;t=254">Ink! 101</a> [Video]</p>
</li>
<li><p><a target="_blank" href="https://727-ventures.github.io/openbrush-contracts/evm-wasm-smart-contracts">EVM vs Wasm Smart Contracts</a> [Text]</p>
</li>
<li><p>Blockspace over Blockchain</p>
<ul>
<li><p><a target="_blank" href="https://www.rob.tech/polkadot-blockspace-over-blockchains/">Blockspace over Blockchain</a> [Text]</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=AEqOQQ5MHKk">Blockspace over Blockchain</a> [Video]</p>
</li>
</ul>
</li>
</ol>
<h4 id="heading-extras">Extras</h4>
<ol>
<li><p><a target="_blank" href="https://polkadot.network/development/academy/?academy_ref_id=PBA076513T">Polkadot Blockchain Academy</a></p>
</li>
<li><p><a target="_blank" href="https://eprint.iacr.org/2020/641.pdf">Overview of Polkadot and its Design Considerations</a> [Text]</p>
</li>
<li><p><a target="_blank" href="https://www.edx.org/course/introduction-to-polkadot">EDX Free Online Course "Introduction to Polkadot"</a> [Video]</p>
</li>
<li><p><a target="_blank" href="https://spec.polkadot.network/">Polkadot Protocol Specification</a> [Text]</p>
</li>
<li><p><a target="_blank" href="https://wiki.polkadot.network/">Polkadot Wiki</a> [Text]</p>
</li>
<li><p><a target="_blank" href="https://www.twitch.tv/polkadotdev">Twitch Channel</a> [Video]</p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/@PolkadotNetwork">Youtube Channel</a> [Video]</p>
</li>
<li><p><a target="_blank" href="https://polkadot.network/development/academy/">Polkadot Blockchain Academy</a> [Info]</p>
</li>
<li><p><a target="_blank" href="https://rtomas.hashnode.dev/polkadot-blockchain-academy-experience">My Experience with Polkadot Blockchain Academy</a> [Text]</p>
</li>
</ol>
<h4 id="heading-reference">Reference</h4>
<ul>
<li>Pre-requisites &amp; Bitcoin from <a target="_blank" href="https://github.com/protofire/blockchain-learning-path/">Protofire github</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[⛓ Polkadot Blockchain Academy Experience 🎓]]></title><description><![CDATA[I believe my journey with the academy started with the Decoded event in Buenos Aires 2022. I was working with Gabriel, and during one of our meetings, we…]]></description><link>https://rtomas.hashnode.dev/polkadot-blockchain-academy-experience</link><guid isPermaLink="true">https://rtomas.hashnode.dev/polkadot-blockchain-academy-experience</guid><category><![CDATA[Rust]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[polkadot]]></category><category><![CDATA[learning]]></category><dc:creator><![CDATA[Tomas Rawski]]></dc:creator><pubDate>Fri, 17 Feb 2023 15:39:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676726661771/d92d4284-d909-4b6b-be1e-12c7e2765393.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I believe my journey with the academy started with the Decoded event in Buenos Aires 2022. I was working with Gabriel, and during one of our meetings, we decided to explore what was going on in the Polkadot Ecosystem.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1676569085750/a05a9c40-0892-476c-a2de-39fc6bff361e.png" alt="University of Law (UBA) in Buenos Aires, Argentina" class="image--center mx-auto" /></p>
<center><b>Image 1: With friends in the Decoded Buenos Aires 2022 </b></center>

<p>I remember three awesome talks pretty well today: two from Argentinian guys, that were working at Parity, Santiago Balaguer and Javier Viola. The 3rd talk was from Gavin Wood and blow my mind 🤯 . He talked about OpenGov.</p>
<p>I have always read about governance in different Ethereum protocols and that talk inspired me to continue watching to Polkadot ecosystem.</p>
<p>Later, I received an email about the academy that was going to take place in Argentina (my home country 🇦🇷 ) and started to think, that was a great opportunity to learn more about Polkadot and blockchain in general. The only problem was that I had to learn Rust in only 2 months 😂 .</p>
<p>After a few weeks of applying, I had the interview with Tim from Parity and later on, I received the exam. The exam was challenging, but the tests already made, make easier for me to learn while I was doing it and validating the code. I have to say that in my dev career, I was very used to learning new things in a pretty small time, so I even enjoyed finishing the exam.</p>
<p>Later on, I was accepted at the academy 🙌🏼  !!! I took a summer vacation with my family before beginning at the University of Law in Argentina, because I knew the academy would be very demanding.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1676570028873/bcc11b82-a113-48e7-8b5a-d9b190cd6efe.png" alt="University of Law (UBA) in Buenos Aires, Argentina" class="image--center mx-auto" /></p>
<center><b>Image 2: University of Law (UBA) in Buenos Aires, Argentina</b></center>

<p>During the first week, we had classes about cryptography, economics and game theory from Gavin Wood! I have to say that he is a great teacher, and the classes were incredible because we asked a lot of questions, and he was enthusiastic about teaching and answering everything in detail!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1676570990502/07914789-a874-4ebe-9543-f92abda9f306.png" alt class="image--center mx-auto" /></p>
<center><b>Image 3: On the first day when we all met each other</b></center>

<p>We also had our first exercise, which was very difficult. I stayed up for two nights trying to solve it 😡 !</p>
<p>The co-work and chill space was amazing, and we had incredible breakfasts, lunch, and snacks. We only had to focus on studying, doing assignments, and networking!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1676571070790/10111868-40ea-4b90-9f10-8441fa122b4f.jpeg" alt class="image--center mx-auto" /></p>
<center><b>Image 4: All in the classroom</b></center>

<p>We had five fantastic weeks with days that we stayed at the university from 9 am to 6 pm with lessons, and then some side events until 10 pm or midnight. Yeah...</p>
<p><code>🔥 It was intense! VERY intense 🔥</code></p>
<p>But it was worth it. Not only for what we learned but also for the incredible people we met along the way 🧉.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1676571127203/cf72c8f9-9588-450b-ae00-7d75f7d8683d.jpeg" alt class="image--center mx-auto" /></p>
<center><b>Image 5: Best team ever from the PBA 2023!</b></center>

<p>We also had lessons with Rob Habermeier and the core team of Parity, like Shawn or Kian. They and other Parity and W3F developers were in the common spaces every week to share chats or discuss specific Polkadot topics. (You can view the full curriculum in the <a target="_blank" href="https://polkadot.network/development/academy/?academy_ref_id=PBA076513T">academy link</a>)</p>
<p>We had 4 assignments during the academy, and each one was related to the topics we learned during the week. They were very challenging in particular the 3rd one where we built a Pallet with substrate.</p>
<p>If you are trying to enter the web3 space or you are already on it but want to go more in-depth, learn Rust 🦀, substrate and ink! Please, Don’t hesitate and let this opportunity pass you by 🛤.</p>
<p>You can have the best teachers in the ecosystem, willing to teach you and you only have to pay for your flight trip 🛫 !</p>
<p>Please feel free to contact me through LinkedIn if you have any questions.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1676571155609/261133f2-dbbc-4fac-896e-352638a6e3ad.jpeg" alt class="image--center mx-auto" /></p>
<center><b>Image 6: Final party at the University of Law 🕺🏻</b></center>

<p>Links from Polkadot:</p>
<ul>
<li><p>Polkadot Academy + <a target="_blank" href="https://polkadot.network/development/academy/?academy_ref_id=PBA076513T">https://polkadot.network/development/academy/</a></p>
</li>
<li><p><a target="_blank" href="https://substrate.io/">https://substrate.io/</a></p>
</li>
<li><p>Rust + <a target="_blank" href="https://doc.rust-lang.org/book/">https://doc.rust-lang.org/book/</a></p>
</li>
</ul>
<p>Personal Links:</p>
<ul>
<li><p><a target="_blank" href="http://www.tomasrawski.com.ar">http://www.tomasrawski.com.ar</a></p>
</li>
<li><p><a target="_blank" href="https://www.linkedin.com/in/tomas-rawski/">https://www.linkedin.com/in/tomas-rawski/</a></p>
</li>
<li><p><a target="_blank" href="https://www.instagram.com/tomas.rawski/?hl=es">https://www.instagram.com/tomas.rawski/</a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>