<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by tzztson on Medium]]></title>
        <description><![CDATA[Stories by tzztson on Medium]]></description>
        <link>https://medium.com/@tzztson?source=rss-12651ec12715------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dFLtwXDiH1x307ehNYSm5A.png</url>
            <title>Stories by tzztson on Medium</title>
            <link>https://medium.com/@tzztson?source=rss-12651ec12715------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:53:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tzztson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Smart Contract — An Introduction]]></title>
            <link>https://tzztson.medium.com/smart-contract-an-introduction-1cb7fa7e119d?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cb7fa7e119d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 00:26:41 GMT</pubDate>
            <atom:updated>2024-03-10T00:26:41.990Z</atom:updated>
            <content:encoded><![CDATA[<h3>Smart Contract — An Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*BC4PmmPxWt5XhpciqIZwMQ.jpeg" /></figure><p>Before you start reading this article, you should have a basic understanding of how blockchain works.</p><p>In general, a contract is an agreement made between <strong>two or more parties</strong> who abide by the terms listed in it. It usually takes the form of a detailed document with several clauses and conditions that are signed on by all parties. Usually, these contracts are <strong>enforceable by law</strong> and written in human language.</p><p>Contracts are <strong>everywhere</strong> in our lives; for example, if you’re leasing or renting a home, you sign a lease agreement. When you accept an offer to a new job, you are signing an employment contract. Whenever you go shopping and want to return a product, the employees look into the return policy, which is a contract. Any insurance or financial agreements are also contracts.</p><p>In this article, I’ll go over everything you need to know to be well acquainted with smart contracts.</p><p>So, let’s look into each of the follow topics:</p><ul><li><strong>What They Are</strong></li><li><strong>A Brief History</strong></li><li><strong>How They Work</strong></li><li><strong>Benefits/Advantages</strong></li><li><strong>Limits/Disadvantages</strong></li><li><strong>Applications</strong></li><li><strong>The Future of Smart Contracts</strong></li><li><strong>Sample Smart Contract</strong></li><li><strong>Additional Reading/Sources</strong></li></ul><h3>What They Are</h3><p>Smart contracts are <strong>rule-based computer programs</strong> that can make decisions based on the conditions built into them. These programs can automatically verify, control, and execute an agreement. For example, they can transfer digital assets between parties when certain conditions are met. This code enforces the contract whereas traditional contracts are enforceable by law.</p><p>The way I like to think of smart contracts is like vending machines. Essentially, when you’re running the code of a smart contract, <strong>you’re choosing which functions to execute</strong>, or which items to obtain from the vending machine. Sometimes these operations require <strong>monetary compensation</strong> to pay for Gas fees (which I will explain in a later section of this article), or other times they may be free (which depends on the type of smart contract it is).</p><h3>Dapps</h3><p>A lot of people interchangeably use the terms smart contracts and decentralized applications (Dapps), but this is incorrect. A smart contract is simply a piece of code that is stored on the blockchain. A Dapp, however, connects the frontend to the backend and <strong>may use several smart contracts to run</strong>.</p><h3>Examples of Smart Contracts/Dapps</h3><p>An example of a smart contract could be one used in the field of voting for elections. It could count the number of votes towards each party and then make a final decision on who won. This smart contract would be immutable, meaning nobody would be able to change it, making it <strong>entirely trustworthy</strong>.</p><p>A huge example of a Dapp that you may have heard of, is MakerDAO. It is essentially a financial system where you can lend and borrow money using cryptocurrencies. MakerDAO has a frontend that communicates with the backend and uses several smart contracts.</p><h3>A Brief History</h3><p>The original idea of a smart contract on a distributed ledger was envisioned by Nick Szabo, a cryptographer, in 1994. By “smart contract” he meant a set of promises written digitally, including protocols which the parties perform on their promises. However, the term “smart contract” was rarely used until 2008, when Satoshi Nakamoto introduced the concept of Bitcoin.</p><p>Later in 2015, the concept of smart contracts was popularized by Ethereum, and in the present day, they are being used for a variety of tasks.</p><h3>How They Work</h3><p>Smart contracts are composed of <strong>three components:</strong> the parties, the subject of the contract, and the terms or conditions that apply to it. Each smart contract is put onto the blockchain that is broadcasted to the entire network and has an address. This code is executable on <strong>every node in the network</strong>.</p><p>Each node has the history of all smart contracts, the history of all transactions, and the current state of all smart contracts.</p><p>A Dapp is an interface for people to interact with a smart contract. It consists of the frontend and API to interact with the smart contract(s). A smart contract provides a way for a Dapp to interact with the blockchain.</p><p>Below are some concepts that help understand how smart contracts are best suited to the Ethereum platform.</p><h3>Turing-Completeness</h3><p>Bitcoin uses a programming language called Bitcoin Script, whereas Ethereum uses Solidity. One big difference between these two languages is that <strong>Bitcoin Script is not a Turing-Complete language, unlike Ethereum’s Solidity, which is Turing-Complete</strong>. A programming language is considered to be Turing-Complete when it is possible to program any logic into it, including loops.</p><p>Bitcoin Script doesn’t support the use of loops, for an obvious reason — it would slow down the entire blockchain if an infinite or computationally demanding loop is put into the system. So, by design, loops were not included in Bitcoin Script.</p><p>But Ethereum’s Solidity does support loops, so how does Ethereum handle the problem of the blockchain slowing down? Vitalik Buterin came up with an ingenious solution to this problem.</p><h3>Gas, Gas, Gas…</h3><p>Vitalik introduced the concept of Gas, which is a fee that the developer of the smart contract has to pay for executing <strong>any operation</strong> on the Ethereum platform. It encourages programmers to make their smart contracts as<strong> efficient as possible</strong> so they pay the least fee possible. If someone writes very inefficient code, or, worst-case, an infinite loop in the smart contract, it may slow the network down temporarily, until the developer of the smart contract runs out Gas. This structure allows Solidity to use loops while keeping the blockchain running smoothly.</p><p>The unit for measuring Gas prices is Wei. Every operation run on a smart contract is translated into the number of Wei consumed and charged to the developer. One Wei is 10^-18 of Ether, or <strong>one quintillionth</strong> of one Ether, the cryptocurrency used on the Ethereum blockchain.</p><p>If you would like to see which operations consume how much Wei, take a look at <a href="https://docs.google.com/spreadsheets/d/1n6mRqkBz3iWcOlRem_mO09GtSKEKrAsfO7Frgx18pNU/edit#gid=0">this spreadsheet.</a></p><h3>Ethereum Virtual Machines</h3><p>A smart contract runs on every single computer in the network. What if a smart contract is written maliciously to infect computers? What if they could access your personal files or even turn on your webcam? How do we address this security concern?</p><p>Ethereum Virtual Machines (EVMs) effectively solve this problem. When you participate in the Ethereum network, an EVM gets installed on your computer. The EVM completely encapsulates everything that runs on the blockchain and isolates it from the machine it’s running on. The EVM acts like a <strong>computer within your computer</strong>, and nothing can escape from the EVM onto your actual computer. In fact, EVMs are completely unaware of anything outside of it, which also adds to its several layers of security, guaranteeing that everything happening on the EVM, stays on the EVM.</p><h3>Benefits/Advantages</h3><p>Below are a few advantages of using smart contracts over traditional, physical contracts.</p><p><strong>Removes Intermediaries: </strong>Smart contracts remove the needs for intermediaries and allow direct and transparent relationships between all involved parties.</p><p><strong>Efficiency: </strong>Smart contracts use software code to automate tedious tasks and related paperwork, thus saving time and money. This automation of tasks also helps avoid human error.</p><p><strong>Security: </strong>As documents are stored in encrypted form on an immutable ledger, they are highly secure with a low probability of misuse or tampering. Because the data is stored in chronological order, tracking the audit trail becomes very easy.</p><p><strong>Decentralization: </strong>Because your data is stored on all nodes on the network, even though one node goes down or fails, the other nodes can back it up.</p><h3>Limits/Disadvantages</h3><p>While smart contracts come with some awesome advantages, there are certainly some aspects that have to be worked on.</p><p><strong>Lack of International Recognization: </strong>Decentralized transactions without third parties are not lawfully recognized in several countries. Also, the laws are still not matured enough where they are recognized. This lack of regulation makes its full adoption difficult.</p><p><strong>Immutable: </strong>As soon as a smart contract is put onto the blockchain, it cannot be changed. There is less flexibility in situations such as addressing a bug in a smart contract or a future need to change the code in the smart contract. The only way for you to change the code would be for you to add a new copy of the smart contract onto the blockchain.</p><p><strong>New Technology: </strong>This technology is still relatively new, and its implications are still not fully assessed in several of its use cases. So, it still needs to gain a wider trust as it becomes more mature.</p><h3>Applications</h3><p>Smart contracts have the potential to be used in <strong>almost every aspect of our lives</strong> — in healthcare, in finance/banking, in industries, in real estate, and in governments and private sectors.</p><p>Below are a few applications of smart contracts.</p><h3>Banking/Insurance</h3><p>Many projects are being developed that are looking to transform banking to run on blockchain technology. These projects, that are mainly Dapps, such as Meld and MakerDAO, will inherently need smart contracts to eliminate the need for the intervention of a third party.</p><p>In the field of insurance, smart contracts can be used for error checking, routing, and issuing payments efficiently. They achieve this by using a decentralized, immutable ledger for bookkeeping, and minimizing the risk of fraud.</p><h3>Healthcare</h3><p>Smart contracts can be used to automate payment systems for healthcare. It can record all healthcare transactions and bills on a blockchain, and create transparency between the patient, the healthcare provider, and the insurance company by creating a single view. These records could be stored in an encoded form to address data security and privacy concerns. Only those to which these records belong can access it.</p><h3>Real Estate</h3><p>Real estate transactions involve great amounts of commission to the real estate agents and fees to the lawyers who help the buyer or seller to perform the transaction to transfer the ownership of the property. These commissions and fees to the middlemen can be eliminated with the use of smart contracts.</p><p>One can build complex logic in a smart contract that ensures that all clauses of the agreement are met before the transfer of ownership occurs. These transactions will be recorded on an immutable ledger, to minimize the opportunity for fraud.</p><h3>Management</h3><p>In decentralized autonomous organizations (DAOs), smart contracts can be used to make decisions on the behalf of humans based on complex conditional logic built into them. For example, if the supply of raw material goes below a certain threshold, a smart contract can trigger an order to the supplier/manufacturer to deliver a new shipment of raw materials.</p><h3>The Future of Smart Contracts</h3><p>The adoption of smart contracts in the future depends on how well we address the challenges listed above. The simpler and more straightforward conventional contracts may be easily standardized into smart contract templates. However, the more complicated contracts that require frequent changes due to their unique nature and changing circumstances may have to stay conventional until we find common ground to address some of the above problems.</p><p>As this technology matures, we will see more and more uses of smart contracts in various aspects of our day-to-day lives.</p><h3>Sample Smart Contract</h3><p>Below is a simple code snippet from <a href="https://docs.soliditylang.org/en/v0.8.11/introduction-to-smart-contracts.html?#subcurrency-example">Solidity Docs</a> that makes a small mock cryptocurrency. I recommend checking out the Solidity Docs to see more examples.</p><pre>// SPDX-License-Identifier: GPL-3.0<br>pragma solidity ^0.8.4;</pre><p>In line 1, we identify that the code is licensed under GPL Version 3.0, and in line 2, we are specifying the version of Solidity that we’re going to use. We do this because there might be breaking changes in newer Solidity compilers, so we want to keep it at this version.</p><pre>contract Coin {<br>  address public minter;so<br>  mapping (address =&gt; uint) public balances;</pre><p>In line 4, we initialize our contract that we name <em>Coin</em>, and in line 5, we initialize an address called <em>minter</em>, but we don’t give it a value yet. Note that it also has the <strong>public</strong> tag, meaning that this variable is accessible by other contracts. In line 6, we now create a mapping called <em>balances</em>. A mapping is essentially like a key and value finder, so if you input an address into the balances variable, you will get a <em>uint</em>, or unsigned integer, which essentially means it’s not negative.</p><pre>event Sent(address from, address to, uint amount);</pre><p>Here, in line 8, we are still inside the contract, and now we’re making an <em>event</em>. An event basically allows users to see what changes have been made to the contract. An event can be emitted, signaling that it has been executed.</p><pre>constructor() {<br>    minter = msg.sender;<br>}</pre><p>In line 10, we use a <em>constructor</em>. All of the code that’s nested inside a constructor gets executed when the contract is created. In line 11, we finally define our variable, <em>minter</em>, and set its value to <em>msg.sender</em>, which is essentially the address of the account that sent a “message.”</p><pre>function mint(address receiver, uint amount) public {<br>    require(msg.sender == minter);<br>    balances[receiver] += amount;<br>}</pre><p>In line 13, a function, <em>mint</em>, is being called. This function essentially creates and sends, or mints, money to a specific address. The parameters of the function are the receiver as an address, and the amount being sent as an unsigned integer. The <em>mingt</em> function can only be called by the developer of the smart contract. In line 14, we are requiring msg.sender, the address of the account that initialized the smart contract, to be equal to the address of the minter. Then, by using our <em>balances</em> mapping, we add the amount we wanted to give, to the receiver’s account.</p><pre>error InsufficientBalance(uint requested, uint available);</pre><p>In line 18, we are defining an <em>error</em>. Errors can give information on how and why an action failed. We are passing the parameters <em>requested </em>and <em>available</em>.</p><pre>function send(address receiver, uint amount) public {<br>  if (amount &gt; balances[msg.sender])<br>      revert InsufficientBalance({<br>          requested: amount,<br>          available: balances[msg.sender]<br>      });</pre><p>In line 20, we are making a function called <em>send </em>that sends Coins to the address that called the function. In lines 21–24, we first check if the amount requested to send is greater than the balance of the person who called the function. If the condition turns out to be true, the <em>revert</em> keyword unconditionally stops all the code and gives an <em>error</em>, with the parameters of how much was requested and how much is available.</p><pre>balances[msg.sender] -= amount;<br>    balances[receiver] += amount;<br>    emit Sent(msg.sender, receiver, amount);<br>  }<br>}</pre><p>Still inside the function, if the previous condition turns out to be false, then we proceed with the next lines. Here, we are subtracting the amount of Coins sent from the sender, and we are adding that same amount to the receiver. Then, we <em>emit</em> the event, <em>Sent</em>, which tells us that the transaction was successful.</p><p>If you made it this far, thank you for reading my article. Be sure to stay safe and Happy Holidays!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cb7fa7e119d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Square Payment With Next.js]]></title>
            <link>https://tzztson.medium.com/square-payment-with-next-js-78e9ed1c980f?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/78e9ed1c980f</guid>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Wed, 12 Apr 2023 07:51:44 GMT</pubDate>
            <atom:updated>2023-04-13T03:16:34.735Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ill8SpyHYJqDJWq6" /><figcaption>Photo by <a href="https://unsplash.com/it/@christiannkoepke?utm_source=medium&amp;utm_medium=referral">Christiann Koepke</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Square has become one of the most popular payment gateways for online businesses, and for good reason — it offers a comprehensive set of payment services for merchants and customers alike.</strong></p><p>In this article, we’ll discuss what the React Payment Gateway is and how it can help you accept payments on your website.</p><h3>Getting Started</h3><p>First, Let’s create new Next.js Project with TypeScript.</p><pre>npx create-next-app@latest --ts<br># or<br>yarn create next-app --typescript<br># or<br>pnpm create next-app --ts</pre><p>With our project created, the first thing we’ll need to do is install the package is the react-square-web-payments-sdk package by running.</p><pre>npm install react-square-web-payments-sdk<br># or<br>yarn add react-square-web-payments-sdk</pre><p>React Square Web Payments SDK is a software development kit (SDK) created by Square that enables developers to quickly and easily integrate Square’s web payments solution into web applications built with React.</p><p>The most important component of this package is the PaymentForm provider, which provides us access to the web payments SDK. We can wrap our entire app with this provider to make the SDK available everywhere, or we can wrap a smaller area of our app with the provider to limit its scope. For demonstration’s sake, I’m going to put the provider in our Home component.</p><pre>import styles from &#39;../styles/Home.module.css&#39;<br>import { PaymentForm } from &#39;react-square-web-payments-sdk&#39;;<br><br>export default function Home() {<br>  return (<br>    &lt;div className={styles.container}&gt;<br>      &lt;PaymentForm<br>        applicationId=&quot;sandbox-XXXXXX&quot;<br>        cardTokenizeResponseReceived={(token, verifiedBuyer) =&gt; {<br>          console.log(&#39;token:&#39;, token);<br>          console.log(&#39;verifiedBuyer:&#39;, verifiedBuyer);<br>        }}<br>        locationId=&#39;XXXXXXXXXX&#39;<br>      &gt;<br>      &lt;/PaymentForm&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>As you can see, There are three <strong>api </strong>keys, Application ID ,Access Token , and Location ID (You can see the Access Token in the below.)</p><p>In <a href="https://developer.squareup.com/apps/">this link</a>, you can get these api keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E81ycymbIHctxMmmAImRGA.png" /></figure><p>You can get Application ID and Access Token in the Credentials .</p><p>There are two options for SandBoxand Production mode.</p><p>Square SandBox is an environment where developers can test their Square API applications and integrations without impacting live transactions and users. This allows developers to experiment and test their code with real data and API responses, without having to worry about impacting transactions or customers.</p><p>Square Production mode is the live environment for Square API applications and integrations. This is where developers can deploy their applications and integrations for customers to use. All live transactions and user-generated data is stored in the production environment. This is the environment where customers will experience the applications and integrations developed by the developer.</p><p>Then, you can get Location ID in the Locations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bxqS6-l-w_lggG4cXo8NNQ.png" /></figure><h3>Accept Credit Card Payment</h3><p>Let’s import the CreditCardcomponent from our react-square-web-payments-sdk and then add the component as a child of our PaymentForm.</p><pre><br>import {<br>  ApplePay,<br>  GooglePay,<br>  CreditCard,<br>  PaymentForm,<br>} from &quot;react-square-web-payments-sdk&quot;;<br><br>...<br><br>&lt;PaymentForm<br>  applicationId=&quot;sandbox-XXXXXX&quot;<br>  cardTokenizeResponseReceived={async (token, verifiedBuyer) =&gt; {<br>    console.log(&#39;token:&#39;, token);<br>    console.log(&#39;verifiedBuyer:&#39;, verifiedBuyer);<br>  }}<br>  locationId=&#39;XXXXXXXXXX&#39;<br>&gt;<br>  &lt;CreditCard /&gt;<br>&lt;/PaymentForm&gt;</pre><p>Now, our form should now look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*w1cor6uXkgqGcheTpVNpMA.png" /></figure><p>You can change this style to suit your demand.</p><h3>Payment Processing</h3><p>Let’s execute the below command.</p><pre>npm install square<br># or<br>yarn add square</pre><p>Within the api folder, create a new file called payment.ts. This is where we’ll write our custom endpoint to process the payment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*eIzQmKyocrUZdq44JTMu6w.png" /></figure><p>The contents of the payment.ts file are the same as below.</p><pre>import { Client } from &quot;square&quot;;<br>import { randomUUID } from &#39;crypto&#39;;<br><br>(BigInt.prototype as any).toJSON = function () {<br>  return this.toString();<br>};<br><br>const { paymentsApi } = new Client({<br>  accessToken: &quot;YOUR ACCESS TOKEN HERE&quot;,<br>  environment: &quot;sandbox&quot; as any,<br>});<br><br><br>export default async function handler(req:any, res:any) {<br>  if ( req.method === &#39;POST&#39; ) {<br>    const { result } = await paymentsApi.createPayment({<br>      idempotencyKey: randomUUID(),<br>      sourceId: req.body.sourceId,<br>      amountMoney: {<br>        currency: &#39;USD&#39;,<br>        amount: 500 as any<br>      }<br>    })<br>    console.log(result);<br>    res.status(200).json(result);<br>  } else {<br>    res.status(500).send();<br>  }<br>}</pre><h3>Sending the POST Request</h3><p>To send our POST request, we’ll use the Fetch API and include our token in the body of our request.</p><p>The contents of the index.tsx file are the same as below.</p><pre>import { PaymentForm, CreditCard } from &#39;react-square-web-payments-sdk&#39;;<br><br>export default function Home() {<br>  return (<br>    &lt;div className={styles.container}&gt;<br>      &lt;PaymentForm<br>        applicationId=&quot;sandbox... YOUR APPLICATION ID HERE&quot;<br>        cardTokenizeResponseReceived={async (token, verifiedBuyer) =&gt; {<br>          const response = await fetch(&quot;/api/payment&quot;, {<br>            method: &quot;POST&quot;,<br>            headers: {<br>              &quot;Content-type&quot;: &quot;application/json&quot;,<br>            },<br>            body: JSON.stringify({<br>              sourceId: token.token,<br>            }),<br>          });<br>          console.log(await response.json());<br>        }}<br>        locationId= &quot;YOUR LOCATION ID HERE&quot;<br>      &gt;<br>        &lt;CreditCard /&gt;<br>      &lt;/PaymentForm&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><h3>Conclusion</h3><p>We’ve just built out an end-to-end payment processing flow that accepts credit cards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zExwYtPnXK_olROD1ZlRNw.png" /></figure><p>You can check the result <a href="https://developer.squareup.com/apps">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cLYvvue-4lVEMpZXUtE5pA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtznjtCXSLw0F81Ov8V0FA.png" /></figure><p>I appreciate your consideration and hope that it will be of assistance to you.</p><p><a href="https://github.com/tzztson/square-with-next.js">Here is my GitHub repo link.</a></p><p>Thank you very much :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78e9ed1c980f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write a winning bid]]></title>
            <link>https://tzztson.medium.com/how-to-write-a-winning-bid-f29ee9015df6?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/f29ee9015df6</guid>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 02:30:58 GMT</pubDate>
            <atom:updated>2023-04-14T05:45:34.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jgeujpuOp00_SKnm" /><figcaption>Photo by <a href="https://unsplash.com/@krakenimages?utm_source=medium&amp;utm_medium=referral">krakenimages</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Now, there are many, too many freelancers who work on freelancing websites such as <a href="https://www.fiverr.com/">Fiverr</a>, <a href="https://www.guru.com/">Guru</a>, <a href="https://www.upwork.com/">Upwork</a>, and <a href="https://www.freelancer.com/">Freelancer</a>.</p><p>Each site has a lot of freelancers, as well as many highly-rated freelancers, so it can be very hard for a newbie freelancer to get a job from them.</p><p>Then, how can write a winning bid and get the client’s attention? What is the secret to attracting clients?</p><p>I have found 8 methods from my testing.</p><p>First, I asked 40 freelancers to create a new Upwork account. Then, I sent them the link of most recent job postings so they could bid on them.</p><p>After 2 hours of testing, I found results that were so amazing I couldn’t believe them.</p><p><strong>SECRET1: Please make client to view your proposal.</strong></p><p>Most of clients (especially who are not familiar with the project) will not read bids in the final section, so if you have written a great proposal but the client can’t see it, it is useless.</p><p>I discovered four crucial things to gather attention of clients.</p><p>Yes, there are proposals that have been sent too quickly, proposals that have been given a boost, proposals that have been highlighted, and the freelancer avatar.</p><p>Now, the client has seen your proposal, but they chose to go with another freelancer instead of you. Why do you think that happened?</p><p><strong>SECRET2: Please read client’s requirements carefully.</strong></p><p>Some clients add special words or phrases as keyword to check freelancers have read their proposal or not.</p><p>If you bid without considering client’s keywords and requirements, how will they think?</p><p>Yes, of course, they will think like this: “This is a bidding bot.”</p><p>FAILED</p><p>It is essential to pay attention to the needs of the client.</p><p>It would be beneficial if you have experience what clients want, or have already achieved tangible results that you can show to client.</p><p><strong>SECRET3: If possible, Please include client’s name in your proposal.</strong></p><p>Generally, if someone who doesn’t know you knows your name, and then uses your name in conversation with you, it makes you so glad.</p><p>It demonstrates an interest in the client and informs them that you have already done research about them. (I had a feeling I might be wrong, but the results confirmed that I was right. 😁)</p><p>If a client has a working history on Upwork, then you will have the possibility of finding his name.</p><p><strong>SECRET4: Please answer all of your client’s questions.</strong></p><p>There are such strict and demanding clients, they want to choose the best suited freelancer.</p><p>It could be your most stressful experience, but it could also be an important step in making you more professional.</p><p>If you think it is so cranky, and then ignore this, client will think you are not a suitable freelancer.</p><p><strong>SECRET5: Please provide links that are similar to what the client wants.</strong></p><p>If you can provide links to evidence of your previous work, such as your Github, StackOverflow, or Medium profiles, that would be helpful to client choose you.</p><p>Your live link that is similar to what the client is looking for makes you a strong candidate. (The most important thing is that you must prove that this is your own work, otherwise it would make you look like a scammer.)</p><p><strong>SECRET6: Don’t use template proposal.</strong></p><p>Some freelancers already have too many pre-written proposals. However, sending a template proposal does not usually meet the client’s needs.</p><p>Further, if you send a template proposal too quickly, clients will have doubts about whether you are a bot or not.</p><p>Do not submit a bid that is just a copy and paste of a template; some freelancing sites can detect this and it will indicate that you are a bot.</p><p><strong>SECRET7: Make your avatar looks good.</strong></p><p>I asked how to select a good avatar for my freelancer profile on ChatGPT.</p><p>The result is below.</p><blockquote><strong>1. A good suggestion would be to look for a photo that shows a natural, genuine smile with slightly upturned corners of the mouth.</strong></blockquote><blockquote><strong>2. Choose a professional-looking profile photo. Make sure the image is clear and in focus, and that it shows your face.</strong></blockquote><blockquote><strong>3. Choose a background image that reflects your professional goals. A graphic, a landscape, or an abstract pattern are all good options.</strong></blockquote><blockquote><strong>4. Use the same photo and bio across all of your social media accounts. This will help potential clients recognize you and make it easier for them to reach out.</strong></blockquote><p><strong>SECRET8: Make your good profile</strong></p><p>There are too many good ideas out there.<br>So the best way to go about creating an amazing profile is to look at the profiles of successful freelancers and use them as a model.</p><p><strong>In a nutshell, using kernel bids (that are neither too short nor too long) to match all client requests is the key to writing a successful winning bid.</strong></p><p>I think there are other great ways to do this that I’m not aware of. Would you be able to share them with me and provide contact information <a href="http://zhenghu61919@gmail.com/">here</a>?</p><p>Also, please give me advice about the drawbacks of my <a href="https://github.com/tzztson/chatgpt-next.js/">chatgpt</a>.</p><p>Thank you very much. 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f29ee9015df6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT bot using Next.js + Tailwind CSS]]></title>
            <link>https://tzztson.medium.com/chatgpt-bot-using-next-js-tailwind-css-7d8efd5344f0?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d8efd5344f0</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 04:08:55 GMT</pubDate>
            <atom:updated>2023-04-14T05:46:24.009Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rlw7G857m2Fh0tF4" /><figcaption>Photo by <a href="https://unsplash.com/@dkoi?utm_source=medium&amp;utm_medium=referral">D koi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fellipticalimpressivedassierat&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fellipticalimpressivedassierat&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FEllipticalImpressiveDassierat-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1912" height="932" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb4441da1b61f1895f40f40003687254/href">https://medium.com/media/bb4441da1b61f1895f40f40003687254/href</a></iframe><p>As all my friends know, I am very lazy. So I haven’t done anything these days.</p><p>When I heard about ChatGPT, I thought it might help me code more easily and comfortably.</p><p>I’m not sure how it will help me, but it was surprisingly easy to make. 😁</p><p>Let’s see how I made ChatGPT.</p><p><a href="https://tailwindcss.com/docs/guides/nextjs">Install Tailwind CSS with Next.js - Tailwind CSS</a></p><p>After installed Tailwind CSS with Next.js, then let’s make main feature of chatting.</p><p>Please replace content of index.tsx as below.</p><pre>import Head from &#39;next/head&#39;<br>import { useState, useRef, useEffect } from &#39;react&#39;<br><br>export default function Home() {<br><br><br>  const scrollContainer = useRef(null);<br><br>  const [messageText, setMessageText] = useState(&#39;&#39;);<br><br>  const [isLoading, setIsLoading] = useState(false);<br><br>  const [userChat, setUserChat] = useState&lt;string[]&gt;([]);<br>  const [botChat, setBotChat] = useState&lt;string[]&gt;([]);<br><br><br>  const botResponse = async () =&gt; {<br>    setIsLoading(true);<br>    const response = await fetch(&quot;/api/generate&quot;, {<br>      method: &quot;POST&quot;,<br>      headers: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;,<br>      },<br>      body: JSON.stringify({<br>        messageText,<br>      }),<br>    });<br>    console.log(&quot;Edge function returned.&quot;);<br><br>    if (!response.ok) {<br>      throw new Error(response.statusText);<br>    }<br><br>    // This data is a ReadableStream<br>    const data = response.body;<br>    if (!data) {<br>      return;<br>    }<br><br>    const reader = data.getReader();<br>    const decoder = new TextDecoder();<br>    let done = false;<br><br>    let botReply = &quot;&quot;;<br><br>    while (!done) {<br>      const { value, done: doneReading } = await reader.read();<br>      done = doneReading;<br>      const botMessage = decoder.decode(value);<br>      botReply += botMessage;<br>    }<br>    console.log(botReply)<br>    setBotChat([...botChat, botReply]);<br>    setIsLoading(false);<br>  }<br><br>  const handleScroll = (ref: any) =&gt; {<br>    ref.scrollTo({<br>      top: ref.scrollHeight,<br>      left: 0,<br>      behavior: &quot;smooth&quot;,<br>    });<br>  };<br><br>  const sendMessage = () =&gt; {<br>    botResponse();<br>    setUserChat((messageText.trim().length === 0) ? userChat : [...userChat, messageText]);<br>    <br>    setMessageText(&quot;&quot;);<br>  }<br><br>  const handleEnterKey = (e: any) =&gt; {<br>    if (e.key === &#39;Enter&#39; &amp;&amp; !e.shiftKey) {<br>      sendMessage();<br>    }<br>  }<br><br>  useEffect(() =&gt; {<br>    handleScroll(scrollContainer.current);<br>  }, [messageText, botChat])<br><br>  return (<br>    &lt;&gt;<br>      &lt;Head&gt;<br>        &lt;title&gt;ChatGPT BOT&lt;/title&gt;<br>        &lt;meta name=&quot;description&quot; content=&quot;Generated by create next app&quot; /&gt;<br>        &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;<br>        &lt;link rel=&quot;icon&quot; href=&quot;/favicon.ico&quot; /&gt;<br>      &lt;/Head&gt;<br>      &lt;main&gt;<br>        &lt;h1 className=&#39;py-4 text-2xl font-bold text-sky-400 text-center pt-12&#39;&gt;Next.js With ChatGPT&lt;/h1&gt;<br>        &lt;p className=&#39;py-4 text-xl font-bold text-sky-400 text-center&#39;&gt;If you discover any issue, please feel free to contact me.&lt;/p&gt;<br>        &lt;div className=&#39;bg-sky-100&#39;&gt;<br>          &lt;div className=&#39;container mx-auto px-12 max-sm:px-6 py-6 overflow-auto h-[72vh] chat-container&#39; ref={scrollContainer}&gt;<br>            {userChat.map((ele, key) =&gt; {<br>              return (<br>                &lt;div key={`blockchat-${key}`}&gt;<br>                  &lt;div key={`userchat-${key}`} className=&#39;flex flex-col gap-2 items-end justify-center&#39;&gt;<br>                    &lt;div className=&#39;bg-[#efffde] rounded-2xl px-6 py-2 max-w-[50%] break-words&#39;&gt;{ele}&lt;/div&gt;<br>                  &lt;/div&gt;<br>                  {botChat[key] &amp;&amp; &lt;div key={`botchat-${key}`} className=&#39;flex flex-col gap-2 items-start justify-center break-words&#39;&gt;<br>                    &lt;div className=&#39;bg-white rounded-2xl px-6 py-2 max-w-[50%]&#39;&gt;{botChat[key]}&lt;/div&gt;<br>                  &lt;/div&gt;}<br>                &lt;/div&gt;<br>              )<br>            })}<br>            {isLoading &amp;&amp; &lt;div className=&quot;lds-ellipsis&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;}<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br><br>        &lt;div className=&#39;container mx-auto px-12 max-sm:px-2 flex justify-center &#39;&gt;<br>          &lt;div className=&quot;relative w-1/2 flex items-start py-6 max-xl:w-full flex justify-center max-md:flex-col max-md:items-center gap-4&quot;&gt;<br>            &lt;textarea value={messageText} onChange={e =&gt; setMessageText(e.target.value)} onKeyUp={handleEnterKey}<br>              className=&quot;outline-none bg-sky-50 border border-sky-300 text-sky-900 w-full h-14 px-6 py-3&quot;<br>              placeholder=&quot;PLEASE TYPE YOUR TEXT HERE ...&quot; /&gt;<br>            &lt;button className=&#39;bg-sky-500 rounded-full text-white text-3xl font-black px-6 py-2 active:translate-y-1&#39; onClick={sendMessage}&gt;<br>              Send<br>            &lt;/button&gt;<br>          &lt;/div&gt;<br><br>        &lt;/div&gt;<br>      &lt;/main&gt;<br>    &lt;/&gt;<br>  )<br>}</pre><p>Let’s make generate.ts in the api folder.</p><pre>import { OpenAIStream, OpenAIStreamPayload } from &quot;../../utils/OpenAIStream&quot;;<br><br>type RequestData = {<br>  messageText: string;<br>};<br><br><br>if (!process.env.OPENAI_API_KEY) {<br>  throw new Error(&quot;Missing env var from OpenAI&quot;);<br>}<br><br>export const config = {<br>  runtime: &quot;edge&quot;,<br>};<br><br>let message_junk = &quot;&quot;;<br><br>const handler = async (req: Request): Promise&lt;Response&gt; =&gt; {<br>  <br>  const { messageText } = (await req.json()) as RequestData;<br><br>  message_junk += `${messageText} \n` ;<br><br>  if (!messageText) {<br>    return new Response(&quot;No prompt in the request&quot;, { status: 400 });<br>  }<br><br>  const payload: OpenAIStreamPayload = {<br>    model: &quot;text-davinci-003&quot;,<br>    prompt: message_junk,<br>    temperature: 0.7,<br>    top_p: 1,<br>    frequency_penalty: 0,<br>    presence_penalty: 0,<br>    max_tokens: 1000,<br>    stream: true,<br>    n: 1,<br>  };<br><br>  const stream = await OpenAIStream(payload);<br>  return new Response(stream);<br>};<br><br>export default handler;</pre><p>Finally, Let’s make OpenAIStream.ts in the utils folder.</p><pre>import {<br>  createParser,<br>  ParsedEvent,<br>  ReconnectInterval,<br>} from &quot;eventsource-parser&quot;;<br><br>export interface OpenAIStreamPayload {<br>  model: string;<br>  prompt: string;<br>  temperature: number;<br>  top_p: number;<br>  frequency_penalty: number;<br>  presence_penalty: number;<br>  max_tokens: number;<br>  stream: boolean;<br>  n: number;<br>}<br><br>export async function OpenAIStream(payload: OpenAIStreamPayload) {<br>  const encoder = new TextEncoder();<br>  const decoder = new TextDecoder();<br><br>  let counter = 0;<br><br>  const res = await fetch(&quot;https://api.openai.com/v1/completions&quot;, {<br>    headers: {<br>      &quot;Content-Type&quot;: &quot;application/json&quot;,<br>      Authorization: `Bearer ${process.env.OPENAI_API_KEY ?? &quot;&quot;}`,<br>    },<br>    method: &quot;POST&quot;,<br>    body: JSON.stringify(payload),<br>  });<br><br>  const stream = new ReadableStream({<br>    async start(controller) {<br>      // callback<br>      function onParse(event: ParsedEvent | ReconnectInterval) {<br>        if (event.type === &quot;event&quot;) {<br>          const data = event.data;<br>          // https://beta.openai.com/docs/api-reference/completions/create#completions/create-stream<br>          if (data === &quot;[DONE]&quot;) {<br>            controller.close();<br>            return;<br>          }<br>          try {<br>            const json = JSON.parse(data);<br>            const text = json.choices[0].text;<br>            if (counter &lt; 2 &amp;&amp; (text.match(/\n/) || []).length) {<br>              // this is a prefix character (i.e., &quot;\n\n&quot;), do nothing<br>              return;<br>            }<br>            const queue = encoder.encode(text);<br>            controller.enqueue(queue);<br>            counter++;<br>          } catch (e) {<br>            // maybe parse error<br>            controller.error(e);<br>          }<br>        }<br>      }<br><br>      // stream response (SSE) from OpenAI may be fragmented into multiple chunks<br>      // this ensures we properly read chunks and invoke an event for each SSE event stream<br>      const parser = createParser(onParse);<br>      // https://web.dev/streams/#asynchronous-iteration<br>      for await (const chunk of res.body as any) {<br>        parser.feed(decoder.decode(chunk));<br>      }<br>    },<br>  });<br><br>  return stream;<br>}</pre><p>You can also find this resource from my github.<br><a href="https://github.com/tzztson/chatgpt-next.js">https://github.com/tzztson/chatgpt-next.js</a></p><p>Thank you for your attention.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d8efd5344f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How did I create a simple Angular accordion?]]></title>
            <link>https://tzztson.medium.com/how-did-i-create-a-simple-angular-accordion-e0348dc68832?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0348dc68832</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[accordion]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Sat, 18 Feb 2023 23:09:07 GMT</pubDate>
            <atom:updated>2023-04-14T05:43:03.162Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GBlw8mG7fz4neZH4" /><figcaption>Photo by <a href="https://unsplash.com/@keyspics?utm_source=medium&amp;utm_medium=referral">JEREMY MALECKI</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s good idea to play the accordion to relax in your free time.</p><p>When I was an amateur, I didn’t know Angular framework.</p><p>At that time, I didn’t know anything except pure HTML, CSS, and JS.</p><p><strong>Then, Let’s see how I made my first Angular accordion.</strong></p><p>Of course, I’m pretty sure you’ve already built the environment.</p><pre>ng new angular-accordion</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxizJF-Q2HwA3EoLb72tXw.png" /></figure><p>For CSS, I used Tailwind CSS.<br><a href="https://tailwindcss.com/docs/guides/angular">https://tailwindcss.com/docs/guides/angular</a></p><p>“Hu, please don’t drive us crazy, we don’t have enough time to hear your babbling.”</p><p>“Absolutely, It’s really simple”.</p><p>Now, Please remove the content of “app.component.html”, then copy below code.</p><pre>&lt;h1 class=&quot;text-3xl font-bold underline&quot;&gt;<br>  Hello world!<br>&lt;/h1&gt;</pre><p>Through ‘ng serve’ command, you can check Tailwind CSS works or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKGaWHxNaP2dcp3awmAZsQ.png" /></figure><p>Now, let’s make accordion-type.ts file in the src/app holder.</p><p>Here, we will define data interface for accordion.</p><pre>export interface FAQ {<br>    visible:boolean;<br>    image:string;<br>    title:string;<br>    content:string;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NZCu53qHuMSOFqFmrXprDQ.png" /></figure><p>Then let’s replace the content of “app.component.ts” as below.<br><strong>Note</strong>: please don’t forget to add icons in the “src/app/assets/images/icons” folder.</p><pre>import { Component, OnInit } from &#39;@angular/core&#39;;<br><br>import { FAQ } from &#39;./accordion-type&#39;;<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;]<br>})<br>export class AppComponent {<br><br>  faqs: FAQ[] = [<br>    {<br>      visible: true,<br>      image: &#39;/assets/images/icons/faq-plus.svg&#39;,<br>      title: &#39;What is Lorem Ipsum?&#39;,<br>      content: &#39;Consulting is unfortunately a vast industry, and business consultants operate at all levels. No matter what stage of business you&#39;re in, you want to find (and hire!) consultants who can meet you where your business is at.  doing so.&#39;<br>    },<br>    {<br>      visible: false,<br>      image: &#39;/assets/images/icons/faq-plus.svg&#39;,<br>      title: &#39;Why do we use it?&#39;,<br>      content: &#39;Consulting is unfortunately a vast industry, and business consultants operate at all levels. No matter what stage of business you&#39;re in, you want to find (and hire!) consultants who can meet you where your business is at.  doing so.&#39;<br>    },<br>    {<br>      visible: false,<br>      image: &#39;/assets/images/icons/faq-plus.svg&#39;,<br>      title: &#39;Where does it come from?&#39;,<br>      content: &#39;Consulting is unfortunately a vast industry, and business consultants operate at all levels. No matter what stage of business you&#39;re in, you want to find (and hire!) consultants who can meet you where your business is at.  doing so.&#39;<br>    },<br>    {<br>      visible: false,<br>      image: &#39;/assets/images/icons/faq-plus.svg&#39;,<br>      title: &#39;Where can I get some?&#39;,<br>      content: &#39;Consulting is unfortunately a vast industry, and business consultants operate at all levels. No matter what stage of business you&#39;re in, you want to find (and hire!) consultants who can meet you where your business is at.  doing so.&#39;<br>    },<br>  ]<br>  openMessage(index: number) {<br>    this.faqs.map(ele =&gt; {<br>      ele.visible = false;<br>      ele.image = &#39;/assets/images/icons/faq-plus.svg&#39;;<br>    });<br>    this.faqs[index].visible = true;<br>    this.faqs[index].image = &#39;/assets/images/icons/faq-minus.svg&#39;;<br>  }<br>}</pre><p>Almost done, we’re almost there. 🥱<br>Let’s replace the content of “app.component.html” as below.</p><pre>&lt;div class=&quot;flex flex-col container mx-auto py-12 px-12 max-sm:px-6&quot;&gt;<br>  &lt;div *ngFor=&quot;let faq of faqs; let indexOfelement=index;&quot;<br>    class=&quot;border-b-2 border-[#001F691A] py-2 flex flex-col gap-4&quot;&gt;<br>    &lt;div class=&quot;flex justify-between gap-4&quot; (click)=&quot;openMessage(indexOfelement)&quot;&gt;<br>      &lt;p class=&quot;text-[#00171B] text-xl font-medium&quot;&gt;{{faq.title}}&lt;/p&gt;<br>      &lt;img src={{faq.image}} alt=&quot;&quot; /&gt;<br>    &lt;/div&gt;<br>    &lt;p *ngIf=&quot;faq.visible&quot; class=&quot;text-[#00171BB2] text-lg font-normal&quot;&gt;{{faq.content}}&lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fwellinformedkaleidoscopicdamselfly&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fwellinformedkaleidoscopicdamselfly&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FWellinformedKaleidoscopicDamselfly-size_restricted.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=gfycat" width="1880" height="876" frameborder="0" scrolling="no"><a href="https://medium.com/media/452f306f43c90f886430f65bd0273e19/href">https://medium.com/media/452f306f43c90f886430f65bd0273e19/href</a></iframe><p>Looks good? 😀😀😀<br>ThanQ very very much. 🙆‍♂️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0348dc68832" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Destructuring Array & Object]]></title>
            <link>https://tzztson.medium.com/destructuring-array-object-94dd4a86b57e?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/94dd4a86b57e</guid>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[destructuring]]></category>
            <category><![CDATA[concept]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Wed, 08 Feb 2023 11:09:23 GMT</pubDate>
            <atom:updated>2023-04-14T05:37:48.361Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Any fool can write code that a computer can understand. <br>Good programmers write code that humans can understand.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TxHs_Dwts25AF5xP" /><figcaption>Photo by <a href="https://unsplash.com/@balazscsaba2006?utm_source=medium&amp;utm_medium=referral">Csaba Balazs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Destructuring assignments can make code easier and more understandable.</p><p>You can’t write awesome code if you don’t know about pretty JavaScript syntax.<br>JavaScript helps to create understandable code.<br>Now, let’s see how to write destructuring assignments.</p><h3>Array Destructuring</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*BHs9_9sMCBaX6jLs1ww5tw.png" /></figure><p>It allow us to work with variables instead of array members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*UGjE6TaliQlMica9OAI8Tw.png" /></figure><p>In the code above, the second and third elements of the array are skipped, the fourth element is assigned to the title, and the rest of the array items are also skipped (because there are no variables).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ie3FdPiHLjmJOZM_8Gmnfg.png" /></figure><p>The code above shows that we can also use destructuring array for objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*JE4MgB1lab7MyW8zDOE8ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Xq3uX-TYkx8nYQ23wkHTAQ.png" /></figure><p>Oh sorry, 😓 what happened?</p><p>I didn’t know “<strong><em>[developer, client] = [client, developer]</em></strong>;” works.</p><p>new Array(100).fill().map((_) =&gt; console.log(`Boss, I am really sorry. 🙏`));</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*kmUgUc9DYf5Hp4PawX0Gzw.png" /></figure><p>Boss, asked me, “Hu, how many developers in our team?”</p><p>Hmm, 🧐🧐🧐 too many devs.<br>So, how many developers are in our team?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*OxXr3uC9ruqoxwkJVh2CUQ.png" /></figure><p>That’s perfect answer, right? 😁</p><h3>Object Destructuring</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*xzIpKv2YLxDde-Td03VYmQ.png" /></figure><p>Not only Array, we can also use destructuring assignment in Object.</p><p>“Hu, 😪I wanna use short names.”<br>“okay okay. you beat me. it’s for you.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*BheHV5potOOxTUR2wgaBtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*omFB8PJbThKi_k-IH4HX_g.png" /></figure><p>“Hu, what made you foolish?”<br>“Oh, no, 🤯 Don’t look down on me! Just see! ”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*ZTadQANTVZMTuUYvcxRqzQ.png" /></figure><p>Almost Done,</p><h3>Smart Function Parameters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*NHZyZxigdR56HLopebq66g.png" /></figure><p>If you are not an amateur, you mustn’t use above ugly code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*juxgTmNyV7rsqwJbie7RMw.png" /></figure><p>Use like this.</p><p>I will end the article here. Thank you for your interest. 🙆‍♂️🙆‍♂️🙆‍♂️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94dd4a86b57e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to handle Smart Contract using ethers.js and node.js]]></title>
            <link>https://tzztson.medium.com/how-to-handle-smart-contract-using-ethers-js-and-node-js-4070f9399328?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/4070f9399328</guid>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Fri, 03 Feb 2023 07:23:30 GMT</pubDate>
            <atom:updated>2023-04-14T05:33:30.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ud0NExW4zfiyB_4b" /><figcaption>Photo by <a href="https://unsplash.com/@thisisengineering?utm_source=medium&amp;utm_medium=referral">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently, I’ve worked on Paypal gateway integration project.</p><p>The main goal of project is when people buy crypto token using paypal.</p><p><strong>How do I think</strong></p><p>At first, I cannot find method how to do.</p><p>Why need to but token using paypal, cryptocurrency isn’t enough?</p><p>But I don’t have any method to do this, because it’s client demand.</p><p>Below are simple code I did.</p><h3>Let’s install ethers.js</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*uyDqpZAqKgwven5jA1KD3g.png" /></figure><p>For convenience, I imported the contract address into abi.json.</p><p>Therefore, the contract abi and contract address exist in the abi.json file.</p><p>I used Infura_id for georli rpc link, you can use this Infura_id directly.</p><p>(This is not a recommended method for the security of development. I used this method for user convenience. Do not use Infura_id like me. It is dangerous method. 🙅‍♂️)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*5GdyktiM82fN6nUv2hViWA.png" /></figure><p>Private_key is used directly in the file.</p><p>It would be used to configure the contract and use contract functions.</p><h3>Now, Let’s create Contract!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*rBcEl1i7zlGOGxr3jXzwKw.png" /></figure><p>You may be wondering why need a Wallet Private_key.<br>Because I didn’t write that above code.</p><p>Be patient! 😣 We’re almost there.</p><h3>Let’s see why need Wallet Private_key.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*Uf-6kEyr5eYr73PduapeCA.png" /></figure><p>Yes, right, that is it.</p><p><strong>Wallet Private_key is used to execute Contaract funcitons.</strong></p><p>It allows us to <strong>transfer </strong>tokens and <strong>claim </strong>tokens.</p><p>Source is existing in my Github.</p><p><a href="https://github.com/tzztson/node-handle-smart-contracts">GitHub - tzztson/node-handle-smart-contracts</a></p><h4>Thank you for your attention! 🙆‍♂️</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4070f9399328" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sudoku for improving your IQ]]></title>
            <link>https://tzztson.medium.com/is-sudoku-really-crazy-game-972aa6aac46?source=rss-12651ec12715------2</link>
            <guid isPermaLink="false">https://medium.com/p/972aa6aac46</guid>
            <dc:creator><![CDATA[tzztson]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 09:59:09 GMT</pubDate>
            <atom:updated>2023-04-14T05:34:11.429Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TZy1qqVhxRxeWxzK" /><figcaption>Photo by <a href="https://unsplash.com/@bkaraivanov?utm_source=medium&amp;utm_medium=referral">Bozhin Karaivanov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Maybe, it is not difficult than you think.<br>It is easier said than done???</p><h3>The History of Modern Sudoku</h3><blockquote>The modern Sudoku was most likely designed anonymously by Howard Garns, a 74-year-old retired architect and freelance puzzle constructor from Connersville, Indiana, and first published in 1979 by Dell Magazines as Number Place (the earliest known examples of modern Sudoku).</blockquote><h3><strong>Why Sudoku is popular?</strong></h3><blockquote>Sudoku is stands for “Sūji wa dokushin ni kagiru”.</blockquote><blockquote>Sudoku is highly beneficial for kids because it helps them to recognize errors quickly, rationalize, and develop problem-solving skills. This will help them stand out in class and the workplace when they grow older.</blockquote><blockquote>The logical structure of the game means that Sudoku is relatively simple and easy to learn how to play. Because Sudoku is a “numbers game” based on numbers instead of letters, it’s a broadly appealing game that can be played by people in many cultures and countries.</blockquote><h3>Main Rule of this Crazy Game</h3><blockquote>Rule 1 — Each row must contain the numbers from 1 to 9, without repetitions. …</blockquote><blockquote>Rule 2 — Each column must contain the numbers from 1 to 9, without repetitions. …</blockquote><blockquote>Rule 3 — The digits can only occur once per block (nonet) …</blockquote><blockquote>Rule 4 — The sum of every single row, column and nonet must equal 45.</blockquote><h3>Can you be the Sudoku Winner?</h3><blockquote>Of course, If you try more &amp; more, you can possibly surpass <a href="https://en.wikipedia.org/wiki/Thomas_Snyder">Thomas Snyder.</a> 83.93s<br>According to Guinness World Records, the fastest time to complete a “Very Easy” difficulty Sudoku puzzle was 83.93 seconds. The record was set on May 20, 2006 by Thomas Snyder, an American Sudoku champion. How does Thomas Snyder solve Sudoku puzzles so fast?<br>Reason is simple — It is to find the secret.<br>He may know lots of Sudoku secrets through his research and experience.</blockquote><h3>The Secret That I found :)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*EkUy305ksVImQya7JG-ShQ.png" /><figcaption>figure 1–1 Captured from <a href="https://sudoku.com/">https://sudoku.com/</a></figcaption></figure><h4>Secret 1: Please implement your guess using Notes.</h4><blockquote>In sudoku puzzle, you can denote your guess in each cell of sudoku matrix.</blockquote><h4>Secret 2: Erase will be helpful to determine correct selection.</h4><blockquote>Please press Number “0” of your Keyboard or press “Erase” key to make empty cell.</blockquote><h4>Secret 3: You need to memorize sum of numbers in Sudoku Killer.</h4><blockquote>Sudoku Killer is also a popular number puzzle game that may be easier than the Classic Sudoku puzzle.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*6EMEc4jIIhS7t4CKldsPew.png" /><figcaption>figure 1–2 Captured from <a href="https://sudoku.com/killer/expert/">https://sudoku.com/killer/expert/</a></figcaption></figure><blockquote>As you can see, The only numbers that add up to 4 are 1 and 3.<br>Also, in case of 17, only 8 &amp; 9.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*HXOVwzYLgPqHKWiOnCF2Tg.png" /><figcaption>figure 1–3 Sudoku Killer cases.</figcaption></figure><blockquote>You can get the source of this puzzle case from <a href="https://github.com/tzztson/sudoku-case-recursive">https://github.com/tzztson/sudoku-case-recursive</a></blockquote><h4>Thank you for your reading, it was my noble or humble article :D</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=972aa6aac46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>