<?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[Cleverse, a Web3 Focused Venture Builder - Medium]]></title>
        <description><![CDATA[Cleverse, a Web3 Focused Venture Builder full of people who have fun building the future. Learn more https://cleverse.com - Medium]]></description>
        <link>https://medium.com/cleverse?source=rss----6e648ae9c812---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Cleverse, a Web3 Focused Venture Builder - Medium</title>
            <link>https://medium.com/cleverse?source=rss----6e648ae9c812---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:29:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/cleverse" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Welcome to the world of Web 3.0]]></title>
            <link>https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-d16b61235dc4?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/d16b61235dc4</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[Aikdanai Sidhikosol]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 07:20:15 GMT</pubDate>
            <atom:updated>2022-09-27T07:20:15.830Z</atom:updated>
            <content:encoded><![CDATA[<p>Web 3.0, dubbed the next state for the internet, is being talked about more and more as the days go by. So what is it exactly?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYS-_BjZv_fLXoXquIPwig.png" /></figure><p>To fully understand the term, we have to look at the evolution of the internet itself.</p><h3>Evolution of Web</h3><h4>Web 1.0: Read-only Internet</h4><p>The first iteration of the Web. In the Web1 ecosystem, almost all of its users are consumers of information provided by creators that developed the websites.</p><p>Mostly read-only static sites, there is almost no interaction between its users and no way for average users to provide any information back to the internet for other users. Instead, Web1 serves only as a way for site creators to put their information out there for users to consume. Nowadays, many sites still fall under this category of Web1, including our beautiful <a href="https://cleverse.com/">Cleverse Landing Page</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*cHVI0OHiXRiJb9_ijiUfXg.png" /><figcaption>The one-way street of Web 1.0</figcaption></figure><p>Checking the validity of the information is not possible; you have to take the site’s words for it, making the information manipulable by its creators. Although there might be mechanisms outside the Web1 internet to control the information, be it law or societal pressure, the point stands.</p><h4>Web 2.0: Read-and-write Internet</h4><p>The second iteration of the Web. Its main difference from Web1 is that users generate the content instead of the owner.</p><p>Now users can provide their content or interact with the internet. Giving feedback to other information becomes possible, mitigating the issues about information manipulation since the users can provide their correct information or at least point out the incorrectness, e.g., commenting on social media — though whether others believe said users is another thing.</p><p>Interacting with other systems becomes possible, such as online payment instead of paying with good ol’ cold hard cash.</p><p>Here’s an example of Web2: <a href="https://www.linkedin.com/company/cleverse">Cleverse on LinkedIn</a>, with us as the user generating the content and <a href="https://www.linkedin.com/">LinkedIn</a> as the platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*UxYmWAISX2HXpmuaDBOJVA.png" /><figcaption>The controlled two-way street of Web 2.0</figcaption></figure><p>But the problem of information manipulation still exists. Users’ comments can be censored — or getting their accounts banned. Payment service might get paused.</p><p>Also, platform owners own your registered personal information data and every transaction you have ever made in their database. And one can’t use their service without giving up said information.</p><p>With all that being said, it doesn’t mean that any of that will happen for sure; it just means it is <em>technically</em> possible<em>.</em></p><h4>Web 3.0: Read-and-write-and-own Internet</h4><p>Enter the Web3, the next iteration of the Web.</p><p>There’s no definitive meaning to the term “Web3” presented since everyone has their implications associated with it. So, I will be giving you my understanding of Web3.</p><p>Web3 is the internet where no one entity truly owns the information and the system. The information is distributed among the users, publicly available, and verifiable by anyone. In other words, it’s a decentralized, permissionless, and trustless network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*IdXWA9sGDR-8nlKkE2sCgg.png" /><figcaption>The distributed internet of Web 3.0</figcaption></figure><p>To further explain these three terms, let’s go back to a Web2 example; the payment service, or more specifically, the bank.</p><p><strong>Decentralized</strong> means that a network of computers holds the data instead of the bank holding them along with the only means to interact with your assets. You can interact with any of them to access the service. That brings us to another point: when a centralized banking service went down, got attacked, or got hacked, it rendered its entire userbase unable to do anything since it’s a single point of failure. But with decentralization, if one service provider goes down or is compromised, there are others to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*BqJuZGnUlPeAtB0GxiUtSA.png" /><figcaption>The benefit of being decentralized</figcaption></figure><p><strong>Permissionless</strong> means that instead of the bank requiring personal information and being able to choose who or when to provide the service, everyone can use the service without giving up their personal information, and no one can decide on their own to stop providing the service to anyone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*MeqcGuJl3f3y5gEyzFGAcw.png" /><figcaption>The benefit of being permissionless</figcaption></figure><p><strong>Trustless</strong> means that instead of you needing to trust the bank to be your intermediary that when you transfer funds, the recipient will receive the correct amount, and the transaction will show up on their end. Although, to be fair, Web3’s trustless doesn’t mean we can trust no one entirely. It means that we can distribute our trust that everyone participating in the network — which is governed by code — will maintain the system’s integrity instead of harming it since the network was designed so that doing so won’t benefit them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OSV5kvsksTDzGEzArN5SsQ.png" /><figcaption>The benefit of being trustless</figcaption></figure><p>To summarize, the comparison between payment service on Web2 and Web3 are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*dAY_3ACpOJD58VUlxbJKvg.png" /><figcaption>Difference between payment services in Web 2.0 and Web 3.0</figcaption></figure><p>The idea about Web3 doesn’t end here; however, concepts such as AI/Machine Learning infusion and many other things are being explored as we speak.</p><p>While it is exciting to talk about the future, for this article, I’d like to talk more about the current state of Web3. Specifically about the technology being used to make Web3 possible: blockchain.</p><h3>Blockchain</h3><p>What’s blockchain? I find this statement from Ethereum documentation most fitting to describe a blockchain:</p><blockquote>A blockchain is a public database that is updated and shared across many computers in a network. — <a href="https://ethereum.org/en/developers/docs/intro-to-ethereum/#what-is-a-blockchain">Ethereum.org</a></blockquote><p>Now, let’s break the word blockchain down further, shall we?</p><h4>What is a “Block”?</h4><p>Block is a collection of transactions stored consecutively to each other. New transactions have to be added to a new block, and only until the network confirms the block and committed to the chain that the transaction is considered completed.</p><h4>What is a “Chain”?</h4><p>A chain is an idea that each block that supposedly should be stored consecutively is immutable. Every block will cryptographically refer to its ancestor until the first “Block 0” AKA “Genesis block.” Thus blocks are <em>chained</em> together, creating a blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MyM4yZRH3jPpCSiat6u2pQ.png" /><figcaption>Simplified blockchain visualization</figcaption></figure><p>Computers — AKA nodes — in the network have to agree when a new block comes in that the transactions inside the block are legit and the block itself cryptographically refers to the latest block, and also that the chain as a whole is still correct. Only then that the new block be committed to the blockchain, thus becoming the latest block for the following block to refer to as its ancestor. (For a more elaborate explanation, please refer to <a href="https://ethereum.org/en/developers/docs/blocks/">this</a>.)</p><p>Now, you might have a question: what is <em>cryptographically refer to</em> even <em>mean</em>? Good question. Let’s dive a little deeper into how blockchain works.</p><h4>How does blockchain work?</h4><blockquote>This section might get too technical even though I did try to simplified it. Feel free to skip to the Ethereum section.</blockquote><p>Again, our old friend payment service will take place as an example.</p><p>Now, let’s start with a blank slate—the genesis block. No one has any balance in the system, and no committed transaction.</p><p>Then, Alice deposits 100 USD, and Bob deposits 50 USD. The node which Alice and Bob interacted with then added the transaction into a block.</p><p>When the node wants to commit a block, it will first have to combine the following data to generate a “hash”: the previous block’s hash, all the data within this block. You can think of this hash as each block’s identity; in a way, it’s similar to our fingerprints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*z-cTYrmR6WLuzbSlyL6a_A@2x.png" /></figure><p>The node then commits the block to the network for every other node to verify the validity of this block, and when the consensus of the network agrees that this block is valid, this block then becomes the latest block of the chain.</p><p>Then, Alice creates a transaction to transfer 20 USD to Bob. The node then creates Block 2 and commits to the blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*U1q942gB3KF6SHevso32IQ@2x.png" /></figure><p>Now, to know the current state of the blockchain, we can “replay” all the transactions ever since the genesis block to find out everyone’s balance.</p><p>What if someone wants to act maliciously by tampering with the data in the blockchain? Say, change Alice’s deposit in Block 1 from 100 USD to 110 USD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*MopfaEzAKOe9eICi0-e64Q@2x.png" /><figcaption>Tampering with the committed data.</figcaption></figure><p>This mechanism means that certain someone(Alice, I’m looking at you) would need to change every block’s hashes ever since the tampered block. Since Block 1’s data changed, Block 1’s hash has to change, and with Block 1’s hash changed, Block 2’s hash also has to change, so on and so forth.</p><p>And even after changing all the hashes accordingly, there’s still a problem the malicious actor has to overcome: how to present to the nodes in the network so that they accept this new blockchain as the correct one — it’s virtually impossible.</p><p>That’s just a <em>glimpse</em> into what an amazing technology Blockchain is.</p><blockquote>Disclaimer: This is just a <strong><em>very</em></strong> brief explanation of Blockchain. If you want to see an article going deep and technical, <a href="https://www.facebook.com/cleverse.team/">let us know</a>!</blockquote><p>Next, let’s briefly talk about Ethereum. The platform, which, I’d say, popularized and utilized blockchain technology to serve a way wider audience than <a href="https://www.investopedia.com/terms/b/bitcoin.asp">Bitcoin</a>.</p><h3>Ethereum</h3><p>Ethereum is a platform that uses blockchain as its core idea and pushes the utilization further.</p><p>There’s a single Ethereum blockchain whose state every node in the network agrees on. Each node then keeps a copy of this state on its machine.</p><p>Any node can request the network to perform any arbitrary computation (e.g., Alice sending messages to Bob, monthly paying the salary). Every node then verifies and executes such a request.</p><p>With that being said, I want to talk more about the most prominent feature of Ethereum, in my opinion: The Smart Contract.</p><h4>What is Smart Contract?</h4><p>A smart contract is a snippet of code on the Ethereum blockchain that developers can create to provide varying services like a marketplace, banking, lending, and many more.</p><p>Any user can interact with any smart contract, provided the parameters and the conditions are correct.</p><p>For example, a piggy bank smart contract that allows users to deposit Ether, withdrawable by them alone after a specific time.</p><p>Here’s an example of a series of instructions a smart contract could be doing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*J53xWCjEzkwx96lTNyiKXA.png" /><figcaption>Smart Contract implementation visualized</figcaption></figure><p>Utilizing smart contracts on Ethereum allows developers to create complex applications that satisfy the users’ needs. Thus expanding the use of blockchain to solve a wider and wider array of problems as more contracts are being developed every day.</p><h3>Let’s wrap it up</h3><p>Web 3.0 is the direction the internet is evolving toward. The main goal is the distribution of ownership from a few large organizations to many small individuals(yes — <a href="https://ethereum.org/en/developers/docs/nodes-and-clients/run-a-node/">you can be one of them!</a>), moving the trust in the organization to the consensus of people, letting the internet be accessible to everyone.</p><p>The blockchain is the most prominent technology utilized for Web 3.0 to reach those goals. Being a public database shared by a network of nodes governed by computer code, blockchain made “Decentralized”, “Permissionless”, and “Trustless” possible.</p><p>And to be able to make Web 3.0 available and valuable to people, more blockchain use cases other than cryptocurrencies need to be developed. So that’s where Ethereum came in. Being a powerful platform superpowered with Smart Contract opens up endless opportunities eagerly waiting to be created and shared!</p><blockquote>Personally, I don’t believe Web3 to be the sole future of the internet. I think it will coexist with Web1 and Web2 as they currently do. Each generation of web serve its different purposes. Also, not every application is meant to be decentralized, permissionless and trustless anyway.</blockquote><blockquote>This article’s purpose is about explaining the meaning of Web3 and its associated technology. Not to blindly suggest that Blockchain (along with Ethereum) is the silver bullet meant to solve every goal of Web3, just that it’s currently the most popular one. And who knows what technologies might be born in the future to better serve the vision of Web3.</blockquote><blockquote>I find discussing the real-world practicality of Web3/Blockchain to be interesting. So feel free to reach out to talk about it!</blockquote><p>And that about wraps it up for this article!</p><p>There are many more exciting things left to talk about. The consensus algorithms, The pros/cons of blockchain and how it’s being solved, Ethereum 2.0, the list goes on.</p><p>If you are interested in any Web3-related topics and want to see more articles from us or give feedback about this article, <a href="https://www.facebook.com/cleverse.team/">feel free to reach out to us!</a></p><p>Stay tuned for upcoming articles! Spoiler: it’s for <em>developers</em> ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d16b61235dc4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-d16b61235dc4">Welcome to the world of Web 3.0</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving DApps problem with Merkle drop]]></title>
            <link>https://medium.com/cleverse/solving-dapps-problem-with-merkle-drop-ff656adca942?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/ff656adca942</guid>
            <category><![CDATA[venture-builder]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[Nutchanon Ploypray]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 06:47:30 GMT</pubDate>
            <atom:updated>2023-01-10T08:54:23.612Z</atom:updated>
            <content:encoded><![CDATA[<p>There are now additional Blockchain use cases due to the proliferation of DApps or decentralized applications, such as DeFi, NFT, or GameFi. According to its use case, each approach has advantages and disadvantages, so anyone considering creating DApps should be aware of the following:</p><ul><li><strong>Transparency</strong>: The system is transparent and can be checked by anyone</li><li><strong>Privacy</strong>: Because every piece of data on the blockchain is transparent and available to everyone, we may need to consider how sensitive the user’s data is. Therefore, there is a tradeoff between transparency and privacy.</li><li><strong>Security</strong>: Because it is about money and transparency. Making them vulnerable to various attacks</li><li><strong>Transaction Fee</strong>: High transaction costs. The value is relatively high in a blockchain transaction like an Ethereum transaction. Besides, storing blockchain data also requires a lot of money to save.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNRtj0EiqBz7S0L8OWO08g.png" /></figure><p>Don’t worry if you’ve read this and haven’t heard of Web 3.0 or Blockchain. I advise you to read this blog first to understand what Web 3.0 is and how significant it is in the modern world.</p><p><a href="https://medium.com/@aikdanai.s/welcome-to-the-world-of-web-3-0-d16b61235dc4">Welcome to the world of Web 3.0</a></p><p>So, what challenges do we encounter in the field of blockchain technology, and how do we overcome them? What factors ought we consider?</p><h3>Simple Problems, Simple Solutions</h3><p>Give a specific problem as an example. Let’s say you start as a DApp team in Ethereum and later decide to hire a group of 7–10 additional members.<br>Suppose ETH was worth $100 at the time, and the average wage for a team member was $4000. You send 40 ETH to each team member at the end of the month. Gas might cost $1 for each person. The choice of people is not at all wrong.</p><blockquote>Gas cost = ~$8<br>Time cost = ~30 minutes</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*JGYqJyJ0UdA4Y_yhFs0OBw.png" /></figure><h3>Time flies, and the answer has been altered.</h3><p>Once your DApp is widely used, your team expands to 100 individuals earning a range of incomes. Additionally, the gas expense rises to $20 for each transaction. You consult the programming team because paying the team members who must send money one at a time is starting to fail. Our staff will improve the functionality of the tools used to manage your money transfer.</p><p>After a while, the team’s developers began to come up with several suggestions. There are 3 intriguing concepts.</p><h4>1. Multi-Transfer Smart Contract</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*2K99afYYasHSLInU8Syv7g.png" /></figure><p>It is a technique for transferring coins to several destinations at once by making a call to a smart contract with the specified money and destination.</p><pre>&quot;0xEcA5035aAcBe8cfcdE45348Ad4bF0659a2da2Be5&quot;, 1000<br>&quot;0xD1Cd56B0212dA4F653c66cBDaa0cBfd7Bac0A305&quot;, 500<br>&quot;0x67C48F490b4bB87D93466Ff6aB4a46C851E0c040&quot;, 1500<br>&quot;0xe379DC0CaE3FACA163C0CF5563F9e6A76bC3045c&quot;, 1000<br>&quot;0xf12CF93685EFbcD890C921918F4b1BA479eE8f9a&quot;, 1000<br>&quot;0x48B23fa9aC54a8574C4568A3F6347fB82E53DF9e&quot;, 1000<br>&quot;0x169C198de1D0385AAC19A10fa29d3b00C154e9bB&quot;, 1000<br>&quot;0x856bf248DF77f1FFf8125F7bbD42eF282135A8e9&quot;, 1000<br>&quot;0x933aA63bdE10435479cAcE74D56e4F9d2363EFc2&quot;, 1000<br>&quot;0xF2c28A054B76c69de9Fa2522903452f652eeA357&quot;, 1000<br>...</pre><p><strong>Calculate Transaction Fee (Gas cost)</strong></p><blockquote>If receiver = 1000</blockquote><blockquote>Sender calls multi-transfer for transferring money to receivers</blockquote><blockquote>= ~$2/receiver = $2000</blockquote><blockquote>Gas cost = ~$2000</blockquote><p><strong>Security</strong></p><p>So this idea has some points that we need to think about it</p><ul><li>All funds must be kept in the sender’s wallet prior to the transfer.</li><li>Transferring using a smart contract requires your consent. Allowance is the maximum amount a smart contract may take from your account. Therefore, if the contract is changed or you approve the incorrect one, it might result in you losing all of your money.</li></ul><p><strong>Pros</strong></p><ul><li>Simple and fast to implement</li><li>This approach is easy for sender and receiver to use.</li></ul><p><strong>Cons</strong></p><ul><li>Because the transaction charge grows according to the Receiver amount, it cannot be scaled.</li></ul><h4>2. Vault Smart Contract</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*rAMQ-vvulq95ZWL6V1l7XA.png" /></figure><p>To store all of the money, we developed a smart contract called “Vault.” Then the sender configures the Vault such that those who are eligible to claim funds can do so and in what amounts.</p><p><strong>Steps</strong></p><ol><li>Transfer funds from the sender or source for storage in the Vault smart contract.</li><li>To specify which addresses and how much they can claim from the vault, the sender sends the configuration to the vault.</li><li>To claim the money, the receiver calls the claimed method on the smart contract.</li></ol><p><strong>Calculate Transaction Fee (Gas cost)</strong></p><blockquote>If receiver = 1000</blockquote><blockquote>Sender set the configuration in Vault = ~$1/receiver = $1000</blockquote><blockquote>Receivers claim on smart contract = ~$1</blockquote><blockquote>Gas cost = ~$1001</blockquote><p>If you see that the cost to the sender is lower but the entire cost of gas, which includes all of the money paid by the recipient, remains the same,</p><p><strong>Security</strong></p><p>If the sender&#39;s private key is lost, the attacker will be able to alter the settings and steal all of the money.</p><p><strong>Pros</strong></p><ul><li>The cost of sender gas is greatly lowered</li><li>The responsibility to keep an eye out for money transfers from the sender to the smart contract</li></ul><p><strong>Cons</strong></p><ul><li>Now the receiver has to pay a small gas cost</li><li>Setting setup consumes the greatest gas and continues to do so based on the receiver amount</li></ul><h4>3. Vault Smart Contract with Signature</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4trhognR0ouqtHxP5KEsg.png" /></figure><p>Similar in idea to the second, however, this proposal modifies the smart contract’s set up to store the signature off-chain. If the sender signs the signature, which is a hash of the recipient’s address and the amount of the claim, the smart contract will permit the recipient to withdraw the money.</p><p><strong>Steps</strong></p><ol><li>Transfer funds from the sender or source for storage in the Vault smart contract.</li><li>The sender creates a signature from the data which is the hashed of the receiver address and claim amount.</li><li>delivering the signature in some way to the recipient. It may be sent by API or messaging.</li><li>The recipient uses their signature to get their smart contract money.</li></ol><p><strong>Calculate Transaction Fee (Gas cost)</strong></p><blockquote>If receiver = 1000</blockquote><blockquote>Sender set the owner signature address = ~$1</blockquote><blockquote>Receivers claim on smart contract = ~$1</blockquote><blockquote>Gas cost = ~$2</blockquote><p>As you can see, this method has a minimal gas cost as the store configuration data is no longer on the blockchain, but it still requires the recipient to complete a transaction in order to collect their money.</p><p><strong>Security</strong></p><ul><li>The second concept still has the same security flaw in that if the sender&#39;s private key is lost, all of the money might be lost.</li><li>A user cannot utilize a smart contract to collect money if the server that offers a signature is unavailable.</li></ul><p><strong>Pros</strong></p><ul><li>Compared to all solutions, the cost of gas is the lowest.</li><li>If sender and recipient numbers expand in the future, scaling will be easiest.</li></ul><p><strong>Cons</strong></p><ul><li>The need to deploy or set up a location where the recipient can visit to obtain a signature may result in an extra expense.</li></ul><h3>Making a decision</h3><p>Each of the three solutions may be used to handle the problem of transferring money once we have discussed their advantages and disadvantages, but there are certain trade-offs between them.</p><ul><li>Transaction Fee (Gas cost)</li><li>Security</li><li>How simple it is to implement and use</li></ul><h4>Choose the Easiest or the Most Difficult</h4><p>Deciding a direction to take is never easy. I thus have an idea for you. If you need something quick and inexpensive, pick the easy option; if you want something durable and maintenance, pick the toughest. Since you may immediately reject the simple answer.</p><p>The third idea, <em>“Vault Smart Contract with Signature”</em>, is what our team chose as the solution. Then this blog’s subsequent part will outline this method in more depth.</p><h3>Merkle Proof and ECDSA Signature</h3><h4>ECDSA Signature</h4><p>Elliptic Curve Digital Signature Algorithm is the full name of the algorithm. In order to produce Private Key and Public Key for making a transaction in the blockchain, cryptography is thus made using an algorithm. We will thus demonstrate how to utilize ECDSA in our approach.</p><p><strong>Signature</strong></p><p>Data + Private Key = Signature</p><p>Using the previous formula Data and a private key are combined to generate a signature. This is a “sign signature” action.</p><p><strong>Recovery</strong></p><p>Data + Signature = Public Key</p><p>On the other side, we can recover it to obtain the public key if we have the data and signature.</p><p><strong>Implementation</strong></p><p>The idea we selected is implemented in a code following this section.</p><blockquote>Step1: Sender must sign a message that includes the recipient’s address and a claim for payment.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8RaDzwM5wZoaXmX7J_auA.png" /></figure><blockquote>Step2: Sender must deliver a signature from the previous stage to the recipient. It may also be transmitted over a message service or API.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*10caY_wdFC515WflHvN0gg@2x.png" /></figure><blockquote>Step3: Receiver brings the signature to claim money from a smart contract that implements a method that using to verify the signature.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4088bbfd69f176b4247fc0dee876e64/href">https://medium.com/media/d4088bbfd69f176b4247fc0dee876e64/href</a></iframe><p>Finally, you can implement a smart contract that allows the sender to deposit money and wait for the receiver to come to pick them up later. However, the approach in the next part is improved.</p><h4>Merkle Proof</h4><p>Merkle Proof is a list of hashes. It serves as proof that the leaf is a component of the Merkle tree.</p><h4>Merkle Tree</h4><p>Hash tree or the Merkle tree It is a data structure in the form of a tree, with each node being a hash of a data block and each parent being a hash of their child. The Merkle root was the highest parent node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*SVADcHE9dFwEIDLTeihAhw@2x.png" /></figure><p>So by this feature of Merkle Proof, we can use this to improve verify method</p><h4>How to use Merkle Proof</h4><p>For instance, suppose the whitelisted address hashing tree is the Merkle Tree. You are therefore on the whitelist; how can we ensure that you are valid?</p><p><strong>What do you need to prove?</strong></p><ul><li>The Leaf. In this case, your leaf represents your address and amount.</li><li>Neighbour nodes in the route to the Merkle root that hashes with your leaf</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8636e5c039c58b38d50507479da0087c/href">https://medium.com/media/8636e5c039c58b38d50507479da0087c/href</a></iframe><h4>Then What?</h4><p>In order to verify that the user is a part of the Merkle Tree, you must now save the root and add logic to your vault smart contract code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7761a04346eb4ed8abc3c76b408b32df/href">https://medium.com/media/7761a04346eb4ed8abc3c76b408b32df/href</a></iframe><h3>Summary</h3><p>After a lengthy reading, I’ll summarize what you’ve read in bullet points.</p><ul><li>Characteristics of DApp and Blockchain</li><li>The simple way to transfer money in Blockchain</li><li>Identify a solution to the scale problem.</li><li>How to implement Merkle Proof and ECDSA in Solidity smart contract</li></ul><p>Thank you for reading, see you later in the next article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff656adca942" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/solving-dapps-problem-with-merkle-drop-ff656adca942">Solving DApps problem with Merkle drop</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solidity Made Easy with Hardhat]]></title>
            <link>https://medium.com/cleverse/solidity-made-easy-with-hardhat-91a6972362bb?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/91a6972362bb</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <dc:creator><![CDATA[Aikdanai Sidhikosol]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 06:44:46 GMT</pubDate>
            <atom:updated>2022-11-23T13:54:12.937Z</atom:updated>
            <content:encoded><![CDATA[<h3>Solidity Made Easy with Hardhat | Cleverse Web3 Series</h3><p>As a Solidity Developer who started with Remix, I wondered if there was a better way to create a smart contract.</p><p>And I believe I’ve found the solution with <strong>Hardhat</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjXXQpJb26ALoUXQ7_jPEw.png" /><figcaption>A beautiful thumbnail by our designer at Cleverse</figcaption></figure><p>In my <a href="https://medium.com/@aikdanai.s/welcome-to-the-world-of-web-3-0-d16b61235dc4">Web 3.0 article</a>, I mentioned Smart Contracts as one of the most powerful tools for achieving Web 3.0 and as one of the factors that have led to Ethereum’s current success.</p><blockquote><strong>Disclaimer:</strong> This article will not go into the nitty-gritty technical details of Solidity. The goal is to show how to use Hardhat as the Solidity development environment.</blockquote><h3>Before Hardhat, there was Remix</h3><p>Let’s talk a bit about Remix first.</p><p>What exactly is Remix? <a href="http://remix.ethereum.org/">Remix</a> is a smart contract development IDE. It’s likely the first thing you learn when learning smart contract development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qdSp17RGzEypd4YrYN5vkw@2x.png" /><figcaption><a href="https://remix.ethereum.org/">remix.ethereum.org</a></figcaption></figure><p>It has served its purpose admirably, whether for learning, prototyping, or development. Even though it is adequate, I want to look for something that better suits my needs.</p><h3>Hardhat!</h3><p>Hardhat is a development environment that streamlines compiling, deploying, debugging, and, my personal favorite, testing smart contracts.</p><p>This article will walk you through the steps of creating, compiling, testing, deploying, and verifying smart contract projects using Hardhat.</p><h3>Article Outline</h3><ol><li>Creating Project with Hardhat</li><li>Implementing Smart Contract</li><li>Automated Test with Hardhat</li><li>Deploying with Hardhat Script</li><li>Verifying Code on Blockchain Explorer (withHardhat Script)</li></ol><h3>1. Creating the project</h3><p>Let’s start with an npm project, then install hardhat and create a TypeScript project with it.</p><pre>npm init</pre><pre>npm install --save-dev hardhat</pre><pre>npx hardhat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*X8rgsMV3O6forwadMfuxPQ@2x.png" /><figcaption>Select TypeScript when creating a sample project</figcaption></figure><p>Then the project structure should be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*avYsfUunZNnQF8z3AonQMg@2x.png" /><figcaption>Project Structure</figcaption></figure><p><strong>The meaning of each important files</strong></p><ul><li>hardhat.config.ts Configuration file (<a href="https://hardhat.org/hardhat-runner/docs/config#configuration">Learn more here</a>)</li><li>contracts/ Directory for Smart Contract source code</li><li>scripts/ Directory for scripts, e.g., deploy scripts</li><li>test/ Directory for automated test files</li></ul><p>Change the test command in package.json to this:</p><pre>&quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;hardhat test&quot;<br>}</pre><h4>Environment file</h4><p>Create .env by duplicate .env.example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*GKdxwCBvHMxPppx8hQNkvA@2x.png" /><figcaption>The real .env</figcaption></figure><p>Configure .env to the real values. I’ll be using Ethereum Ropsten as the network for this article. (For the ROPSTEN_URL using this site: <a href="https://rpc.info/">rpc.info</a> is a good way to find one)</p><blockquote>This article was written when Ropsten was still alive. But it will be deprecated and shut down soon (Q4 2022), so you might need to use another network.<br><a href="https://blog.ethereum.org/2022/06/21/testnet-deprecation/">Read more</a></blockquote><h4>🏁 Checkpoint #1: Project created</h4><p>At this point, there should be a directory containing sample code, which you can test by running the following command:</p><pre>npm run test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*MzV9_0yF5yX8enxaNPnTtw@2x.png" /><figcaption>Test results</figcaption></figure><h3>2. Implementing the contract</h3><p>For this article, I’ll make a LoveLetter contract to send a lovely message (with money attached) to a recipient.</p><p>Create LoveLetter.sol in contracts/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*qbKqflW2wWJOZX-PMBJTLg@2x.png" /><figcaption>LoveLetter.sol in contracts</figcaption></figure><h4>The requirements:</h4><ul><li>Send letters containing Ether.</li><li>Receive letters with Ether. It should only be callable by the receiver.</li><li>Read the message contained within a letter. (We won’t be preventing others from reading the message.)</li></ul><blockquote>⚠️ <strong>Challenge1</strong>: Before reading the code below, try implementing it with the help from contracts/Greeter.sol.</blockquote><h4>🏁 Checkpoint #2: Contract implemented</h4><p>At this point, the LoveLetter.sol is finished. Here are my implementations:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4d5ba0ea7ffb357090294d0b1ccabce/href">https://medium.com/media/f4d5ba0ea7ffb357090294d0b1ccabce/href</a></iframe><p>Check the contract by running this command:</p><pre>npx hardhat compile</pre><p>The result should be something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*hWltDWzHbb2vf9BtvvIufQ@2x.png" /></figure><p>Next, let’s use my favorite features of Hardhat. Automated Test!</p><h3>3. Testing the contract</h3><p>Create the test file loveletter.ts in test/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*6iTBQGfsbKw6oJzbulvBXA@2x.png" /><figcaption>loveletter.ts in test/</figcaption></figure><h4>Implement tests for these use cases:</h4><ul><li>The contract can be deployed successfully.</li><li>Send the letter successfully, then read the correct values from it.</li><li>The letter can’t be opened by someone that’s not the receiver.</li><li>The receiver opens the letter successfully, receiving the Ether within.</li></ul><blockquote>⚠️ <strong>Challenge2</strong>: Before reading the code below, try implementing it with the help from test/index.ts.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f82280107853683b212e870d98349473/href">https://medium.com/media/f82280107853683b212e870d98349473/href</a></iframe><h4>Running tests</h4><p>Use the command:</p><pre>npm run test</pre><p>The result will be something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*alcxJ5Ca1ab70XZjBFkqkA@2x.png" /><figcaption>The result</figcaption></figure><blockquote>[send] 0 1000000000000000000 ...What is this?</blockquote><p>And that would beconsole.log() for solidity!</p><p>This console.log is inside send function in my implementation of the contract. <a href="https://hardhat.org/hardhat-network/docs/reference#console-log">Read more about console.log</a></p><h4>🏁 Checkpoint #3: Contract tested</h4><p>At this point, the contract has been tested. Next, let’s deploy it onto the network!</p><blockquote>⚠️<strong> Challenge3:</strong> Add two test cases:<br>1. Revert the transaction if the receiver tries to open an opened letter.<br>2. Send a letter (which would has an id of 1) successfully.<br>My implementation will be in the GitHub repository at the end of this article.</blockquote><h3>4. Deploying the contract</h3><blockquote>⚠️ <strong>Challenge4</strong>: Try deploying the contract on Remix first!</blockquote><h4>Deploy with Hardhat script</h4><p>Create the script atscripts/deploy-loveletter.ts</p><blockquote>⚠️ <strong>Challenge5</strong>: Try implementing the script with <em>scripts/deploy.ts</em> as an example.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f29c2cdd851738b37cd12fda5e283368/href">https://medium.com/media/f29c2cdd851738b37cd12fda5e283368/href</a></iframe><p>Then run the command below for deploying:</p><pre>npx hardhat run scripts/deploy-loveletter.ts --network ropsten</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ij48mSllrtDsyJOb44GJJg@2x.png" /><figcaption>Result of the deployment</figcaption></figure><h4>🏁 Checkpoint #4: Contract deployed</h4><p>At this point, the smart contract is deployed on the blockchain.</p><p>You can see your deployed contract on <a href="https://ropsten.etherscan.io/">https://ropsten.etherscan.io/</a> (or whatever blockchain explorer for the network of your choice)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuN4afXIwP3BPykIpGCo7g@2x.png" /><figcaption>Contract is on <a href="https://ropsten.etherscan.io/">ropsten.etherscan.io</a> !</figcaption></figure><p>A thing might be a little different for you, namely the Contract tab without the green checkmark.</p><p>The checkmark indicates that the contract has been verified with readable source code. So let’s go and do that!</p><h3>5: Verifying the source code</h3><p>Even though anyone can deploy smart contracts on the blockchain (<a href="https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-thai-version-6c8c24da3ca1">Permissionless</a>) and see the code of all smart contracts. There’s a catch.</p><p>The code is a bytecode, which is not human-readable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdgPCpL8Q_C5jQgF6E4PeA@2x.png" /><figcaption>Bytecode of the contract</figcaption></figure><p>If contract developers want others to be able to read the source code, they will have to verify the contract with the original source code first.</p><p>And with hardhat, doing so is easier than ever!</p><pre>npx hardhat verify --network ropsten {{contractAddress}}</pre><p>Now, anyone will be able to read the code!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDti5MONsLpfxVt5_G9DDA@2x.png" /><figcaption>Verified source code</figcaption></figure><blockquote>⚠️ <strong>Challenge6</strong>: Try verify the code on blockchain explorer itself.</blockquote><h4>🏁 Checkpoint #5: Contract code verified</h4><p>At this point, we have a tested, deployed, and verified contract on the network!</p><blockquote>⚠️ <strong>Challenge7</strong>: Try <a href="https://hardhat.org/tutorial/deploying-to-a-live-network">Deploy</a> &amp; Verify on mainnet. The process is exactly the same, just changing things in .env and sometinkering with hardhat.config.ts</blockquote><h3>🏁 Done! 🏁</h3><p>To recap, here are the things we’ve done in this article:</p><ol><li>Creating Project with Hardhat</li><li>Implementing Smart Contract</li><li>Automated Test with Hardhat</li><li>Deploying with Hardhat Script</li><li>Verifying Code on Blockchain Explorer (with Hardhat Script)</li></ol><p>Thank you for reading, see you later in the next article!</p><p>Resources</p><ul><li><a href="https://github.com/aikdanai/solidity-hardhat-101">GitHub - aikdanai/solidity-hardhat-101</a></li><li><a href="https://hardhat.org/tutorial">Hardhat&#39;s tutorial for beginners | Ethereum development environment for professionals by Nomic Foundation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91a6972362bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/solidity-made-easy-with-hardhat-91a6972362bb">Solidity Made Easy with Hardhat</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เขียน Solidity ..ชีวิตดีได้ด้วย Hardhat!]]></title>
            <link>https://medium.com/cleverse/solidity-hardhat-101-6ccbfa493b11?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/6ccbfa493b11</guid>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <dc:creator><![CDATA[Aikdanai Sidhikosol]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 09:27:14 GMT</pubDate>
            <atom:updated>2022-08-05T09:27:14.669Z</atom:updated>
            <content:encoded><![CDATA[<h3>เขียน Solidity ..ชีวิตดีได้ด้วย Hardhat!</h3><p>ชีวิตของ Solidity Developer ที่อยู่ได้ด้วย Remix นั้น ถึงจุด ๆ หนึ่งอาจจะนึกขึ้นมาว่า <em>มันมีสิ่งที่ดีกว่านี้รอเราอยู่ไหมนะ?</em> …บทความนี้จะมาตอบเลยว่า มี!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjXXQpJb26ALoUXQ7_jPEw.png" /><figcaption>รูปปกเสกโดยดีไซเนอร์มือฉมังแห่ง Cleverse</figcaption></figure><p>จาก<a href="https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-thai-version-6c8c24da3ca1">บทความ Web 3.0</a> นั้น ผมได้มีการพูดถึง Smart Contract ไว้ว่าเป็นหนึ่งในอาวุธสำคัญที่จะทำให้เราเข้าใกล้โลก Web 3.0 เข้าไปอีกก้าว และเป็นฟีเจอร์หลักของ Ethereum เลยก็ว่าได้ ซึ่งสามารถเขียนโดยภาษา Solidity ผ่าน Tools ต่าง ๆ เช่น Remix หรือ Hardhat</p><blockquote>Disclaimer: บทความนี้จะขอข้ามรายละเอียดทางเทคนิคหลายอย่างนะครับ โดยจะพยายามใส่ลิ้งก์ที่เกี่ยวข้องเผื่อศึกษาเพิ่มเติมให้ครบ<br>แล้วก็รวมถึง Technical Details ของ Solidity ที่ขอละไว้ ซึ่งตรงนี้คิดว่าหากอยากลงลึก ลองค้นหา<a href="https://www.udemy.com/course/ethereum-and-solidity-the-complete-developers-guide/">คอร์สเรียน</a> หรือถาม<a href="https://www.youtube.com/watch?v=EhPeHeoKF88">อาจารย์ YouTube</a> ดู น่าจะได้ความรู้ครบถ้วนกว่าเป็นบทความครับผม 🥰</blockquote><h3>ก่อนจะ Hardhat รู้จัก Remix สักนิด</h3><p><a href="https://hardhat.org/getting-started#overview">Hardhat</a> นั้นทำให้การสร้าง Smart Contract นั้น Developer ทำได้อย่างสะดวกสบายมากขึ้น</p><p><em>“สบายขึ้นนี่ คุณน้องเทียบกับอะไรฮะ?” — คำถามในใจผู้อ่าน</em></p><p>จริง ๆ แล้ว Ethereum.org เองเนี่ย ก็มี IDE สำหรับเขียน Solidity อยู่แล้วนะครับ ซึ่งก็คือ <a href="https://remix.ethereum.org/">Remix</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qdSp17RGzEypd4YrYN5vkw@2x.png" /><figcaption><a href="https://remix.ethereum.org/">remix.ethereum.org</a></figcaption></figure><p>หากสนใจ Remix ลองเล่นดูโดยอ่าน Guide ละเอียดๆได้<a href="https://remix-ide.readthedocs.io/en/latest/">ที่นี่</a> แต่สำหรับบทความนี้ขอมูฟออนไปยัง Hardhat ดีกว่า</p><p>ทำไมถึงดีกว่า? ขอเล่าในหัวข้อถัดไปครับ</p><h3>Hardhat!?</h3><p>เป็น Development Environment ที่ทำให้เราสามารถ Compile, Deploy, Test, Debug ตัว Smart Contract ได้ ซึ่งมาพร้อมกับ Local Ethereum Network ทำให้เราสามารถทดสอบกับ Blockchain จริง ๆ ได้เลย</p><p>ข้อดีหลัก ๆ ของ Hardhat มีดังนี้:</p><ul><li>Debug ได้ง่าย Error Message ชัดเจน</li><li>Fork Network ของจริงมาทดสอบได้ ทำให้ Test ได้แบบสมจริง</li><li>ดู Stack Trace ได้</li><li>สำหรับเหล่า JS Dev ทั้งหลาย; มี console.log()ด้วย! 😳</li><li>เป็น JS Ecosystem ทำให้หลายๆคนอาจจะรู้สึกคุ้นเคยเหมือนคนเคยคุย</li><li>มี Plugins ให้เลือกมาเสริมมากมาย</li></ul><h3>Outline บทความ</h3><ol><li>ขึ้น Project Hardhat</li><li>เขียน Smart Contract</li><li>Automated Test ผ่าน Hardhat</li><li>Deploy ด้วย Hardhat Script</li><li>Verify Code บน Blockchain Explorer (ด้วย Hardhat Script)</li></ol><h3>1. ขึ้นของแบบไม่ของขึ้น</h3><blockquote>ไม่ของขึ้นเพราะง่ายมาก?<br>เปล่า เพราะงง! ผ่าม!</blockquote><p>มาลุยขึ้นโปรเจ็กต์กันครับ!</p><p>เริ่มด้วยการขึ้น npm มาก่อน</p><pre>npm init</pre><p>จากนั้นลง hardhat</p><pre>npm install --save-dev hardhat</pre><p>แล้วสร้างโปรเจ็กต์ด้วย Hardhat — เลือกเป็น TypeScript ครับ (ผม TypeScript FC ❣️)</p><pre>npx hardhat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*X8rgsMV3O6forwadMfuxPQ@2x.png" /><figcaption>เลือกอันนี้ๆๆ</figcaption></figure><p>จากนั้นจะได้โครงสร้าง Project มาประมาณนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*avYsfUunZNnQF8z3AonQMg@2x.png" /><figcaption>Project Structure</figcaption></figure><p><strong>อธิบายความหมายไฟล์สำคัญๆ</strong></p><ul><li>hardhat.config.ts Configuration สำหรับ hardhat ทั้งหมด <a href="https://hardhat.org/config#configuration">อ่านเพิ่ม</a></li><li>contracts/ Directory รวมโค้ด Smart Contract</li><li>scripts/ Directory รวมไฟล์ Scripts ต่างๆ เช่น Script สำหรับ Deploy</li><li>test/ Directory รวมไฟล์ Automated Test</li></ul><p>แก้คำสั่ง test ใน scripts ของ package.json ให้เป็นตามนี้</p><pre>&quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;hardhat test&quot;<br>}</pre><h4>กำหนด Environment</h4><p>ก๊อปปี้ไฟล์​ .env.example ออกมา เป็น .env</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*GKdxwCBvHMxPppx8hQNkvA@2x.png" /><figcaption>.env คนจริง</figcaption></figure><p>แก้ค่าใน .env ให้เป็นค่าจริง ซึ่งสำหรับบทความนี้จะทำอยู่บน Ethereum Ropsten Testnet นะครับ</p><p>โดยแต่ละค่าก็คือ:</p><ul><li>ETHERSCAN_API_KEY API Key ของ <a href="https://docs.etherscan.io/getting-started/viewing-api-usage-statistics">etherscan.io</a> (อันนี้ใช้ใน Step 5: Verify Contract เพื่อ Verify Code ผ่าน Script เท่านั้นครับ ข้ามไปแล้ว Verify แบบ Manual เอาก็ได้เหมือนกัน)</li><li>ROPSTEN_URL RPC URL ของ Ropsten ซึ่งเจ้า Hardhat generate ตัวอย่างมาให้เป็นของ <a href="https://www.alchemy.com/">Alchemy</a> แต่ใช้ของ public ใน <a href="https://rpc.info/">rpc.info</a> ก็ได้ (เช่น ตอนที่ผมดูจะเป็น <a href="https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161">https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161</a>)</li><li>PRIVATE_KEY Private Key ของ Wallet ที่จะใช้ Deploy Contract (กดดูใน <a href="https://metamask.io/">Metamask</a> ได้ — 🚨อย่าทำ Key หลุดนะครับบบ🚨)</li></ul><blockquote>บทความนี้เขียนตอน Ropsten ยังมีชีวิตอยู่ แต่มันกำลังจะ Deprecated ในอนาคตอันใกล้นี้นะครับ หากตอนอ่านบทความนี้มันสิ้นชีพไปแล้ว ลอง Testnet อื่นดูครับ<br><a href="https://blog.ethereum.org/2022/06/21/testnet-deprecation/">อ่านเพิ่มเติม</a></blockquote><h4>🕵🏻‍♂️ Checkpoint 1: Project Structure</h4><p>ถึงจังหวะนี้จะได้ Directory พร้อมโค้ดตัวอย่างมาแล้วครับ ลองทดสอบดูได้โดยการ</p><pre>npm run test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*MzV9_0yF5yX8enxaNPnTtw@2x.png" /><figcaption>ผลลัพธ์เวลารันเทสกับ Project ตัวอย่าง</figcaption></figure><h3>2. เขียน Contract กัน!</h3><p>โจทย์เป็น Contract ที่จะทำหน้าที่ง่าย ๆ คือ ให้เราสามารถส่งจดหมายรัก (พร้อมเงินเปย์) ให้คนปลายทางสามารถรับไปได้</p><p>โดยในจดหมายจะมีข้อความเป็น String ติดไปด้วย — ซึ่งสำหรับ Scope งานนี้ จะเป็นใครก็อ่านได้ไปก่อน ยังไม่ต้องทำระบบกันไม่ให้คนอื่นอ่าน</p><p><em>แชร์ความสวยงามของความรักให้แก่ชาวโลกกันเถอะ </em>🌝</p><blockquote>ย้ำว่าไม่ลง Technical Details นะครับ และโค้ดนี้ยังไม่ได้ผ่านการ Optimize Gas ใดๆ เน้นความอ่านง่ายเป็นหลัก</blockquote><h4>วางตำแหน่งกล่องจดหมาย</h4><p>สร้างไฟล์ LoveLetter.sol ไว้ใน Directory contracts/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*qbKqflW2wWJOZX-PMBJTLg@2x.png" /><figcaption>LoveLetter.sol ใน contracts</figcaption></figure><blockquote>⚠️ <strong>Challenge1</strong>: ก่อนอ่านโค้ดด้านล่าง ดูตัวอย่างจาก <em>contracts/Greeter.sol</em> อ่านโจทย์ แล้วเขียนเองดูครับ</blockquote><h4>ขึ้นโครงกล่องจดหมาย</h4><p>ขึ้นโค้ด Contract มาพร้อมกับประกาศ​ Data Structure ที่ต้องใช้ให้ครบ</p><ul><li>totalLetters บอกว่าตอนนี้มีจดหมายอยู่กี่อัน</li><li>mapping(uint256 =&gt; address) public senders เก็บว่า Letter ID นี้ ใครเป็นคนส่ง</li><li>mapping(uint256 =&gt; address) public receiversเก็บว่า Letter ID นี้ ใครเป็นคนรับ</li><li>mapping(uint256 =&gt; Letter) public letters เก็บข้อมูลภายใน Letter ซึ่งประกอบไปด้วย: ข้อความ, ปริมาณเงินเปย์, สถานะว่าถูกเปิดหรือยัง</li><li>struct Letter คือ Data Structure ของจดหมาย</li><li>constructor คือฟังก์ชั่นที่จะทำงานตอนเรา Deploy Contract ครั้งแรก อันนี้มีหน้าที่เพียงเซ็ตค่า totalLetters ให้เริ่มต้นที่ 0 เท่านั้น</li><li>event คืออีเว้นต์ที่เราสามารถดักจับออกมาดูได้ ถ้า Transaction นั้นผ่าน ซึ่งจะมี 2 อีเว้นต์ที่เราต้องการ คือเมื่อมีคนส่งจดหมาย (Send ) กับเปิดจดหมาย (Open)</li></ul><blockquote>Solidity มี Default Value อยู่แล้ว ซึ่งสำหรับ <em>uint256</em> ก็เป็น <em>0</em> นั่นแหละ ดังนั้นจริงๆไม่ต้องเซ็ตก็ได้ แต่เขียนไว้เพื่อความชัดเจน</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae7f0323cd5c63be0b1af0e969d65f1e/href">https://medium.com/media/ae7f0323cd5c63be0b1af0e969d65f1e/href</a></iframe><h4>ช่องส่งจดหมาย</h4><p>พอมีกล่องจดหมายเปล่า ๆ มาแล้ว ขั้นต่อไปก็คือฟังก์ชั่นสำหรับส่งจดหมาย</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d832cbe6d94e798569a08a176cdd8015/href">https://medium.com/media/d832cbe6d94e798569a08a176cdd8015/href</a></iframe><h4>ช่องรับจดหมาย</h4><p>มีคนส่งก็ต้องมีคนรับ ต่อไปคือฟังก์ชั่นรับจดหมาย ที่เรียกได้เฉพาะคนเป็น Receiver ของจดหมายนั้นๆ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b2228e8aed369c2df130646b9e9b052/href">https://medium.com/media/5b2228e8aed369c2df130646b9e9b052/href</a></iframe><h4>ช่องแอบส่อง</h4><p>ส่งได้รับได้ แต่เรายังไม่มีช่องเอาไว้ส่องของข้างในเลย ดังนั้นมาทำฟังก์ชั่นดูค่าต่าง ๆ ในจดหมายกันต่อ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/534a5dc4621ad0b5139b94065675de4b/href">https://medium.com/media/534a5dc4621ad0b5139b94065675de4b/href</a></iframe><h4>🕵🏻‍♂️ Checkpoint 2: LoveLetter.sol</h4><p>ถึงจังหวะนี้ จะได้ Contract LoveLetter มาแล้วครับ อยู่ใน Directory contracts</p><p>โดยโค้ดทั้งหมดของ LoveLetter เป็นดังนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4d5ba0ea7ffb357090294d0b1ccabce/href">https://medium.com/media/f4d5ba0ea7ffb357090294d0b1ccabce/href</a></iframe><p>เช็คความถูกต้องได้โดยรันคำสั่ง</p><pre>npx hardhat compile</pre><p>ซึ่งผลลัพธ์ควรจะต้องออกมาประมาณนี้ครับ ไม่มี Errors</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*hWltDWzHbb2vf9BtvvIufQ@2x.png" /></figure><p>ขั้นถัดไป มาใช้ความสามารถสุดเทพอย่างหนึ่งของ Hardhat กัน! นั่นก็คือ Automated Test</p><h3>3. เทสแรกไม่เป็นไร เทสถัดไป.. แตก!</h3><p>เขียนโค้ดเสร็จแล้ว มานั่งเทสมือมันเหนื่อย เรามองลองเขียน Automated Test ครอบกันดีกว่า</p><h4>สร้างไฟล์ Test</h4><p>สร้างไฟล์ loveletter.ts ไว้ใน Directory test/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*6iTBQGfsbKw6oJzbulvBXA@2x.png" /><figcaption>loveletter.ts ใน test/</figcaption></figure><h4>เทสอะไรบ้างดี</h4><p>ลองเขียนเทสกันเบื้องต้นใน Usecase สำคัญ ๆ</p><ul><li>ทดสอบว่า Deploy สำเร็จ และ Initiate ค่าได้ถูกต้อง</li><li>ทดสอบว่าสามารถส่งจดหมาย ผ่านฟังก์ชั่น send ได้สำเร็จ และ มีค่าในจดหมายที่ถูกต้อง</li><li>ทดสอบว่าจดหมายต้องถูกเปิดโดยคนที่ไม่ใช่ผู้รับไม่ได้</li><li>ทดสอบว่าจดหมายถูกเปิดโดยฟังก์ชั่น openได้โดยคนที่เป็นผู้รับ และได้เงินเปย์ปริมาณที่ถูกต้อง</li></ul><blockquote>⚠️ <strong>Challenge2</strong>: ก่อนอ่านโค้ดด้านล่าง อยากให้ลองเขียนเทสดูเองก่อน โดยดูตัวอย่างจากไฟล์​ <em>test/index.ts</em> ครับ</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f82280107853683b212e870d98349473/href">https://medium.com/media/f82280107853683b212e870d98349473/href</a></iframe><h4>ฮัลโหล เทส เทส</h4><p>รันคำสั่งเทสได้โดย</p><pre>npm run test</pre><p>ซึ่งผลลัพธ์ก็จะออกมาหน้าตาประมาณนี้ครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*alcxJ5Ca1ab70XZjBFkqkA@2x.png" /><figcaption>ผลลัพธ์เทส</figcaption></figure><blockquote>[send] 0 1000000000000000000 คืออะไร๊!?</blockquote><p>สิ่งนั้นก็คือออออ…</p><p>console.log() ภายใน Solidity ครับ!</p><p>log ตัวนี้ อยู่ภายในในฟังก์ชั่น send ครับ ลองเล่น log นู่นนี่นั่นออกมาดูได้ <a href="https://hardhat.org/hardhat-network/reference#console-log">อ่าน docs กดที่นี่</a></p><h4>🕵🏻‍♂️ Checkpoint 3: ทดสอบความรัก</h4><p>จังหวะนี้ก็จะได้ไฟล์​ Automated Test เพื่อเสริมสร้างความมั่นใจก่อนเอา Contract ขึ้น Blockchain จริง ๆ แล้วนะครับ</p><blockquote>⚠️<strong> Challenge3:</strong> อยากให้ลองเพิ่ม Test Case เองครับ โดยเป็นสองเคสต่อไปนี้:</blockquote><blockquote>ทดสอบว่า หากเปิดจดหมายเดิมซ้ำ Transaction ควรจะถูก Revert</blockquote><blockquote>ทดสอบว่า ส่งจดหมายถัดไป จะเป็นจดหมาย ID <em>1</em> และเปิดได้โดยผู้รับเหมือนปกติ</blockquote><p>เทสของโจทย์สองข้อนี้ที่ผมเขียน จะอยู่ใน GitHub Repository ที่ผมแปะไว้ท้ายบทความนะครับ — <em>แอบดูตีมือ ☝️</em></p><h3>4. -3–2–1 Blast off! Deploy!</h3><p>โค้ดก็เสร็จแล้ว เทสก็ทำแล้ว คงไม่เหลืออะไรให้ทำอีกนอกจากเอาโค้ดขึ้นละ</p><p>ก่อนจะไปท่า Hardhat ขอกลับไปใช้ <a href="https://remix.ethereum.org/">Remix</a> กันก่อนนะครับ ถือเป็นการ Deploy แบบ Manual โดยไม่ต้องเขียน Script อะไรกันก่อน <em>แบบว่าลำบากก่อนสบายทีหลัง 🌝</em></p><h4>Remix สาย(ฉบับ)ย่อ</h4><p>เริ่มจากสร้างไฟล์ใหม่ใน Remix ตั้งชื่อว่า LoveLetter.sol แล้วก๊อปโค้ดจากไฟล์ contracts/LoveLetter.sol ใน Project เราไปวางครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NwKevMyLZ8Rsyh_xy22VQg@2x.png" /><figcaption>แปะโค้ดออกมาหน้าตาประมาณนี้</figcaption></figure><p>จากนั้นเลือกไปที่หัวข้อ Compile แล้ว Config ตามนี้ครับ</p><ul><li>Compiler เลือกเป็นอะไรก็ได้ใน 0.8.* (ง่าย ๆ ก็เอาตัวที่ใหม่สุดไป) เพราะจะเห็นว่าในโค้ดเราเขียนไว้ว่าเป็น pragma solidity ^0.8.0</li><li>ติ๊ก Auto compile เพื่อชีวิตที่ดีกว่า (มันจะ Compile ทุกครั้งที่เราแก้โค้ด ทำให้เห็นได้เลยว่ามี Compilation Error อะไรหรือเปล่า)</li><li>เลือก Contract เป็น LoveLetter.sol</li><li>กด Compile!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*zqRlUPULP7z5er73t5Kb2Q@2x.png" /><figcaption>Config ของ Compiler</figcaption></figure><p>สุดท้าย ก็คือไปที่หัวข้อ Deploy ครับ ซึ่ง Config ตามนี้</p><blockquote>จะข้ามวิธีใช้ <a href="https://metamask.io/">Metamask</a> ไปนะครับ</blockquote><ul><li>เลือก Environment เป็น Injected Web3 ซึ่งจะทำให้มัน Deploy ไปยัง Network ที่ Metamask นั้นเลือกอยู่ ดังนั้นให้ชัวร์ว่า Metamask เลือกเป็น Ropsten อยู่</li><li>Account จะเป็นกระเป๋าที่ใช้ Deploy ให้ชัวร์ว่ามี Gas อยู่ใน Ropsten — ถ้าไม่มีไปกดจาก <a href="https://faucet.metamask.io/">Faucet</a> ได้ (ตอนผมกดต้องรออยู่สิบกว่านาทีถึงจะเข้า)</li><li>เลือก Contract ให้เป็น LoveLetter.sol</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*u7BOLrFHAqb7X5EPJdFIRA@2x.png" /><figcaption>Config ของ Deployer</figcaption></figure><p>จากนั้น กด Deploy เลย!</p><p>หลังจาก Confirm ใน Metamask เสร็จก็นั่งจิบชารอ Transaction เสร็จซักแป๊ปครับ</p><p>ซึ่งหากเรียบร้อยจะขึ้นมาอยู่ใน Deployed Contracts แบบนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*Xd03Uno_OTZ42ORVWSfAFA@2x.png" /><figcaption>Blasted off!</figcaption></figure><p>ถ้าลองก๊อปปี้ Address ไปดูใน <a href="https://ropsten.etherscan.io/">ropsten.etherscan.io</a> ได้ จะเห็น Transaction ที่ Deploy อยู่ครับ เยยยย้</p><blockquote>⚠️ <strong>Challenge4</strong>: ลองเล่นใน Remix ทั้ง <em>send</em> ,<em>open</em> และฟังก์ชั่นอื่น ๆ ดูครับ แบบให้ receiver เป็นกระเป๋าอื่น แล้ว open ให้ได้</blockquote><blockquote>Deploy ยุ่งยาก ไม่ทำและ เลิกอ่านละบทความ</blockquote><p>หยุดก่อนเถิดท่านผู้ใจร้อนรุ่ม</p><p>ถัดไปมาลองทำท่าที่ง่ายกว่ากัน!</p><h4>Deploy ด้วย Script Hardhat</h4><p>สร้างไฟล์ Script ไว้ที่ scripts/deploy-loveletter.ts ได้เลยครับ (ก๊อปปี้มาจาก scripts/deploy.ts เลยก็ได้)</p><blockquote>⚠️ <strong>Challenge5</strong>: ลองเอา <em>scripts/deploy.ts</em> มาแก้เองดูครับ (แก้น้อยมากกก)</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f29c2cdd851738b37cd12fda5e283368/href">https://medium.com/media/f29c2cdd851738b37cd12fda5e283368/href</a></iframe><p>จากนั้นรัน Command ด้านล่างนี้เพื่อ Deploy ครับ</p><pre>npx hardhat run scripts/deploy-loveletter.ts --network ropsten</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ij48mSllrtDsyJOb44GJJg@2x.png" /><figcaption>ผลลัพธ์หลังจากรัน Command</figcaption></figure><h4>🕵🏻‍♂️ Checkpoint 4: ปลดปล่อยความรักสู่โลก</h4><p>ถึงจุดนี้ก็จะได้ Smart Contract ขึ้นไปอยู่บน Blockchain แล้วนะครับ</p><p>ลองก๊อปปี้ Address จากผลลัพธ์ใน Terminal ไปดูที่ <a href="https://ropsten.etherscan.io/">https://ropsten.etherscan.io/</a> ได้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuN4afXIwP3BPykIpGCo7g@2x.png" /><figcaption>Contract เราใน <a href="https://ropsten.etherscan.io/">ropsten.etherscan.io</a> !</figcaption></figure><p>ใครลองทำตามแล้วเทียบผลลัพธ์ใน Etherscan ดู อาจจะพบว่า ตรง Contract ของคุณไม่มีติ๊กสีเขียวอยู่</p><p>ซึ่งสิ่งนั้นจะเกิดขึ้นได้ เราต้อง <strong>“Verify”</strong> โค้ด Smart Contract เราก่อน เพราะปกติแล้วเราจะอ่านโค้ดของ Contract ที่ยังไม่ Verify ไม่ได้ จะเห็นเป็น Bytecode ยาว ๆ</p><p>Verify ยังไง? ตามมาดูกัน! หัวข้อสุดท้ายแล้ววว</p><h3>5: ยืนยันว่ารักยังยั่งยืนอยู่ยั้งยืนยง</h3><p>เนื่องจาก Blockchain นั้น ใคร ๆ ก็สามารถ Deploy Contract ขึ้นไปได้ (<a href="https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-thai-version-6c8c24da3ca1">Permissionless</a>) และใครก็สามารถดูโค้ดได้ด้วย</p><p>…แต่โค้ดที่เห็นนั้นก็จะเป็น ByteCode ที่มนุษย์เรา ๆ อ่านไม่รู้เรื่อง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdgPCpL8Q_C5jQgF6E4PeA@2x.png" /><figcaption>Bytecode ของ Contract ที่ยังไม่ Verify</figcaption></figure><p>ดังนั้น ถ้านักพัฒนาอยากให้ผู้ใช้สามารถมาตรวจสอบโค้ด(แบบที่มนุษย์อ่านออก)ด้วยตัวเอง ก็ต้องยืนยัน(Verify)โค้ดกันเสียก่อน ว่าโค้ดต้นฉบับก่อนที่จะกลายเป็น ByteCode นั้น หน้าตาเป็นยังไง</p><p>ซึ่งด้วยพลังแห่ง Hardhat นั้น ก็ทำได้ง่ายมาก โดยรันแค่นี้เลย! (ต้อง Config .env ตัว ETHERSCAN_API_KEY ก่อนนะครับ)</p><pre>npx hardhat verify --network ropsten 0x8b53e7A4aBa76b8e2cdA11b0A3d7cBf5847C5aB6</pre><p>ทีนี้ไม่ว่าใคร ก็<a href="https://ropsten.etherscan.io/address/0x8b53e7A4aBa76b8e2cdA11b0A3d7cBf5847C5aB6#code">สามารถดูโค้ดของเรา และตรวจสอบด้วยตัวเองได้แล้ว</a>ครับ!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDti5MONsLpfxVt5_G9DDA@2x.png" /><figcaption>อ่านโค้ดได้เลย!</figcaption></figure><blockquote>⚠️ <strong>Challenge6</strong>: ลอง Verify ในเว็บ Etherscan ดู ได้เหมือนกันครับ</blockquote><blockquote>ซึ่งถ้า Deploy โค้ดเดิมเป๊ะไป มันจะมองว่าเราเคย Verify ไปแล้ว ทำให้เราลอง Verify ใหม่ไม่ได้ เลยขอ Challenge ให้แก้โค้ด โดยการเอา <em>console.log</em> ออกครับ เพราะอย่างไร <em>console.log</em>ใช้ได้เฉพาะในตอนเราเทสด้วย Hardhat เท่านั้นอยู่แล้ว ขึ้น Blockchain ไปไม่มีประโยชน์อะไร รังแต่ทำให้ Contract เราใหญ่ขึ้น</blockquote><h4>🕵🏻‍♂️ Checkpoint 5: ความรักจะยั่งยืนตลอดไป</h4><p>ถึงจุดนี้ เราก็จะได้ Smart Contract ที่ผ่านการทดสอบอย่างหนักหน่วง(?) ขึ้นไปอยู่บน Blockchain จริง ๆ แล้วนะครับ</p><p>แถมการ Deploy &amp; Verify ก็ยังง่ายดาย เพียงแค่รัน Command บรรทัดเดียวเท่านั้นเอง!</p><blockquote>⚠️ <strong>Challenge7</strong>: <a href="https://hardhat.org/tutorial/deploying-to-a-live-network">Deploy</a> &amp; Verify บน Mainnet ดูครับ (ถ้า Ethereum แก๊สอาจจะแพงกระเป๋าตังขาดกระจุย ลองดู​ Chain อื่น ๆ เช่น Binance Smart Chain, Polygon ดูได้ครับ)</blockquote><p>หากอยากลองยิง Smart Contract ส่งจดหมายรักบน Blockchain จริงดู ขอแนะนำให้รู้จักกับ<a href="https://medium.com/cleverse/web3-developer-journey-ethers-js-d7c2fdf141b">บทความสุดเทพ by Earth</a> ชาว Cleverse อีกคนนึงครับ จะได้ลองใช้ JavaScript ในการ Interact กับ Smart Contract ผ่าน <a href="https://docs.ethers.io/v5/">Ethers.js</a> ซึ่งง่ายมากกก</p><h3>🏁 Goal! ถึงจุดหมายแล้ว</h3><p>ยินดีกับทุกท่านด้วย ที่มาถึงจุดนี้ได้ครับ ขอปรบมือให้สองที 👏</p><blockquote>แปะ แปะ</blockquote><p>ขอ Recap อีกสักทีว่าเราได้ทำอะไรไปบ้างในบทความนี้นะครับ</p><ol><li>ขึ้น Project Hardhat</li><li>เขียน Smart Contract</li><li>Automated Test ผ่าน Hardhat</li><li>Deploy ด้วย Hardhat Script</li><li>Verify Code บน Blockchain Explorer (ด้วย Hardhat Script)</li></ol><blockquote>ใช่ครับ ผมก๊อปข้างบนมา <em>🌝</em></blockquote><p>ทั้งนี้ทั้งนั้น หนทางสู่การเป็นเซียน Solidity นั้นยังอีกยาวไกล เรายังเพิ่งเริ่มก้าวแรกไปด้วยกันเท่านั้น ยังมีเส้นทางสูงชันกว่าจะไปถึงยอดเขาครับ</p><p>ดังนั้นติดตามรอดูบทความ Advanced ยิ่งขึ้นจาก Cleverse ได้เลยครับ (เขียนเมื่อไหร่อีกเรื่อง 🎅🏼)</p><h4>Resources</h4><ul><li><a href="https://github.com/aikdanai/solidity-hardhat-101">GitHub - aikdanai/solidity-hardhat-101</a></li><li><a href="https://hardhat.org/tutorial">Hardhat&#39;s tutorial for beginners | Ethereum development environment for professionals by Nomic Foundation</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEhPeHeoKF88%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEhPeHeoKF88&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEhPeHeoKF88%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1eba04b1cd8d19b0aff7c366393e748c/href">https://medium.com/media/1eba04b1cd8d19b0aff7c366393e748c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ccbfa493b11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/solidity-hardhat-101-6ccbfa493b11">เขียน Solidity ..ชีวิตดีได้ด้วย Hardhat!</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web3 Developer Journey: ethers.js]]></title>
            <link>https://medium.com/cleverse/web3-developer-journey-ethers-js-d7c2fdf141b?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/d7c2fdf141b</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[ether]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Nutchanon Ploypray]]></dc:creator>
            <pubDate>Thu, 23 Jun 2022 11:26:55 GMT</pubDate>
            <atom:updated>2022-06-23T11:26:55.104Z</atom:updated>
            <content:encoded><![CDATA[<p>สวัสดีครับทุกคน วันนี้ผมจะมาแชร์ ประการณ์ในการทำงานเป็น Web3 Developer ของตัวผมกันหวังว่าจะเป็นแรงบันดาลใจ และแนวทางให้กับคนที่สนใจจะลองทำงานเกี่ยวกับ blockchain หรือ web3 นะครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lr1xdwqo38oGgBhY3_ErSw.png" /></figure><p>สำหรับใครที่ยังไม่รู้ว่า web3 คืออะไร blockchain คืออะไรแล้วหลงเข้ามาอ่านสามารถไปอ่านกันได้ที่บทความด้านล่างนี้เลยนะครับ</p><p><a href="https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-thai-version-6c8c24da3ca1">เช็คความพร้อมแพ็คความรู้เตรียมเข้าสู่โลกแห่ง Web 3.0 กัน</a></p><p>โดยที่ในบทความนี้จะสอนให้ทุกคนลองเขียนโปรแกรมเพื่อทำงานร่วมกับ Ethereum Blockchain กันครับ โดยที่เจ้าตัว Ethereum เนี่ยเป็น platform ที่เป็นตัวทำให้ blockchain มีความโด่งดัง และมี community และ นักพัฒนาเป็นอันดับต้นๆของ โลก blockchain เลยทีเดียว</p><p>Ethereum นั่นทำงานโดยการเชื่อมต่อ EVM (<a href="https://ethereum.org/en/developers/docs/evm/">Ethereum Virtual Machine</a>) Node หลายๆตัวเข้าด้วยกันเป็นเครือข่าย blockchain โดยที่จะ มี smart contract ที่เป็นเหมือน โปรแกรมอัตโนมัตที่จะทำงาน ตาม code ที่ถูกเขียนขึ้นโดยที่ทุกคนสามารถเข้าไปดูได้ว่า code นั้นทำงานอย่างไร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*3p9fNe6LqydYI-ERRY7gpQ@2x.png" /></figure><p>ซึ่งเราการที่เราจะทำการติดต่อหรือทำงานร่วมกับ Ethereum ได้นั้นเราจะต้องทำงานผ่าน node แต่ละตัวของเจ้า Ethereum นั่นเองโดยที่วิธีการหลักๆในการติดต่อ กับ node นั้นเราจะใช้สิ่งที่เรียกว่า JSON RPC</p><h4>JSON RPC คืออะไร</h4><p>JSON RPC ก็คือ วิธีการสื่อสารประเภทหนึ่งที่ใช้ในการติดต่อสื่อสารระหว่าง application โดยจะส่งเป็น format ที่เป็น JSON นั่นเอง</p><pre>{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;method&quot;:&quot;eth_gasPrice&quot;,&quot;params&quot;:[],&quot;id&quot;:73}</pre><p>แต่ว่าการติดต่อผ่าน JSON RPC นั้นก็ยังมีความยุ่งยากอยู่ระดับหนึ่งในแต่ละภาษาจึงได้สร้าง library ขึ้นมาเพื่อติดต่อกับเหล่า blockchain node ทั้งหลายขึ้นมาโดยตัวที่เราจะหยิบมาใช้ กันในบทความนี้ ก็ตามชื่อบทความเลยครับนั้นก็คือ EtherJs นั่นเองงงง โดยจะเป็นดั่งแผนภาพด้านล่าง</p><p><a href="https://docs.ethers.io/v5/">Documentation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*EPhgeADPBp3-aQHzDzhFfg@2x.png" /></figure><h3>เริ่มต้น Coding กันเถอะ</h3><p>tool แนะนำที่ใช้ลองเล่น ethers.js ก็คือออ</p><p><a href="https://web3playground.io/">Web3Playground</a></p><p>โดยที่อย่าลืมเปลี่ยน lib เป็น ethers.js กันนะครับ และสิ่งแรกที่เราจะเริ่มทำกันเกี่ยวกับ web3 ก็คือการสร้างตัวตน หรือว่า wallet กันครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPtAHWyjzE6qRl4mllf7Iw@2x.png" /></figure><h3>Wallet คืออะไร</h3><p>ในโลก blockchain นั้นเราจะสามารถ identify บุคคลใด ได้ด้วยสิ่งที่เรียกว่า key โดยที่ใครมี key นั้นจะเป็นผู้มีสิทธ์ในการทำธุรกรรม หรือว่า transaction ใดๆในระบบได้ทั้งหมด ดังนั้น ข้อควรระวังก็คือเราไม่ควรปล่อยให้ key ของเราหลุดเข้าไปใน internet โดยเฉพาะการ copy ส่งกันผ่าน chat application หรือว่า save เก็บเป็นไฟล์ใว้ใน computer เป็นอันขาด</p><blockquote>โดยเฉพาะเหล่า developer ทั้งหลายห้าม push key ของตัวเองขึ้น github กันนะครับ</blockquote><p>ได้ยินคำว่า key กันมาซักพักแล้ว ในทางปฏิบัติ key ที่พูดถึงก็จะหมายถึง private key นั้นเองโดยที่ wallet ของเราจะประกอบไปด้วยของ 3 ส่วน ก็คือ</p><ul><li>Mnemonic Phrase</li><li>Private Key</li><li>Public Address</li></ul><h4>Mnemonic Phrase (AKA Recovery phrase, Mnemonic seed)</h4><p>ถ้าคุณเคยมีประสบการณ์เกี่ยวกับการใช้ blockchain มาก่อน ไม่ว่าจะเป็น wallet ประเภทไดขั้นตนแรกสุดของการสร้าง wallet ก็คือการ random คำศัพท์ 12–24 คำขึ้นมาใช้ทำหน้าที่เป็น key ของเรานั่นเอง โดยทุกคนสามารถ อ่านคำอธิบายเต็มๆได้ <a href="https://coinmarketcap.com/alexandria/glossary/mnemonic-phrase">ที่นี่ </a>โดยที่ Mnemonic Phrase จะหน้าตาประมาณนี้เลย</p><blockquote>leave coral rent someone rival next jaguar decide cup copper tail xxxxx</blockquote><h4>Private Key</h4><p>หลังจากที่เราได้ Mnemonic Phrase มาในรูปแบบคำที่สามารถจดจำได้ง่ายแล้ว ทางปฏิบัติแล้วตัว Mnemonic Phrase จะถูกนำมาแปลงเป็น private key เพื่อใช้ในการ sign transaction ก่อนส่งขึ้น blockchain หน้าตาของ private key จะเป้นประมาณนี้</p><blockquote>0xa69544348a8f689a38fdcfe85fe91486fbd4c389b33335xxxxxxxxxxxxx</blockquote><h4>Public Address</h4><p>หรือว่าสิ่งที่เรียกว่า wallet address จะเป็นสิ่งที่เอาใว้ทำให้คนอื่นระบุตัวตนของเราได้ใน blockchain โดยที่ตามชื่อเลยก็คือ public เราสามารถเอาไปเผยแพร่ หรือบอกใครก็ได้เหมือนบอก เลขโทรศัพท์มือถือของเราเลยนั่นเอง</p><blockquote>0xD8fAB0D93a428d262d222Bc0F8701aB85a0E4942</blockquote><p>ใน code ก็จะน่าตาประมาณนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ca15d9dd25eb48cc2d1439b99bf9785/href">https://medium.com/media/6ca15d9dd25eb48cc2d1439b99bf9785/href</a></iframe><p>ผลลัพธ์ที่ได้ก็จะเห็นว่า wallet ที่ create ขึ้นมาก็จะประกอบไปด้วย 3 อย่างด้านบน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*WEAEJmnWZtjkR-L7m47qLw@2x.png" /><figcaption>create wallet result</figcaption></figure><p>ถัดมาเราจะทำการ import wallet หรือ recover wallet ของเราด้วย seeds และ private key กัน</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80b450a1d2396464fdd73487c8972a51/href">https://medium.com/media/80b450a1d2396464fdd73487c8972a51/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*MUkJuZqHpHfV38JWcJSkKQ@2x.png" /></figure><p>จะสั่งเกตได้ว่ากระเป๋า wallet1 ที่เราได้ import ด้วย private key จะไม่มี Mnemonic Phrase เพราะว่า private key นั้น generate มาจาก Mnemonic Phrase ตัว private key เลยไม่สามารถ recover ตัว seeds กลับมาได้นั่นเอง</p><h3>Connect to the Node</h3><p>ในขั้นตอนถัดมาเราก็จะทำการ connect กับ EVM node เพื่อเข้าถึงข้อมูลใน blockchain กันซึ่ง สิ่งที่เราจำเป็นต้องใช้ในการ เชื่อมต่อกับ node ก็คือ provider ซึ่ง provider นั้นจะสามารถทำให้เราใช้ wallet ที่สร้างขึ้นมา connect กับ blockchain ต่างๆได้โดยเปลี่ยนแค่ provider เท่านั้น</p><p>โดยที่เราสามารถใช้ เรียกใช้ provider ได้หลายวิธีเช่น</p><ul><li>ใช้ function getDefaultProvider แล้วเลือกด้วยชื่อ network เช่น</li></ul><pre>const networkName = &quot;mainnet&quot; // or other network like &quot;ropsten&quot;<br>const provider = ethers.providers.getDefaultProvider(networkName)</pre><ul><li>เลือก connect กับ node โดยตรงโดยใช้ RPC URL “https://mainnet.infura.io/v3/&quot;</li></ul><pre>const rpcURL = &quot;https://mainnet.infura.io/v3/&quot;<br>const provider = new ethers.providers.JsonRpcProvider(rpcURL)</pre><p>สำหรับที่ต้องการหา RPC URL อื่นๆเบื้องต้นสามารถหาได้จาก ที่นี่เลยครับ มี public node rpc endpoint ให้ใช้ พอสมควรเลย</p><p><a href="https://github.com/arddluma/awesome-list-rpc-nodes-providers">GitHub - arddluma/awesome-list-rpc-nodes-providers: A curated list of awesome Node providers and public PRC endpoints for Ethereum, BSC, Gnosis (xDAI), Fantom, Avalanche, KuCoin, Fuse, Harmony, Tezos, IoTeX, Arbitrum, Optimism and more :)</a></p><h4>Connect Wallet to Provider</h4><p>หลังจากที่เราได้สร้าง provider ขึ้นมาแล้วเราจะทำการเชื่อม wallet ของเราเข้ากับ provider เพื่อใช้งาน blockchain กัน</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fa139c494bca25234071cab5429a328/href">https://medium.com/media/2fa139c494bca25234071cab5429a328/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*MRdAue5KklZt42FEhT1qWQ@2x.png" /><figcaption>result</figcaption></figure><p>หลังจากที่ run code แล้วจะเห็นได้ว่าเราสามารถดึงข้อมูลของ chain ออกมาแสดงได้แล้ว และสำหรับใครหลายๆคน อาจจะสงสัยว่าค่าแต่ละค่ามีความหมายว่าอะไรผมจะมาอธิบายคร่าวๆให้ฟังกันครับ</p><p>EVM blockchain นั้นในความเป็นจริงใครใดๆ ก็สามารถที่จะตั้ง blockchain network ของตัวเองขึ้นมาได้ ซึ่งแต่ละ chain นั้นจะมี ข้อมูลประมาณนี้ก็คือ</p><ul><li>Chain Name หรือก็คือ ชื่อของ chain ที่ทุกคนน่าจะได้ยินชื่อเหล่านี้ผ่านหูมาบ้าง เช่น Ethereum, Binance Smart Chain, Polygon, Avalanche, Fantom โดยที่แต่ละชื่อก็อาจจะสามารถถูกเรียกหรือว่าใช้ ต่างกันนิดหน่อยเช่น ETH, BSC เป็นต้น</li><li>Chain ID หรือ Network ID จะคล้ายๆกับ Chain name แต่ว่าจะเป็นสิ่งที่ เวลาอ้างอิงถึง จะรู้ว่าเป็น chain ไหนแน่ๆ ดังนั้นเวลา เขียน code กันเราเลยจะใช้ chain id เป็นตัวที่อ้างอิงถึง chain ใดๆ</li><li>Native Currency หรือที่คนทั่วไปอาจจะเรียกกันในชื่อ Ether โดยที่ในแต่ละ chain นั้นจะมีค่าเงินที่เป็นค่าเงินหลักเพียงอันเดียวเท่านั้นเช่น ETH ( Ethereum) BNB(BSC) MATIC(Polygon)</li></ul><p>หน้าตาของ chain ใน code ก็จะเป็นประมาณนี้เลย</p><pre>{<br>  &quot;name&quot;: &quot;Ethereum Mainnet&quot;,<br>  &quot;chain&quot;: &quot;ETH&quot;,<br>  &quot;network&quot;: &quot;mainnet&quot;,<br>  &quot;nativeCurrency&quot;: {<br>    &quot;name&quot;: &quot;Ether&quot;,<br>    &quot;symbol&quot;: &quot;ETH&quot;,<br>    &quot;decimals&quot;: 18<br>  },<br>  &quot;chainId&quot;: 1,<br>  &quot;networkId&quot;: 1,<br>}</pre><p>สำหรับผู้ที่สงสัยว่า chain นั้นมีเยอะขนาดไหนสามารถเข้าไปดูได้ที่นี่เลยครับ</p><p><a href="https://www.evmchainlist.com/">EVMChainlist</a></p><p>สำหรับ chain ที่ใครหลายๆคนน่าจะได้รู้จักกันมาบ้างแล้วเช่น</p><ul><li>Ethereum Mainnet — Chain Id 1 — Currency ETH</li><li>Binance Smart Chain Mainnet — Chain Id 56 — Currency BNB</li><li>Avalanche C-Chain — Chain Id 43114 — Currency AVAX</li></ul><h3>Ropsten Testnet</h3><p>สำหรับ developer ทุกคนนั้นมั่นใจว่าทุกคนก็คงไม่อยากจะเขียน program แล้วลอง run กันใน production กันตั้งแต่ตอน dev ใช้มั้ยล่ะครับซึ่งสำหรับ EVM chain นั้นก็จะมี testing network อยู่มากมายซึ่งในวันนี้เราจะมาลอง dev กันใน Ropsten Testnet กัน</p><p>โดยที่เราจะเปลี่ยน provider กัน ด้วยการเปลี่ยนจาก mainnet -&gt; ropsten กันครับ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1daa5bbac8fae1dc6a50ac362d0a1206/href">https://medium.com/media/1daa5bbac8fae1dc6a50ac362d0a1206/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*YYvWV-ggNUDea8sdZ0N0vA@2x.png" /></figure><p>ถ้าทุกคนทำได้ถูกต้องจะต้องได้ chainId เป็น 3 ในตอนที่ log ออกมาดูกันนะครับ</p><p>ถัดมาเราจะไปขอรับ ether หรือว่า native currency กันเพื่อนำมาใช้ในการทำธุรกรรมต่างๆกันใน blockchain กันครับ โดยที่สามารถไปรับกันได้จาก faucet ของ Ropsten network ได้เลย <a href="https://faucet.egorfine.com/">ที่นี่</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmZyJAmZ0EkB7YrEz6rA8Q@2x.png" /></figure><p>และเมื่อเรา run code ของเราอีกครั้งเราก็จะเห็นว่าเรามี balance เพิ่มขึ้นแล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*c5UP8Kuh_HJgkX1fdl9p4w@2x.png" /></figure><p>ทุกคนอาจจะสงสัยกันว่าเมื่อกี้เรากดรับมา 10 ETH นี่นาทำไมเราถึงมีตั้ง 10000000000000000000 กันนะ คำตอบก็คือใน blockchain หรือ ภาษา solidity ที่ใช้เขียน code จะไม่มี ตัวแปรประเภท ทศนิยมนั่นเองครับ เขาก็เลยใช้ตัวแปรที่เป็นจำนวนเต็มนี่ล่ะครับ แต่ว่ากำหนด decimals ขึ้นมา เพื่อบอกว่า จำนวนเต็มที่แสดงนี้มีทศนิยมอยู่กี่หลักกันแน่ ยกตัวอย่างเช่น</p><p>ETH ที่มี Decimals 18<br>10000000000000000000 โดยที่ 18 หลักท้ายเป็นทศนิยม<br>จำนวนของ ETH ที่เรามีจริงๆก็คือ 10000000000000000000 / 10 ^18 = 10 ETH</p><p>สมมุติเรามี 0.254 ETH จำนวน balance ที่จะแสดงให้เราเห้นก็คือ 0.254 * 10 ^ 18<br>หรือเท่ากับ 254000000000000000 นั่นเอง</p><p>ซึ่ง ethers js ก็มีตัวช่วยในการแปลงเลขเหล่านี้ให้อ่านง่ายอยู่ด้วยนั้นก็คือ function</p><ul><li>formatUnits จะใช้ แปลง 10000000000000000000 -&gt; 10.0</li><li>parseUnits จะใช้แปลง 10.0 -&gt; 10000000000000000000</li></ul><p>ตาม code ตัวอย่างด้านล่าง</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7fd161f696155cc6f4ba1338c42b9ca/href">https://medium.com/media/b7fd161f696155cc6f4ba1338c42b9ca/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*pI_88OKotcuxO-8OQmLPCg@2x.png" /></figure><h3>Interact with Smart Contracts</h3><p>งานหลักๆของ การพัฒนา Decentralize Application (Dapps) หรือ เป็น Web3 developer งานหนึ่งเลยก็คือการทำให้ application ของเรา ติดต่อกับ smart contract เพื่อดึงข้อมูลและแก้ไขข้อมูลใน blockchain ได้</p><h4>Smart contract คืออะไร</h4><p>สำหรับ developer แล้ว smart contract ก็คงเปรียบเหมือน code ชุดหนึ่ง หรือ class หนึ่งที่ทำงานอยู่บน blockchain เราสามารถ read ค่าบางอย่าง และ ทำการ write หรือแก้ ข้อมูลใน code ชุดนั้นได้</p><p>ตัวอย่างที่เห็นได้ชัดที่สุดและ ค่อนข้างใช้กันอย่างแพร่หลายก็คือ crypto currency หรือเหรียญ cryto ต่างๆนั่นเอง โดยที่ smart contract ของเหรียญ ที่เราจะมาใช้ใน Ropsten testnet ก็คือ <br>เหรียญ: <strong>FaucetToken<br></strong>address<strong>: 0xFab46E002BbF0b4509813474841E0716E6730136</strong><br>link:<a href="https://ropsten.etherscan.io/address/0xFab46E002BbF0b4509813474841E0716E6730136">https://ropsten.etherscan.io/address/0xFab46E002BbF0b4509813474841E0716E6730136</a></p><h3>ทำความรู้จักกันก่อนกับ Blockchain explorer</h3><p>นับว่าเป็น tools ที่มีความสำคัญมากที่สุดตัวหนึ่งเลยสำหรับการใช้งาน blockchain ก็คือ blockchain explorer ซึ่งทุก blockchain จะมี web appclication ตัวนี้เอาใว้ใช้ในการ ดู Transaction, ดูเลข block, อ่าน code smart contract หรือแม้กระทั่ง interact กับ smart contract ก็ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d8WVK9VbDYqPipOjyc7M4g@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXDkLiOJzAiSCItdpfmuGA@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gcVRz9ChUSD1yxupoREWog@2x.png" /></figure><h3>Step 1: Read Smart Contract</h3><p>โดยทั่วไปเราสามารถอ่านค่าจาก smart contract ได้ผ่านทาง block explorer ผ่านทางหน้า contract</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*jfO15crS6ZH2khsmTgghKw@2x.png" /></figure><p>จากรูปจะสังเกตเห็นได้ว่าเราสามารถ read smart contract ผ่านจากหน้าเว็บได้โดยตรงเลยเช่น name และ totalSupply ของเหรียญๆนี้</p><p>สำหรับ การอ่าน smart contract ผ่าน ethers.js สามารถเขียนเป็น code ได้ดังนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62d33bca81817bba87487f94e91909bf/href">https://medium.com/media/62d33bca81817bba87487f94e91909bf/href</a></iframe><p>การที่เราจะเรียก function ต่างๆใน smart contract เราจะต้องมีสิ่งที่เรียกว่า ABI (Application binary interface) เรียกได้ว่าเป็น document หรือคู่มือในการ interact กับ smart contract ก็ได้ว่า function นี้มี parameters อะไรบ้าง type อะไรบ้าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*nJgraQTs9uh-PF3F-SVTxQ.png" /></figure><p>ซึ่งเราจะสามารถหาเจ้าตัว ABI นี้ได้จาก blockchain explorer ด้วยนั้นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jP4mM31TPWbNBlL96hQ15A@2x.png" /><figcaption>smart contract abi</figcaption></figure><p>ผลลัพท์ที่ได้ก็จะเป็นแบบนี้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*9bnqnvnegKAgz4pyOBAv_w@2x.png" /></figure><p>ซึ่งผลลัพท์ก็จะตรงกับการ read ผ่าน blockchain explorer เช่นกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*7OqlwCX61eFzI73NoJ-DtQ@2x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*GaYFOUPKOL-7TuCZLH75hg@2x.png" /></figure><h3>Step 2: Write Smart Contract</h3><p>ใน part ถัดมาเราจะมาลอง write contract กันดูบ้างซึ่งจะขอเกริ่นก่อนว่า ระหว่าง read กับ write เนี่ยมันต่างกันยังไง</p><h4>Write (Transaction)</h4><ul><li>ทำให้ state และ data ของ blockchain เปลี่ยน</li><li>จะถูก process ด้วย miner</li><li>ต้องใช้ ค่า Gas (Ether)</li><li>Asynchronous</li><li>ผลลัพท์ที่ได้จะเป็น transaction hash ซึ่งต้องรอ process ต่อ ไม่การันตีว่า transaction จะ success</li></ul><h4>Read</h4><ul><li>เป็นการอ่านข้อมูล จาก state ของ blockchain</li><li>ไม่เสียค่า Gas (Ether)</li><li>ผลลัพท์ที่ได้จะเป็น value ของ function ที่เราเรียกเลยทันที</li></ul><p>และในทางปฏิบัตเราจะเขียน code ต่างออกไปจากการ read ด้วย ก็คือ</p><ul><li>เราจะต้อง connect ตัว wallet (Signer) เข้ากับ contract เสียก่อน</li></ul><pre>const provider =  ethers.providers.getDefaultProvider(&quot;ropsten&quot;)</pre><pre>const wallet = new Wallet(privateKey)</pre><pre>const connectedWallet = wallet.connect(provider)</pre><pre>const tokenContract = new ethers.Contract(&quot;0xFab46E002BbF0b4509813474841E0716E6730136&quot;, abi,provider)</pre><pre>const contract = tokenContract.connect(connectedWallet)</pre><p>โดยที่ function ที่เราจะทำการ write จะมี 2 funtion ก็คือ</p><ul><li>mint(to address, value uint256)</li><li>transfer(to address, value uint256)</li></ul><h3>Mint</h3><p>จะเป็น function ที่เอาใว้ใช้เสกเหรียญขึ้นมาให้ walletใด wallet หนึ่ง โดยรับ parameters สองค่าคือ to (address ของ wallet ที่จะเสดเหรียญให้), value (จำนวนเหรียญที่จะเสกให้)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b17f540e5aa5f84d09e8bf13af3e702d/href">https://medium.com/media/b17f540e5aa5f84d09e8bf13af3e702d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*N2UFLjRAJO160KcIFTFPtw@2x.png" /></figure><p>ผลลัพท์ที่ได้จากการ write function จะได้เป็น ข้อมูลของ transaction ที่ส่งไปที่ blockchain โดยถ้าเรานำ hash ไป search ที่ block explorer จะสามารถตาม track ได้ว่า status ของเราทำงานเสร็จรึยัง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JXFoczdvrBEybIWDeInNjg@2x.png" /></figure><p>จากภาพจะเห็นว่าที่ transaction hash ที่เราได้เมื่อกี้เสร็จเรียบร้อยแล้ว และมีการ transfer token 1 FAU ไปที่กระเป๋าของเรานั่นเอง และเมื่อเราทำการ ดูค่า balance ของ ether และ token balance จะมีการเปลี่ยนแปลงไป</p><p><a href="https://gist.github.com/earth-np/74bb206261e6af768a9e71379b72fca8">https://gist.github.com/earth-np/74bb206261e6af768a9e71379b72fca8</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*AMqDCTo-AgGpqYTnbzjHoA@2x.png" /></figure><p>จากภาพจะเห็นได้ว่ามี 2 อย่างที่เปลี่ยนแปลงไปนั่นก็คือ</p><ul><li>Ether Balance ที่ลดลงเพราะว่าการ write smart contract นั้นจะต้องจ่ายค่า gas หรือก็คือ Ether นั่นเองจะสังเหตุได้ว่าจำนวนที่หายไปจะเท่ากับ Transaction Fee ที่แสดงอยู่ใน blockchain explorer</li><li>FAU Token Balance เป็นผลลัพท์ที่ได้จากการสร้างเหรียญ จำนวน 1 เหรียญมาที่กระเป๋าของเรานั่นเอง</li></ul><h3>Transfer</h3><p>จะเป็น function ที่ใช้สำหรับการโอนเหรียญกันระหว่าง wallet โดยที่จะรับ parameters เหมือนกับ function mint เลยก็คือ to และ value</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f77f4e6c5094736ebd3e469f02c29ea/href">https://medium.com/media/1f77f4e6c5094736ebd3e469f02c29ea/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*qSotjHoBN8BHdqhEsKIEMQ@2x.png" /></figure><p>หลังจากที่ทำ transaction เสร็จเรียบร้อยก็จะเห็นใน blockchain explorer เราได้ทำการส่งเหรียญ จาก wallet1 (0x94fcdc9…) -&gt; wallet2 (0x9c1b…) ได้สำเร็จแล้วนั้นเอง</p><h3>Summary</h3><p>ก็จบกันไปแล้วนะครับสำหรับ เส้นทางการเป็น Web3 Developer บทความแรก เรามาสรุปกันหน่อยดีกว่าว่าเราได้เรียนรู้เรื่องอะไรไปบ้างในบทความนี้</p><ul><li>รู้จัก Ethereum Blockchain</li><li>Wallet คืออะไร ประกอบไปด้วยอะไร</li><li>วิธีการ เชื่อมต่อกับ Node ของ blockchain</li><li>รู้จัก blockchain ที่เป็น EVM อื่นๆเช่น BSC, Polygon, Ropsten Testnet</li><li>การอ่านข้อมูลจาก blockchain เช่น ChainId, Ether Balance</li><li>ethers utils ที่ช่วยในการ แปลงหน่วยไปมาระหว่าง uint256 เป็น เลขทศนิยม</li><li>ฺBlockchain Explorer tool ที่สำคัญมากในการพัฒนา Dapps กับ Smart Contract</li><li>วิธีการ Read Smart Contract (FAU Token) เช่น name, totalSupply, balanceOf</li><li>วิธีการ Write Smart Contract การ Mint และ Transfer token</li></ul><p>หวังว่าบทความนี้จะเป็น แรงบันดาลใจและความรู้ให้กับคนที่สนใจในด้าน Blockchain, Web3, Defi นะครับ มีข้อสงสัยหรือว่าอยากจะแชร์หรือมี feedback เกี่ยวกับบทความ ทักมาคุยกันได้ครับ <a href="https://www.facebook.com/cleverse.team/">ที่นี่เลย</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7c2fdf141b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/web3-developer-journey-ethers-js-d7c2fdf141b">Web3 Developer Journey: ethers.js</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เช็คความพร้อมแพ็คความรู้เตรียมเข้าสู่โลกแห่ง Web 3.0 กัน]]></title>
            <link>https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-thai-version-6c8c24da3ca1?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/6c8c24da3ca1</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <dc:creator><![CDATA[Aikdanai Sidhikosol]]></dc:creator>
            <pubDate>Fri, 08 Apr 2022 11:50:26 GMT</pubDate>
            <atom:updated>2022-04-08T11:50:25.852Z</atom:updated>
            <content:encoded><![CDATA[<p>คำว่า Web 3.0 กำลังมาแรงและถูกพูดถึงมากขึ้นเรื่อยๆ บางคนเรียกว่ามันจะเป็นยุคสมัยใหม่ที่จะเปลี่ยนโลกอินเทอร์เน็ตจากที่เรารู้จักกันดีไปตลอดกาล</p><p>ว่าแต่… Web 3.0 นี่มันคืออะไรนะ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYS-_BjZv_fLXoXquIPwig.png" /></figure><p>หนทางในการบรรลุถึงตัวตนของมันอาจยาวไกล เรามาที่จุดสตาร์ท เริ่มด้วยการเล่าถึงวิวัฒนาการของอินเทอร์เน็ตกัน</p><h3>ยุคสมัยทั้งสามของอินเทอร์เน็ต</h3><h4>Web 1.0: อ่านได้เขียนไม่ได้</h4><p>ในยุคที่หนึ่งนี้ ผู้ใช้งานอินเทอร์เน็ตเกือบทั้งหมดเป็นเพียงคนเสพข้อมูลที่ผู้สร้างเว็บกำหนดไว้ให้เท่านั้น ไม่ได้มีช่องทางให้คนทั่วไปแบบเราๆเอาของขึ้นไปให้ผู้ใช้คนอื่นๆดู</p><p>หน้าที่ของเว็บไซต์ในยุค Web1 หลักๆแล้ว คือการให้ผู้สร้างเว็บสามารถเผยแพร่ข้อมูลไปให้คนเข้ามาดูได้ โดยเว็บในยุคนี้ที่อาจเห็นกันอยู่บ่อยๆคือ เว็บข่าว หรือเว็บ landing page ต่างๆ</p><p>เพื่อให้เห็นภาพ ขอยกตัวอย่างเว็บ <a href="https://cleverse.com/">Cleverse Landing Page</a> นะฮะ(เว็บสวยมากอยากให้ลองไปเยี่ยมดู 🥰) ซึ่งจะเห็นได้ว่ามันเป็นเว็บที่ทาง Cleverse ใส่ข้อมูลให้คนที่เข้ามาดูได้สัมผัสเท่านั้น แต่ไม่ได้มีช่องทางอะไรให้คนดูส่งข้อมูลกลับมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*cHVI0OHiXRiJb9_ijiUfXg.png" /><figcaption>ถนนวันเวย์แห่งข้อมูลของ Web 1.0</figcaption></figure><p>ประเด็นหนึ่งของ Web1 ที่น่าพูดถึงคือ เราที่เป็นผู้ใช้ทั่วไปไม่สามารถรู้ได้เลย ว่าข้อมูลบนเว็บที่เราอ่านอยู่เนี่ย มันถูกต้องหรือเปล่า? ข่าวบนเว็บนี้มันจริงไหม? หรือเจ้าของเว็บแอบปล่อย fake news มาไหมนะ? เพราะถึงมีคนรู้ว่าข้อมูลบนเว็บนี้มันผิด เค้าก็ไม่สามารถบอกคนอื่นได้เลย — ทั้งนี้อาจจะมองได้ว่า เว็บเฟคนิวส์เดี๋ยวก็โดนรัฐบาลแบน แต่สิ่งที่ต้องการสื่อคือถ้าอาศัยแค่เพียงความสามารถของ Web1 นั้น ผู้ใช้แบบเราๆไม่สามารถทำอะไรบนอินเทอร์เน็ตได้นอกจากเสพข้อมูล</p><h4>Web 2.0: อ่านก็ได้เขียนก็ได้</h4><p>ในยุคที่สองนี้ สิ่งที่แตกต่างจากยุคแรกก็คือข้อมูลและ content ต่างๆนั้นจะเกิดจากผู้ใช้งานทั่วไปแทนที่ผู้สร้างเว็บจะเป็นคนใส่เองทั้งหมด</p><p>Web2 นี้ผู้ใช้จะสามารถสร้าง content ของตัวเองขึ้นมาเพื่อให้ผู้ใช้คนอื่นๆสามารถดูได้แล้ว ไม่ว่าจะเป็นในรูปแบบ โพสต์รูปลงโซเชี่ยล เขียนบทความ(แบบที่ผมเขียนมานี่) คอมเม้นต์ในโพสต์ของสำนักข่าว และอื่นๆอีกมากมาย ข้อมูลที่ผู้ใช้สามารถเสพได้จะเกิดจากผู้ใช้ด้วยกันเองซะส่วนใหญ่ ไม่ใช่ผู้สร้างเว็บยื่นมาให้อย่างเดียว</p><p>ซึ่งการที่ผู้ใช้สามารถคอมเม้นต์หรือโพสต์บนโซเชี่ยลได้นี่ ก็ถือเป็นตัวอย่างหนึ่งที่แสดงให้เห็นว่า Web2 สามารถลดปัญหาเรื่องการเสพข้อมูลแบบทางเดียวใน Web1 ลงได้ เพราะถ้าหากเราเห็นว่าเว็บไหนมีข้อมูลที่ไม่ถูกต้อง เราก็สามารถคอมเม้นต์หรือโพสต์เตือนผู้ใช้คนอื่นๆได้เลย <em>…แต่คนอื่นๆเชื่อเรามั้ยก็อีกเรื่องนะ</em></p><p>อีกสิ่งที่เกิดขึ้นในยุคของ Web2 ก็คือ ผู้พัฒนาเว็บนั้นสามารถทำเว็บที่เปิดให้ผู้ใช้อินเทอร์เน็ตสามารถใช้งานระบบอื่นๆที่อยู่นอกอินเทอร์เน็ตได้ด้วย ตัวอย่างเช่น ระบบ Online Banking ที่ผู้ใช้โอนเงินให้กันและกันผ่านหน้าเว็บได้เลยแทนที่จะต้องไปธนาคาร — โดยสิ่งนี้เป็นเรื่องที่ยุค Web1 ไม่สามารถทำได้ เพราะเว็บในยุคนั้นยังไม่มีความสามารถให้ผู้ใช้ส่งข้อมูลความต้องการโอนเงินขึ้นอินเทอร์เน็ตได้</p><p>เพื่อความเห็นภาพ ขอยกตัวอย่าง <a href="https://www.linkedin.com/company/cleverse">หน้าบริษัท Cleverse</a> บน <a href="https://www.linkedin.com/">LinkedIn</a> ซึ่งในกรณีนี้ LinkedIn ถือเป็นผู้สร้างเว็บ ที่เปิดให้ผู้ใช้งานอย่าง Cleverse สร้างคอนเท้นต์ แล้วผู้ใช้คนอื่นๆก็เข้ามาอ่านได้</p><blockquote>อะไรนะ? โฆษณาไม่เนียน? …มาทำเป็นรู้ทัน <em>👁👄👁</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*UxYmWAISX2HXpmuaDBOJVA.png" /><figcaption>ถนนทูเวย์ทั้งอ่านทั้งเขียนของ Web 2.0</figcaption></figure><p>แต่ทั้งนี้ทั้งนั้น ก็ยังมีประเด็นเรื่องการปรับเปลี่ยนโยกย้ายปลอมแปลงข้อมูลของผู้สร้างเว็บได้อยู่ คอมเม้นต์เราอาจถูกลบหรือแบนทิ้งได้ หรือวันดีคืนดีระบบ Online Banking อาจจะหยุดให้บริการไปดื้อๆ ซึ่งผู้ใช้อย่างเราๆก็คงได้แต่นั่งหน้าตึงแล้วมูฟออน</p><p>อีกประเด็นสำคัญก็คือ: มีผู้สร้างเว็บปริมาณไม่น้อยที่ต้องการข้อมูลส่วนตัวของเรา ก่อนที่เราจะเข้าไปใช้บริการได้ หลังจากนั้นจะโดนเก็บข้อมูลอะไรอีกบ้างก็ตอบได้ยาก แถมข้อมูลเหล่านั้นจะถูกเอาไปใช้อะไรบ้างก็สุดเราจะรู้ได้</p><blockquote>จะไม่ยอมให้ข้อมูลก็ลำบากเพราะโอนเงินผ่านอินเทอร์เน็ตมันสะดวกเกินห้ามใจ</blockquote><p>ที่พูดถึงนี่ไม่ได้แปลว่าผู้สร้างเว็บจะทำอะไรนอกลู่นอกทางกันไปทุกรายนะครับ (ถึงแม้ปัจจุบันจะมีเคสเกี่ยวกับข้อมูลและความเป็นส่วนตัวไม่น้อย) แต่อะไรที่<em>ทางเทคนิค</em>แล้วสามารถเกิดขึ้นได้ มันก็มักจะเกิดขึ้นอยู่เสมอไปจริงๆ</p><h4>Web 3.0: อ่านเขียนได้ แถมอำนาจอยู่ในมือเรา</h4><p>และแล้วเราก็มาถึงยุคที่สาม</p><p>ซึ่งคำว่า “Web3” นี่ ผมคิดว่ามันยังไม่มีคำนิยามและขอบเขตที่ชัดเจนนัก ต่างคนต่างมีนิยามที่ให้กับมันที่ใกล้เคียงกัน แต่ก็มีจุดเล็กๆน้อยๆที่แตกต่างกันบ้าง</p><p>สำหรับบทความนี้ผมขอเล่าถึงนิยามของ Web3 สำหรับผมเองให้ฟัง</p><p><strong>Web3</strong> คือโลกอินเทอร์เน็ตที่ไม่มีใครเป็นเจ้าของมันอย่างแท้จริง ข้อมูลทั้งหมดนั้นไม่มีใครคนใดคนหนึ่งถือแต่เพียงผู้เดียว ไม่มีความลับและข้อมูลทุกอย่างสามารถถูกตรวจสอบความถูกต้องได้โดยทุกๆคน <strong>ทุกคน</strong>สามารถเข้าถึงอินเทอร์เน็ตและระบบทั้งหมดโดยไม่มีใครสามารถห้ามได้</p><p>ถ้าขอสามคำ ผมก็คงต้องขอยกคำยอดฮิตที่ใช้อธิบาย Web3 ขึ้นมา ซึ่งก็คือ: Decentralized, Permissionless กับ Trustless</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*IdXWA9sGDR-8nlKkE2sCgg.png" /><figcaption>โลกใหม่</figcaption></figure><p>มาลองขยายความกันดูครับ ทีนี้เพื่อความเห็นภาพขอยกตัวอย่างเทียบกับระบบ Online Banking ใน Web2</p><p><strong>Decentralized</strong> หมายความว่า แทนที่ธนาคารจะเป็นผู้สร้างระบบที่ถือข้อมูลทั้งหมดและเป็นผู้มีอำนาจอนุญาตให้เราสามารถใช้ระบบได้นั้น จะกลายเป็นเครือข่ายคอมพิวเตอร์(ที่เราก็เอาคอมพิวเตอร์เราไปเป็นหนึ่งในนั้นได้ถ้าต้องการ)เป็นคนถือข้อมูลแทน</p><p>ซึ่งในโลกของ Web2 นั้น เมื่อธนาคารเป็นคนเดียวที่เปิดระบบให้สามารถใช้งานบริการของเค้าได้ ถ้าหากระบบธนาคารเซิฟเวอร์ล่มหรือโดนแฮคไป ผู้ใช้บริการทุกคนก็จะได้แต่นั่งมองตาปริบๆ เพราะไม่มีหนทางอื่นให้เราสามารถโอนเงินของธนาคารนั้นๆได้เลย</p><p>แต่ในโลกของ Web3 นั้น หากเครื่องคอมพิวเตอร์เจ้าประจำที่เราใช้บริการเกิดอาการล่มไป เราก็สามารถไปเลือกใช้คอมพิวเตอร์เครื่องอื่นๆในเครือข่ายได้เลย เพราะทุกเครื่องก็มีข้อมูลเดียวกันอยู่และให้บริการได้เหมือนเครื่องประจำของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*BqJuZGnUlPeAtB0GxiUtSA.png" /><figcaption>Decentralized แล้วระบบเจ้านึงล่มก็ไม่หวั่น</figcaption></figure><p><strong>Permissionless </strong>หมายความว่า แทนที่ธนาคารจะเป็นผู้กุมอำนาจหนึ่งเดียวในการเลือกให้บริการเราตามแต่เงื่อนไขที่ธนาคารกำหนด เราจะสามารถเข้าใช้งานบริการกับคอมพิวเตอร์ในเครือข่ายเจ้าไหนก็ได้ โดยที่ไม่มีใครมีอำนาจมาขวางเราได้เลย เพราะถ้าเจ้านึงเลือกไม่ยอมให้บริการเรา เราก็ไปหาคนอื่นที่ยอมให้บริการแทนได้เสมอ(หรือเราจะไปเป็นหนึ่งในสมาชิกเครือข่ายเองเลยก็ยังได้)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*MeqcGuJl3f3y5gEyzFGAcw.png" /><figcaption>Permissionless แล้วไม่มีใครขวางได้</figcaption></figure><p><strong>Trustless</strong> หมายความว่า แทนที่จะเช่ือใจธนาคารผู้สร้างระบบที่ผู้จัดการเบื้องหลังเป็นมนุษย์ที่มีโอกาสผิดพลาด และผู้มีอำนาจในธนาคารมีอำนาจปรับเปลี่ยนปลอมแปลงทำอะไรกับระบบก็ได้</p><p>เราเปลี่ยนมาเชื่อใจโค้ดคอมพิวเตอร์และกลไกการตกลงระหว่างคอมพิวเตอร์ ในเครือข่าย— เรียกว่า Consensus —ว่าจะให้ผลประโยชน์กับคนที่ทำงานถูกต้อง และลงโทษคนที่ทำงานผิดหรือปลอมแปลงข้อมูล</p><p>กล่าวได้อีกอย่างว่า จริงๆคำว่า Trustless ไม่ได้หมายถึงเราไม่ต้องเชื่อใจใครเลย แต่เราสามารถแบ่งความเชื่อใจให้คนในเครือข่ายคนละนิดละหน่อยได้ ไม่ต้องเชื่อใครคนใดคนหนึ่งหมดใจแบบ Web2</p><p>หากสนใจเกี่ยวกับ Trustless และ Consensus แนะนำให้อ่าน<a href="https://academy.binance.com/en/glossary/trustless">บทความ</a>เพิ่มเติมครับ เนื่องจากจะอธิบายเรื่อง consensus ลงรายละเอียดในบทความนี้เกรงว่าจะยาวกันเกินไป</p><blockquote>นี่ก็ยาวแล้ว? อันนี้พยายามย่อแล้วจริงๆนะฮะ <em>🥲</em> ถ้าอยากอ่านบทความยาวของจริงเกี่ยวกับ Consensus ทักมาใน<a href="https://www.facebook.com/cleverse.team/">เพจ Cleverse</a> ดูได้(เขียนจริงเมื่อไหร่อีกเรื่อง)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OSV5kvsksTDzGEzArN5SsQ.png" /><figcaption>Trustless แล้วไม่ต้องเชื่อใครหมดใจ</figcaption></figure><p>สรุปเทียบระหว่างระบบใน Web2 vs Web3 จะออกมาตามภาพด้านล่างนี้ครับ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*dAY_3ACpOJD58VUlxbJKvg.png" /><figcaption>จับ Web 2.0 ชนกับ Web 3.0</figcaption></figure><p>จริงๆแล้ว ไอเดียและสิ่งที่ Web3 จะเป็นไม่ได้สุดแค่สามสิ่งนี้ แต่ยังมีเรื่องอีกเยอะแยะมากมายที่ผู้คนกำลังวาดภาพเกี่ยวกับอนาคตของอินเทอร์เน็ตด้วย เช่น การนำ AI หรือ Machine Learning มาต้มยำกับเว็บไซต์เพื่อทำให้ประสบการณ์ใช้งานดีขึ้น</p><p>…ก่อนที่จะออกทะเลต้มยำ ขอพาไหลไปสู่หัวข้อถัดไปสำหรับบทความนี้ครับ</p><blockquote>Web3 ไอเดียก็ดูเหมือนจะดีนะ แต่สามข้อนั้นมันทำได้จริงเรอะ?</blockquote><p>ทำได้จริงครับ ด้วยสิ่งที่เรียกว่า Blockchain</p><h3>Blockchain</h3><p>Blockhain คืออะไร? สำหรับนิยามสั้นๆขอยกคำพูดจากเว็บ Ethereum.org มาเลยแล้วกันครับ:</p><blockquote>A blockchain is a public database that is updated and shared across many computers in a network. — <a href="https://ethereum.org/en/developers/docs/intro-to-ethereum/#what-is-a-blockchain">Ethereum.org</a></blockquote><blockquote><strong>แปลไทย:</strong> Blockchain คือฐานข้อมูลที่เปิดสาธารณะให้ทุกคนสามารถเข้ามาดูได้ โดยที่มีเครือข่ายคอมพิวเตอร์เป็นคนถือข้อมูลและจัดการการเปลี่ยนแปลงของข้อมูล</blockquote><p>ทีนี้มาลองแกะคำว่า Block + chain แยกกันออกมาดูทีละอันกัน</p><h4>“Block” คือ?</h4><p>Block ก็คือกลุ่มข้อมูลธุรกรรมที่เกิดขึ้นต่อเนื่องกัน โดยธุรกรรมแต่ละอันจะบอกว่าสถานะของฐานข้อมูลจะต้องถูกเปลี่ยนไปอย่างไรบ้าง เวลามีธุรกรรมใหม่เกิดขึ้น(เช่นผู้ใช้โอนเงิน)ก็จะถูกนำไปใส่ Block ซึ่งการที่ธุรกรรมนั้นจะเปลี่ยนแปลงฐานข้อมูลจริงๆ ต้องรอให้ทั้งเครือข่ายยอมรับก่อนว่า Block นี้ถูกต้องไม่มีการปลอมแปลงข้อมูล</p><p>ตัวอย่างธุรกรรมเช่น บัญชี A โอนเงินให้ บัญชี B 10 USD <strong>ทำให้ในฐานข้อมูล บัญชี A เงินต้องลดลง 10 USD และ บัญชี B เงินต้องเพิ่มขึ้น 10 USD</strong></p><h4>“Chain” ล่ะ?</h4><p>Chain เป็นกลไกที่บอกว่า Block ควรต้องถูกเก็บเชื่อมต่อกันเป็นเส้นๆและข้อมูลธุรกรรมภายในไม่สามารถถูกแก้ไขได้ โดยที่ทุกๆ Block จะมีวิธีการเข้ารหัสเพื่อเชื่อมไปยัง Block ก่อนหน้า เชื่อมย้อนไปเรื่อยๆจนถึง Block แรก — เรียกอีกชื่อว่า Genesis Block — ซึ่งการที่ Block ถูกเชื่อมต่อๆกันเป็นโซ่หนึ่งเส้นแบบนี้เลยมีชื่อเรียกว่า Blockchain นั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MyM4yZRH3jPpCSiat6u2pQ.png" /><figcaption>หน้าตาง่ายๆของ Blockchain</figcaption></figure><p>เวลามี Block ใหม่พยายามขอต่อที่ท้ายเชน คอมพิวเตอร์ — เรียกว่า Node — ในเครือข่าย ต้องยอมรับก่อนว่าธุรกรรมภายในถูกต้อง และ Block นั้นเข้ารหัสชี้ไปยัง Block สุดท้ายได้ถูกต้อง หลังจากเครือข่ายยอมรับ Block ใหม่นี้แล้วก็จะนำเอา Block มาต่อท้ายสุดของเชน เพื่อให้ Block ใหม่ในอนาคตมาต่อกับ Block นี้สืบเนื่องไป ​​(อ่านละเอียดได้<a href="https://ethereum.org/en/developers/docs/blocks/">ที่นี่</a>)</p><p>ทีนี้อาจจะมีคำถามผุดขึ้นในใจว่า <em>เข้ารหัส</em> นี่มันคืออะไรฉันงงใจจัง</p><p>มาดำดิ่งดูการทำงานของ Blockchain กัน</p><h4>Blockchain ทำงานยังไงของมัน?</h4><blockquote>หัวข้อนี้อาจจะลงลึกเกินไปบ้าง สามารถข้ามไปหัวข้อ Ethereum ได้เลยถ้าต้องการครับ <em>🥺</em></blockquote><p>เพื่อการอธิบายขอใช้ตัวอย่างระบบ Banking เหมือนเดิมครับ</p><p>เริ่มด้วย Blockchain โล่งๆเลย ฐานข้อมูลว่างเปล่า ไม่มีธุรกรรมใดๆ</p><p>จากนั้นมี 2 ธุรกรรมเกิดขึ้น:</p><ul><li>Alice ฝากเงิน 100 USD</li><li>Bob ฝากเงิน 50 USD</li></ul><p>จากนั้น Node ที่ Alice กับ Bob ใช้ ก็จะจัดการมัดธุรกรรมให้กลายเป็น Block แล้วสร้างสิ่งที่เรียกว่า <strong>“Hash”</strong> ขึ้นมาโดยการเข้ารหัสด้วยข้อมูลเหล่านี้: Hash ของ block ก่อนหน้า กับธุรกรรมทั้งหมดใน Block นี้</p><p>สามารถมองว่า Hash เป็นลายนิ้วมือของแต่ละ Block เลยก็ได้ — เหมือนเป็นผลลัพธ์จากการปั่นรวม DNA ของ Block ออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*z-cTYrmR6WLuzbSlyL6a_A@2x.png" /></figure><p>จากนั้น Node ก็จะส่ง Block นี้ไปให้เครือข่ายตรวจสอบความถูกต้องของ Block นี้ ซึ่งถ้าเครือข่ายยอมรับแล้วว่าถูกต้อง Block นี้ก็จะถูกนำไปต่อท้ายเชน แล้วคอมพิวเตอร์ทุกเครื่องในเครือข่ายก็อัปเดตเชนใหม่ให้เหมือนกัน</p><p>หลังจากนั้นแล้ว Alice ก็ทำธุรกรรมโอนเงิน 20 USD ให้ Bob</p><p>ซึ่ง Node ก็จะนำธุรกรรมดังกล่าวมาสร้าง Block 2 เพื่อเอาเข้าเชน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*U1q942gB3KF6SHevso32IQ@2x.png" /></figure><blockquote>ถ้าอยากรู้ว่าตอนนี้ Alice กับ Bob มีเงินอยู่เท่าไหร่บ้าง เราจะรู้ได้จากการไล่ทำธุรกรรมทีละอันตั้งแต่ Block 0 มาเลย</blockquote><p>ทีนี้ สมมติว่ามี Node หนึ่งพยายามโกง โดยการเปลี่ยนธุรกรรมอันแรกสุดเลย เพิ่มเงินที่ Alice ฝากจาก 100 USD เป็น 110 USD ล่ะ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*MopfaEzAKOe9eICi0-e64Q@2x.png" /><figcaption>โตไปไม่โกง</figcaption></figure><p>จากภาพจะเห็นได้ว่า คนที่พยายามเปลี่ยนแปลงข้อมูลใน Blockchain ไม่สามารถแค่เปลี่ยนธุรกรรมตรงๆแล้วจบ แต่ต้องไล่เข้ารหัส Block หลังจากนั้นใหม่<strong>ทุก Block </strong>— เพราะการเข้ารหัสนั้น ถ้าข้อมูลเปลี่ยนไปแม้แต่นิดเดียว ผลลัพธ์จะเปลี่ยนไปทันที — ซึ่งในทางเทคนิคแล้วการเข้ารหัสหนึ่งครั้งกินทรัพยากรเครื่องคอมพิวเตอร์ค่อนข้างมาก ยิ่งถ้า Blockchain ยาวมากๆแล้วต้องเข้ารหัสใหม่เยอะๆ จะกินทรัพยากรเยอะถึงขั้นที่ไม่คุ้มทำแต่อย่างใด</p><p>ทำไมไม่คุ้มทำ? เพราะว่าถึงแม้จะปั้นน้ำให้เป็นเชนใหม่ได้สำเร็จ การจะนำเชนที่ถูกปลอมแปลงนี้ไปไล่บอกทุกคนในเครือข่ายให้ยอมรับว่าเชนนี้ถูกต้องนั้นเป็นไปไม่ได้เลย โดยเฉพาะถ้าคนส่วนใหญ่รู้ว่าเชนที่ถูกต้องคืออะไรและไม่ได้อยากร่วมมือโกงด้วย (ซึ่งโดยกลไกผลประโยชน์แล้ว คนส่วนใหญ่ย่อมไม่อยากทำ ด้วยเหตุผลที่อธิบายไปใน Trustless)</p><p>การทำงานดังนี้ของ Blockchain จึงทำให้การทำฐานข้อมูลที่ทั้ง Decentralized, Permissionless และ Trustless เป็นไปได้จริงนั่นเอง</p><blockquote>ออกตัวก่อนเลยว่าอันนี้คือการอธิบายการทำงานของ Blockchain แบบพยายามย่อหนักมาก ถ้าอยากให้ดำดิ่งจริงๆ<a href="https://www.facebook.com/cleverse.team/">ทักมาได้ครับ</a></blockquote><p>ถัดไป อยากพูดถึง Ethereum แบบเร็วๆซักนิดครับ</p><p>ซึ่งเป็น Platform เจ้าที่ผมคิดว่าทำให้ Blockchain โด่งดังขึ้นและมีของให้ใช้มากมาย ไม่ใช่เป็นเพียงสกุลเงินแบบ <a href="https://www.investopedia.com/terms/b/bitcoin.asp">Bitcoin</a> ทำให้เราเข้าใกล้อินเทอร์เน็ตแบบ Web3 ที่แท้จริงขึ้นไปอีกก้าวนึง</p><h3>Ethereum</h3><p>เจ้า Ethereum เป็น Platform ที่ใช้ blockchain เป็นไอเดียหลัก เพื่อให้นักพัฒนาสามารถเข้ามาสร้างนวัตกรรมบน Blockchain ได้</p><p>ในโลกของ Ethereum นั้น จะมี Blockchain อยู่เส้นเดียวที่ทุก Node ในเครือข่ายยอมรับว่าเป็นเชนที่ถูกต้อง ซึ่งทุก Node ก็จะมีเชนที่หน้าตาเหมือนกันนี้คัดลอกเก็บไว้บนเครื่องตัวเอง</p><p>Node ใดๆก็ตามใน Ethereum สามารถขอให้ทั้งเครือข่าย คำนวณหรือทำธุรกรรมใดๆก็ตามได้ เช่น Alice ส่งข้อความให้ Bob หรือ Bob ขอกู้เงินจาก Alice — ซึ่งสังเกตว่าธุรกรรมไม่ได้สุดอยู่แค่การโอนเงินอีกแล้ว</p><p>ซึ่งการส่งข้อความหรือทำธุรกรรมอื่นใดที่ซับซ้อนนี้ โดยปกติแล้วผู้ใช้แบบ Alice ก็จะไม่ใช่คนนั่งคำนวณเอง ว่าธุรกรรมนี้จะเปลี่ยนแปลง Blockchain ไปยังไงบ้าง แต่มักจะเป็นชุดคำสั่งที่มีนักพัฒนาสร้างขึ้นมาให้ผู้ใช้สามารถเรียกใช้ได้ ชุดคำสั่งนี้เรียกว่า <strong>Smart Contract</strong></p><h4>Smart Contract? ชื่อดูจะเท่ ว่าแต่มันคืออะไร</h4><p>แบบที่กล่าวไปด้านบน มันคือชุดคำสั่งที่นักพัฒนาสามารถสร้างขึ้น และนำไปวางบน Blockchain เพื่อให้ทุกคนเรียกใช้ได้ โดยนักพัฒนาสามารถสร้าง Smart Contract ได้หลากหลาย ตั้งแต่ทำระบบธนาคาร ระบบกู้ยืมเงิน ระบบซื้อขายของ และอื่นๆอีกนับไม่ถ้วน</p><p>ซึ่ง Smart Contract จะเป็นโค้ด(โดยมากเขียนด้วยภาษา <a href="https://docs.soliditylang.org/">Solidity</a>) ทำให้การทำธุรกรรมใดๆผ่าน Contract นี้ จะเป็นไปตามโค้ดที่เขียนไว้เป๊ะๆ โดยที่ทุกคนสามารถดูได้ว่าชุดคำสั่งนี้ถูกเขียนไว้ยังไง จะเกิดอะไรขึ้นบ้างหากเราไปเรียกใช้ด้วย Input แบบนี้</p><p>สิ่งนี้ทำให้ผู้ใช้สามารถทำธุรกรรมที่ซับซ้อนได้ โดยไม่ต้องหลุดออกจากโลกของ Blockchain เลยทำให้การทำธุรกรรมใดๆบน Ethereum จะยังคงคอนเซ็ปต์ Decentralized, Permissionless, Trustless อยู่</p><p>ตัวอย่างคร่าวๆของชุดคำสั่งที่ Smart Contract ที่ทำงานแบบกระปุกน้องหมู — ฝากเงินเข้าไปแล้วจะถอนได้เฉพาะหลังจาก Deadline ที่กำหนด:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*J53xWCjEzkwx96lTNyiKXA.png" /><figcaption>ตัวอย่างชุดคำสั่งของ Smart Contract (ไม่ใช่โค้ดจริง 👀)</figcaption></figure><p>Smart Contract นี้ ถือได้ว่าเป็นอาวุธสำคัญที่สุดทำให้การสร้าง Application ที่ซับซ้อนบนโลกของ Web3 เกิดขึ้นได้จริงเลยก็ว่าได้</p><p>ซึ่งการที่ Ethereum เป็น Platform เจ้าแรกที่ทำให้ Blockchain สามารถถูกนำไปใช้ในเคสที่หลากหลายมากมายได้ โดยเฉพาะเมื่อเรามี Smart Contract ถูกพัฒนาขึ้นเพื่อตอบโจทย์ใหม่ๆอยู่อย่างไม่หยุดยั้ง ก็เรียกได้ว่ายิ่งผลักดันให้เราเข้าใกล้วันที่ยุคใหม่ของอินเทอร์เน็ตจะมาถึงเข้าไปทุกที</p><h3>ม้วนเสื่อเก็บหมอน</h3><p>Web 3.0 เป็นทิศทางที่อินเทอร์เน็ตกำลังพุ่งไปเพื่อเล็งจะคืนอำนาจแก่ผู้คน ส่งอำนาจจากกลุ่มเล็กๆของตัวตนใหญ่ๆสู่มือของผู้ใช้ทุกคน ขยับความเชื่อใจที่ต้องมอบทั้งหมดให้กับผู้สร้างเว็บไซต์ไปสู่เครือข่ายของคนที่เป็นผู้ใช้อินเทอร์เน็ตคนนึงเช่นเดียวกับเรา</p><p>เทคโนโลยี Blockchain ถือเป็นชิ้นส่วนหลักที่ทำให้เป้าหมายนั้นเป็นจริงได้ นำมาโดย Ethereum ที่แบก Smart Contract เป็นอาวุธสำคัญในการตอบโจทย์ที่มีคุณค่า เพื่อนำอินเทอร์เน็ตเข้าสู่ยุคใหม่ …<strong>Web 3.0</strong> ครับ</p><blockquote>ส่วนตัวแล้ว ผมเชื่อว่าบริการทุกอย่างบนอินเทอร์เน็ตไม่ได้จะกลายเป็น Web3 หรอกนะครับ เพราะ Application หลายอย่าง มันก็ไม่ได้ควรเป็น Decentralized, Permissionless, Trustless ขนาดนั้น คิดว่าจะเป็นการอยู่ร่วมกันของ Web1, Web2, Web3 ตามความเหมาะสมเสียมากกว่า</blockquote><blockquote>เป้าหมายของบทความนี้แท้จริงแล้วเพียงอยากอธิบายความหมายของ Web3 กับเทคโนโลยี Blockchain แค่นั้นครับ เพราะผมเชื่อว่า Blockchain ยังไม่ใช่ปลายทางของ Web3 แต่อย่างใด วันพรุ่งนี้อาจจะมีเทคโนโลยีเปลี่ยนโลกใหม่ๆผุดขึ้นมา ที่สามารถตอบโจทย์ของ Web3 ได้ดียิ่งกว่า Blockchain ก็เป็นได้</blockquote><p>จบแล้วฮะ สำหรับบทความนี้</p><p>จริงๆแล้วยังมีอีกหลายเรื่องมากที่น่าพูดถึง ทั้งเรื่อง Consensus, ข้อดีข้อเสียของ Blockchain แล้วมันกำลังถูกแก้ยังไงบ้าง, Ethereum 2.0… ไล่หัวข้อได้อีกสามหน้ากระดาษ</p><p>ถ้าอยากฟีดแบคบทความนี้ หรืออยากเห็นบทความเรื่องไหนเพิ่ม ย้ำอีกครั้งครับ; <a href="https://www.facebook.com/cleverse.team/">ทักมาได้</a></p><p>รอติดตามบทความถัดไปจาก Cleverse ได้เลยครับ</p><p><em>สปอยล์: เป็นบทความสำหรับ Developer แหละ</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c8c24da3ca1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/welcome-to-the-world-of-web-3-0-thai-version-6c8c24da3ca1">เช็คความพร้อมแพ็คความรู้เตรียมเข้าสู่โลกแห่ง Web 3.0 กัน</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เราจะวัดความรัก(ของ user)ได้อย่างไร]]></title>
            <link>https://medium.com/cleverse/user-retention-rate-basic-fe36d6ca59f?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe36d6ca59f</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[startup-marketing]]></category>
            <category><![CDATA[digital-marketing]]></category>
            <dc:creator><![CDATA[Kittichai Jirasukhanon]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 07:37:18 GMT</pubDate>
            <atom:updated>2022-01-14T06:20:44.403Z</atom:updated>
            <content:encoded><![CDATA[<p><em>บทความนี้เผยแพร่ครั้งแรกที่ </em><a href="http://bit.ly/2X7IHzT"><em>blog.cleverse.com</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tMoyQMjwGxNfdN9qgawvw.jpeg" /></figure><blockquote>“It’s better to have 100 people that love you than a million people that just sort of like you. Find 100 people that love you.” — Paul Graham</blockquote><p>บริษัทใดที่มี user รักในสินค้า/บริการของเรา บริษัทนั้น ๆ จะมี “แฟนคลับ” ที่มีพลังช่วยโปรโมทเรา และเป็นอ้างอิงให้คนอื่นหันมาใช้สินค้า/บริการของเราเพิ่มขึ้น</p><p><strong>แล้วเราจะวัดความรักได้อย่างไร?</strong></p><p>มี Metrics 2 ตัว ที่เรานิยมใช้วัดผลความรักที่ user มีต่อสินค้า/บริการ (ในส่วนถัดไปจะขอย่อเหลือคำว่าบริการ) นั่นก็คือ Retention Rate กับ Net Promoter Score</p><p><strong>Retention Rate</strong> คือ ตัวบ่งชี้ความต่อเนื่องการกลับมาใช้บริการของเรา ของ user</p><p><strong>Net Promoter Score</strong> คือ อัตราส่วนของ user ที่มีแนวโน้มจะแนะนำบริการของเราให้เพื่อนหรือคนรู้จักสูง ลบด้วย คนที่มีแนวโน้มจะแนะนำบริการของเราต่ำ</p><p>บทความนี้จะขอกล่าวถึงพื้นฐานของ Retention Rate กัน</p><h3>วิธีวัด Retention Rate</h3><p>หลักการวัด Retention Rate ก็คือ user ที่ใช้บริการของเราใน period นี้ มีกี่ % ที่ใช้เราใน period ถัดไป เช่น</p><p>สมมติว่า เรามีการใช้งานของ user เป็นดังนี้</p><ul><li>วันที่ 1 มี user A, B, C, D, E เข้ามาใช้บริการ</li><li>วันที่ 2 มี user A, B, F, G เข้ามาใช้บริการ</li></ul><p>ถ้าเราวัดผลราย 1 วัน โดยเริ่มนับจากวันที่ 1 จะได้ผลดังนี้</p><ul><li>วันที่ 1 = 100% เพราะถือเอา user วันนี้เป็นฐาน</li><li>วันที่ 2 = 40% เพราะมีเพียง A, B ที่กลับมาใช้บริการ จาก user 5 คนในวันแรก</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w9hPVAJ8nQnbjdr8.png" /></figure><h3>Retention Rate vs Engagement Rate</h3><p>Engagement เป็นอีกหนึ่ง metrics ที่นิยมพูดถึงร่วมกับ Retention</p><p>Engagement คือ ความถี่ในการใช้บริการของเรา ในขณะที่ Retention คือ ความต่อเนื่อง</p><p>ถ้าเปรียบเป็นการจีบกัน — engagement ก็คือ การนัดเจอ คุยโทรศัพท์ ส่วน retention คือ จะคบกันยาวแค่ไหน</p><p>ตัวอย่างเช่น ประกันรถยนต์​เป็นสินค้าที่ engagement ต่ำ (ซื้อปีละครั้ง อาจไม่มีการเคลมเลยเป็นเวลาหลายปี) แต่หาก user ยังซื้อต่อเนื่องทุกปี ก็สามารถมี retention ที่สูงได้</p><p>ในขณะที่ Diet plan มักเป็นสิ่งที่ engagement สูง (ในช่วงเห่อ) แต่ retention ต่ำ</p><p>นั่นทำให้หลาย ๆ กรณี เราจะสนใจ Retention มากกว่า Engagement เพราะ “ใช้ไม่บ่อย แต่เราอยู่ในใจเสมอ” ฟังดูดีกว่า “ใช้ซ้ำ ๆ แต่ไม่กลับมาใช้อีกเลย”</p><h3>Interval ในการวัด Retention Rate</h3><p>จากตัวอย่างข้างต้น หากเรามีข้อมูลวันที่ 3–4 เป็นดังนี้</p><ul><li>วันที่ 3 มี user A, B, E, F เข้ามาใช้บริการ</li><li>วันที่ 4 มี user C, G เข้ามาใช้บริการ</li></ul><p>หากเราเปลี่ยนมาวัดผลเป็นราย 2 วันแทน จะได้ว่า</p><ul><li>วันที่ 1–2 มี user รวม A, B, C, D, E, F, G</li><li>วันที่ 3–4 มี user รวม A, B, C, E, F, G ได้ retention เป็น 6 ใน 7 = 85.71% ทั้ง ๆ ที่ user ในวันที่ 4 ลดน้อยลง แต่ retention ก็กลับสูงขึ้น</li></ul><p>นั่นทำให้ระยะเวลาที่ใช้วัด มีผลต่อผลลัพท์เป็นอย่างมาก</p><p>เราควรเลือกระยะเวลาสั้นหรือยาว?</p><p>อยากให้กลับไปที่เจตนารมณ์ของการดู Retention Rate ก่อน — เราอยากรู้ว่า user รักเราหรือไม่? เราจะได้ปรับปรุงสินค้า/บริการของเราได้</p><p>ถ้าเราตั้งกติกาว่า user รัก คือ ต้องใช้เราทุกชั่วโมง เราก็คือคู่รักที่ demanding เกินไป สุดท้ายเราจะนึกว่าไม่มีใครรักเรา ทั้ง ๆ ที่จริง ๆ แล้วเขาอาจจะรัก</p><p>ถ้าเราตั้งกติกาไว้หย่อนเกินไป เช่น เจอกัน 2 ปีครั้งก็พอ เราก็จะเป็นคู่รักที่ประมาท รู้ตัวอีกทีเขาก็เลิกกับเราไปแล้ว</p><p>เราจึงควรเลือกระยะเวลาที่ใช้วัดผลให้ใกล้เคียงกับพฤติกรรมการใช้บริการที่เราคาดหวังให้ผู้ใช้เป็นให้มากที่สุด เช่น App Todo list อาจต้องวัดผลโดยใช้ระยะเวลาถี่กว่า App ซื้อตั๋วหนัง หรือ Google Maps ก็อาจตั้งเกณฑ์ห่างกว่า Uber เป็นต้น</p><p>สำหรับบริการใหม่ ๆ ที่ไม่มีข้อมูลว่า user จะใช้งานบ่อยแค่ไหน เราสามารถเลือกจากการดู user กลุ่มแรก ๆ ที่มีแนวโน้มการใช้งาน/feedback ที่ดี แล้วดูความถี่ของคนกลุ่มนี้เป็นเกณฑ์</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rdMRhQLSmJiv7H9b.jpg" /></figure><h3>Event ที่ไว้วัด Retention Rate</h3><p>สิ่งที่ต้องคิดถึงในการวัดผลอีกอย่างหนึ่ง ก็คือ เราจะเลือกกิจกรรม (Event) อะไรมาใช้วัด ว่า user ยังอยู่กับเราหากคุณเปิดร้านกาแฟ เราควรวัดผลที่ user เข้ามาซื้อกาแฟ หรือ แค่แวะเข้ามาในร้านก็นับแล้ว?</p><p>แน่นอนว่า ในเคสร้านกาแฟข้างต้น คนส่วนใหญ่คงตอบว่า ซื้อกาแฟ</p><p>บางธุรกิจ การวัด retention อาจจะไม่ง่ายอย่างนั้น เช่น</p><ul><li>Application ซื้อขายหุ้น — คุณจะนับที่คนเข้ามาเช็คราคาหุ้น หรือ ต้องเข้ามาส่งคำสั่งซื้อ/ขาย?</li><li>Tinder — คุณจะวัดผลที่ การเข้ามา swipe, จับคู่ได้ หรือ chat คุยกัน?</li></ul><p>และมีเคสที่ซับซ้อนกว่านั้น เช่น</p><p>ตัวอย่าง: user สมัครสมาชิกบริการหนึ่งไว้ ซึ่งเป็นบริการแบบรายเดือน (นึกถึง Netflix หรือ ค่าโทรศัพท์) แต่เราออกโปรโมชั่นลดราคาให้ถ้าจ่ายรายปี — สมมติว่า user 50% ซื้อแบบรายปีไว้ (เพราะโปรโมชั่นเราคุ้มมาก) เราก็จะเหมือนมี Retention 1 ปีตุนไว้ก่อนแล้ว</p><p>แต่ ถ้าปรากฎว่า user เหล่านี้ไม่ใช้บริการเราเลย (Engagement ต่ำ) นั่นทำให้ชีวิตจริงหาก user รู้ตัวว่าไม่ได้ใช้ ก็จะมีแนวโน้มยกเลิกการใช้บริการเราในปีถัดไปสูงมาก เพราะรู้สึกตัวว่าไม่คุ้ม — หากเราใช้ การจ่ายค่าสมาชิก เป็น event ในการวัด Retention เราก็อาจจะหลอกตัวเองได้</p><p>บริษัท telecom บางแห่งจึง active โทรหา user ที่การใช้งานต่ำกว่า package ที่เลือกไว้ เพราะรู้ข้อนี้</p><p>นี่เป็นเหตุที่ว่า การเลือก Event ในการวัด Retention นั้น ต้องเลือกอย่างระมัดระวัง หรือ อาจต้องใช้มากกว่า 1 event ในการวัดผล</p><h3>แนะนำเครื่องมือในการวัด Retention Rate สำหรับ (online product/service)</h3><p>เครื่องมือ basic ที่สุดที่หลายท่านอาจนึกถึง ก็คือ Google Analytics ซึ่ง ณ วันที่เขียนบทความนี้ (14 กุมภาพันธ์ 2019) มี Cohort Analysis ให้ลองเล่น</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3X6R1v8F7O1EXLHP.png" /></figure><p>อย่างไรก็ดี <strong>เราไม่แนะนำให้ใช้ Google Analytics! </strong>(อย่างน้อยก็ในขณะที่ features ยังมีอยู่แค่นี้)</p><p>เหตุเพราะ การเลือก event และดู user journey ของ Google Analytics นั้น มีข้อจำกัดเยอะมาก (หรือเราใช้ไม่เป็นก็ไม่รู้)</p><p>เช่น user 100% ในวันแรก ในความหมายของ Google Analytics คือ user ที่เราเลือกยิง event ใด ๆ เข้าไป และยังไม่มีวิธีให้เลือกเจาะจง event ซึ่งจะทำให้เราวัดผล Retention ได้ยากมาก เช่น สมมติว่าเรามี event ดังต่อไปนี้</p><ol><li>ใครก็ไม่รู้เข้ามา visit website</li><li>เริ่ม sign up ใช้งานเป็น user</li><li>เข้ามาใช้งาน features เป้าหมาย</li></ol><p>สิ่งที่เราควรดู คือ Retention Rate ของ ข้อ 3 จาก user ทั้งหมดในข้อ 2 — ไม่ใช่เอาข้อ 1 มาเป็นฐาน เพราะข้อ 1 อาจเป็นใครก็ได้ที่ยังไม่ได้รู้จัก product เรา และอาจจะยังไม่ได้เริ่มใช้งาน</p><p>ถ้าเปรียบเป็นร้านกาแฟ ข้อ 1 ก็คือ แค่เดินผ่านร้าน ข้อ 2 คือ เข้ามาลองชิม ข้อ 3 คือ ซื้อ</p><p>ถ้าเราเอาจำนวนคนที่แค่เดินผ่านร้านมาเป็นฐาน ค่า Retention ของเราจะต่ำ จนยากที่จะวัดว่า กาแฟของเรารสชาติดีไหม การให้บริการของเราดีหรือไม่</p><p>วันนี้เราอยากจะแนะนำเครื่องมืออีกอันที่ Cleverse ใช้อยู่ในขณะนี้: <a href="http://bit.ly/2X3iv9m">Amplitude</a></p><h3>Amplitude</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E6IsAH2gD9YSnlso.png" /></figure><p>Retention Analysis ของ Amplitude อนุญาตให้เราเลือก Event ตั้งต้นที่เรานับเป็นฐาน user ได้ (สังเกตจาก “First Event” ซ้ายบน) และ event ที่เราจะเลือกใช้วัดผล ว่า user ยังอยู่กับเรา (เช่น ถ้าเราเป็น App TODO List — เราอาจเลือก “First Event” เป็น “ลงทะเบียนสมาชิก” กับ “Return Event” เป็น “Create Task” เป็นต้น)</p><p>นอกจากนี้ ตัวเลือกด้านซ้ายมือที่เห็นข้างต้น ยังให้เราดู event แยกตาม user ที่เคยทำ​ action พิเศษอะไรบางอย่าง มาเปรียบเทียบกันได้ด้วย เช่น จากตัวอย่าง TODO List ข้างต้น เราอาจดึงข้อมูล User ที่เคยผ่าน event ที่ต่างกันมาเปรียบเทียบรวมกัน เช่น เลือก a) ที่เคยดู Tutorial b) ที่ไม่เคยดู c) ที่เคย redeem coupon ส่วนลด — เพื่อจะแยกดูได้ว่า กลุ่มไหนมีแนวโน้ม retention rate สูงกว่า ก็น่าจะแปลว่าเหตุการณ์นั้น ๆ อาจมีแนวโน้มจะดึงดูใจผู้ใช้งานได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*2nYEvUPmqExp0527.png" /></figure><p>นอกจากนี้ Amplitude ยังให้เราเลือกช่วงวันที่ได้อย่างละเอียด ทั้งแบบมาตรฐาน คือ เป็นช่วงกี่วัน หรือแบบเจาะจงวัน (เช่น อยากเห็น user ที่กลับมาในวันที่ 3 หลังจากเริ่มใช้งาน) ได้อีกด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZXzA9oWCca8oL4yW.png" /></figure><p>ถ้าสังเกตขวาบน จะเห็นคำว่า “Since Feb 5, 2019” — Amplitude อนุญาตให้เลือกวันที่ ในแบบ “ตั้งแต่วันที่ …” ได้ด้วย ซึ่งมีประโยชน์มากในกรณีที่คุณมีการ launch features ใหม่ ๆ อยู่เรื่อย ๆ และอยากวัดผลแยกตามวันที่ launch</p><p>Amplitude ยังมี features อื่น ๆ อีกมาก ถ้าสนใจลอง comment ที่ post ของบทความนี้ใน <a href="http://bit.ly/2tljhkw">Facebook page ของ Cleverse</a> — ถ้ามีคนสนใจเยอะ เราจะเขียนให้อ่านกันครับ</p><p>Disclaimer: Amplitude ไม่ได้ sponsor บทความนี้แต่อย่างใด แต่เราให้ NPS กับ Amplitude สูงมาก เราเลยอยากมาแชร์ให้ฟัง</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe36d6ca59f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/user-retention-rate-basic-fe36d6ca59f">เราจะวัดความรัก(ของ user)ได้อย่างไร</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving BigData with BigQuery (1/3): Intro]]></title>
            <link>https://medium.com/cleverse/solving-bigdata-with-bigquery-part-1-6e3af316a470?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/6e3af316a470</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sarin Achawaranont]]></dc:creator>
            <pubDate>Fri, 13 Apr 2018 06:05:19 GMT</pubDate>
            <atom:updated>2022-01-14T06:20:22.059Z</atom:updated>
            <content:encoded><![CDATA[<p>— Or how I get started with writing technical blogs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvCSND4tazFhtZJlqgBvTQ.jpeg" /></figure><p><em>The Thai version of this article is also available at </em><a href="https://blog.cleverse.com/2018/03/29/solving-bigdata-with-bigquery-1/"><strong><em>Cleverse Blog</em></strong></a><em> </em>:)</p><p>Managing and operating big data infrastructure sounds like a pain — from the time-consuming installation process, streaming large data in, to querying from these massive data set. Not to mention those delicate tune-up and maintenance required.</p><p>Introducing BigQuery, a fabulous tool in which we used it as our backbone at Cleverse, my workplace, to process and analyze Big Data.</p><blockquote>Cleverse, a tiny startups<br>with a goal to analyze enormous data<br>Where should we begin?</blockquote><p>It begins when one day, my boss came up with a new data product. He gained access to a large set of data, and set us on a mission to extract meaningful insights from these data.</p><p>This project begins we a team of few developers: three, including me. Almost everyone has zero experience in any data project. So we gained an opportunity to explore many data analytics tools on these data set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQnHFyi6QHctwVXrk4njZQ.jpeg" /><figcaption>Photo taken by <a href="https://www.flickr.com/photos/simplyrains/">me</a> :)</figcaption></figure><h3>I — Dealing with a big dataset</h3><p>Initially, we started with utilizing <a href="http://www.elastic.co/blog/elasticsearch-as-a-time-series-data-store">ElasticSearch</a>. Mostly because it can store both structured data type and unstructured data type. It also support every query we had in mind and provides a means for visualization with Kibana. However, we give up on it due to the increased costs and performance issues.</p><p>Afterward, we took a step back to explore alternative SQL/NoSQL solutions, traditional databases, namely: <em>MySQL</em>, <em>PostgresSQL, MongoDB</em>, and <em>Redis</em>. To sum it up, these are some of the issues we have with them:</p><ol><li><strong>Various performance issues<br></strong>Due to their structure, these databases require a vast amount of resources and gives a worse performance when dealing with a larger dataset. Without months of preparation or a costly infrastructure, the server may explode from dozens of a complex query. It also gets slower and slower when we put in more data, to the point that it’s not applicable. These issues can be fixed by improving the underlying infrastructure, such as increasing the RAM, using faster disks, or making replica sets. But well, at that point, the increasing costs are not worth it.</li><li><strong>Expensive to set up, maintain, and monitor <br></strong>My time also counts as costs. It’s no joke when your boss told me that the server is down, during his ongoing demonstration, while I’m enjoying my overseas trip during my holidays. Not to mention that time when I woke up in the middle of the night to monitor the server performance status and prayed it would be alright because the clients overseas were trying it. There’s also the time I need to study the installation process and the best practices for each tool. Then it gets even harder to determine which infrastructure to support them: a high-spec machine may be able to support almost every use cases, but since we want to build a product with a reasonable price tier, these are not a good choice. For us, a team of a few developers, these issues are time-consuming and they prevent us from developing other parts we would like to.</li><li><strong>In the end, it rejects all my data insertions<br></strong>We need to continuously stream a large chunk of data into the database all the day. There are duplicate rows from time to time. At one point the database can not take in any more data, and we have to slow the process down, or even give up on some data. Initially, we tried to solve it by increasing the specs of the machines that host these databases and by sharding, separating database server into smaller instances to spread the load. Then one day, these data got so large that we couldn’t make the database functions anymore.</li><li><strong>Predicting the costs (and the usage loads) is hard<br></strong>Before launching any new feature, we have to calculate the costs/loads and see if they’re worth it. But it’s hard to predict all the costs/loads beforehand — not without any historical usage statistics, an experienced data engineer, or a <a href="https://www.pokemon.com/us/pokedex/alakazam">Pokemon</a>. At that time I only given two pieces of information: <em>the characteristics of queries</em>, and <em>the affected parts of data</em>. It took me a while to measure those loads and came up with the usage costs for just one feature.</li></ol><p>After months of trial and error, I gave up and asked Google.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CVMr-jdaKimdHDpVSJK7dQ.jpeg" /><figcaption>I wish Google Assistant could help me like this in real life. sigh…</figcaption></figure><p>It then introduced me a new tool: Google BigQuery.</p><h3>II — Introducing Google BigQuery</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*a4wXrjd6ohL5BsXZIaFuKw.png" /></figure><blockquote>A fast, highly scalable, cost-effective and fully-managed enterprise data warehouse for analytics at any scale</blockquote><p>Google BigQuery is an enterprise data warehouse built on top of Google Cloud Platform. It’s serverless, no installations required. BigQuery works great with data of any size, from a tiny Excel spreadsheet to a data on the Petabytes scale, and can execute a complex query on those data within a few seconds</p><h4><strong>Usage</strong></h4><p>BigQuery supports <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax">SQL-like query</a>, which makes it easy to use, just like any basic database we all knows. It’s accessible via its <a href="http://bigquery.cloud.google.com/">web UI</a>, <a href="http://cloud.google.com/bigquery/docs/cli_tool">command-line tool</a>, or <a href="http://cloud.google.com/bigquery/docs/reference/libraries">client librar</a>y (Supports C#, Go, Java, Node.js, PHP, Python, and Ruby). On unsupported platforms, we can use it by sending a JSON request to its <a href="http://cloud.google.com/bigquery/docs/reference/v2">REST API</a>.</p><h4><strong>Serverless — Leave it to Google</strong></h4><p>BigQuery is built on top of Google’s BigTable and Google Cloud Platform. It requires virtually no installation, maintenance, and monitoring. No need to hire additional workers to take care of those. It’s a good choice for a small team like us. Furthermore, it scales to your data automatically with no additional costs on these features. The performance remains the same when my data gets larger and larger.</p><h4><strong>Connectivity and Integration</strong></h4><p>BigQuery also integrates well with other analytics tools. For instance, <strong><em>Hadoop </em></strong>and <strong><em>Spark </em></strong>can read or write data directly from BigQuery with the uses of Cloud Dataproc and Cloud Dataflow. Google also provides automatic transferring of data from other Google services, such as <strong><em>DoubleClick</em></strong><em>, </em><strong><em>AdWords</em></strong>, and <strong><em>YouTube Analytics</em></strong>. It also supports popular BI tools like <strong><em>Tableau</em></strong>, <strong><em>MicroStrategy</em></strong>, <strong><em>Looker</em></strong>, and <strong><em>Google DataStudio</em></strong> with no further setups required, so you can quickly create reports and dashboards straight away.</p><h4>Usage — When to use BigQuery?</h4><p>Due to its implementation, BigQuery supports <a href="https://wikipedia.org/wiki/Data_manipulation_language">DML</a> actions, but it isn&#39;t suitable for update/delete operations, so it shouldn&#39;t be used as an online transaction processing (OLTP) store. On the other hand, BigQuery works great as a data warehouse (LDAP) for a historical data, such as event logs, analytical data, or a time series data. ( — <a href="https://cloud.google.com/solutions/bigquery-data-warehouse">Further reading</a>)</p><blockquote>Based on my experience,<br>BigQuery ingests all these large data streams with virtually no constraints,<br>computes all my complex queries within a few seconds,<br>accepts parallel requests with ease.<br>We encountered almost no failure ever since we begin using BigQuery!<br>In short, it’s fabulous!</blockquote><blockquote><strong>Not to mention its costs.. woops..</strong></blockquote><h3>III — BigQuery: cost-effective ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*LUQwe7t82ymFH6yKY1PDVw.jpeg" /><figcaption>BigQuery pricing data from <a href="https://cloud.google.com/bigquery/pricing">https://cloud.google.com/bigquery/pricing</a></figcaption></figure><p>One of the things I love about BigQuery is its pricing model, which is pay-as-you-go. You only need to pay as much (data) as you use, with no minimums. There’s also a <a href="https://cloud.google.com/bigquery/pricing#free-tier">free tier</a> available for everyone. Its costs are mainly based on these criteria:</p><ul><li>Amount of existing data in the storage — $0.02 per GB, per month</li><li>Amount of inserted data — $0.05 per GB</li><li>The total amount of data used to process each queries — $5 per TB<br>(In my case, 90%+ of thecosts come from this)</li></ul><p>What’s so great about this? It makes me predict the costs easily based on those <em>two things</em> I know earlier: <strong><em>the characteristics of queries</em></strong>, and <strong>the affected parts of data</strong>. No need to think about those hard things like server costs, or any additional infrastructure monitoring costs. When a new feature arrives, I can predict all the prices by just taking a look at those queries and calculating how much data it needs.</p><p>This pricing model makes BigQuery a perfect choice when you have a large data sets, does not want to spend many costs on monitoring and managing, and need the system to be up and operating fast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwC2HaPZQ8ZbZjVVMK28Ng.jpeg" /></figure><p>BigQuery may seem like a cheap and a perfect tool, but wait,</p><p>Based on those numbers, it may costs you up to <strong>$5,000</strong> if you query a 500 GB data for 2,000 requests!</p><p>Well, there’s a workaround for you to lower the costs and may get them down to just $50 (probably), in which I’ll talk about in the later parts of this series :)</p><h4><strong>… to be continued in:</strong></h4><p>- Part 2/3 : BigQuery usage, constraints, and use cases<br>- Part 3/3 : BigQuery costs optimization</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e3af316a470" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/solving-bigdata-with-bigquery-part-1-6e3af316a470">Solving BigData with BigQuery (1/3): Intro</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เผยเทคนิคการทำ Prototype สำหรับ Startup ภายใน 1 คืนด้วย React]]></title>
            <link>https://medium.com/cleverse/%E0%B9%81%E0%B8%99%E0%B8%A7%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-prototype-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-react-95bdd41bed0a?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/95bdd41bed0a</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[prototyping]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[time-management]]></category>
            <dc:creator><![CDATA[Ranatchai Ch.]]></dc:creator>
            <pubDate>Mon, 08 Jan 2018 06:37:32 GMT</pubDate>
            <atom:updated>2022-01-14T08:46:39.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SgqzRLbwP8nS5aFhvjOXOw.jpeg" /></figure><p>จากบทความที่ TURBO เคยเล่าไว้ใน <a href="http://www.designil.com/startup-weekend-education.html">Startup Weekend แค่ 3 วัน 2 คืน ก็เหมือนได้ลองสร้าง Startup จริงๆ</a> เรื่อง Startup Weekend คืออะไรให้ไปอ่านในบทความนู่นนะ 555 พอมีคนถามมามากว่าทำไมถึงเขียนแอพได้เร็วจัง</p><p>ในบทความนี้ ผู้เขียนเลยจะมาเปิดเผยวิธีและเทคนิคทั้งหมดที่ใช้จากประสบการณ์ที่ได้มากจากการทำ Startup และใช้ ReactJS มากว่า 2 ปี มาสร้าง Prototype โดยใช้เวลาตั้งแต่เริ่มทำ Wireframe ถึงจบงานรวมแล้ว 14 ชม.</p><p><strong>Demo</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fzippy.gfycat.com%2FCraftyFastGerbil.mp4&amp;src_secure=1&amp;url=https%3A%2F%2Fgfycat.com%2FCraftyFastGerbil&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FCraftyFastGerbil-thumb100.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=video%2Fmp4&amp;schema=gfycat" width="222" height="386" frameborder="0" scrolling="no"><a href="https://medium.com/media/57aa2f95a9d57ef3234cf9b267a4f87f/href">https://medium.com/media/57aa2f95a9d57ef3234cf9b267a4f87f/href</a></iframe><p>ดูตัวอย่างคร่าวๆกันก่อน สามารถดูวิดิโอเต็มๆ จาก youtube ด้านล่างครับ หรือลองเล่นจริงได้ที่ <a href="https://costudy.firebaseapp.com/">https://costudy.firebaseapp.com/</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fx41GyDzxytA%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dx41GyDzxytA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fx41GyDzxytA%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e69ba31970e99fb0dcfbe86f0e07c858/href">https://medium.com/media/e69ba31970e99fb0dcfbe86f0e07c858/href</a></iframe><h4>บทความนี้จะพูดถึงอะไรบ้าง</h4><p>เนื่องจากบทความที่เกี่ยวกับ React นั้นมีเยอะแล้ว และผู้อ่านคงสามารถหาอ่านได้ไม่ยาก บทความนี้จะไม่ลง Detail เรื่อง Code นัก แต่จะโฟกัสในแง่ของ Developer คนนึงที่เลือก Tool ที่ตัวเองถนัดที่สุดมาใช้ และเล่าถึงการทำงานร่วมกับ Designer และกับฝั่ง Business Team รวมทั้งการบริหารเวลาที่ทำให้สามารถปล่อยผลงาน ได้ทำเวลาที่กำหนด</p><p><strong>1. ทำไมเราถึงต้องทำ Prototype กันนะ</strong></p><ul><li>บทนี้ ผู้เขียนอยากชี้ให้เห็นถึงเหตุผลก่อนว่าทำไม เราถึงต้องทำ Prototype</li></ul><p><strong>2. ทำไมถึงไม่ใช้ Tool ที่ออกแบบมาเพื่อทำ Prototype โดยเฉพาะ</strong></p><ul><li>Tool สำหรับทำ Prototype โดยเฉพาะก็มีอยู่เยอะ ทำไมผู้เขียนถึงไม่ใช้</li></ul><p><strong>3. การทำ Prototype ด้วย React และคำถามที่ถูกถามบ่อย</strong></p><ul><li>บทนี้เป็นบทความสำหรับ Developer แล้ว ว่าทำต้องเป็น React ถ้าไม่ Geek พอแนะนำให้ข้ามไป</li></ul><p><strong>4. การทำงานเป็นทีมกับ designer และฝั่ง business</strong></p><ul><li>จะพูดการทำงานเป็นทีม Product ที่ได้ จะไม่มี hero แค่คนเดียว</li></ul><p><strong>5. การบริหารเวลาการทำงาน</strong></p><ul><li>ปิดท้าย จริงๆแล้วผลลัพธ์ที่ดี เกินกว่า 50% เกี่ยวกับการบริหารเวลา</li></ul><h4>1. “Start With Why” ทำไมเราถึงต้องทำ Prototype กันนะ</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jw07CcTA9GXgB2GU6kyCsg.jpeg" /><figcaption>รูปภาพจาก <a href="http://blog.hubspot.com/customers/3-takeaways-from-start-with-why">http://blog.hubspot.com/customers/3-takeaways-from-start-with-why</a></figcaption></figure><p>ขอเปิดด้วยคำถามก่อนละกันครับ ว่าทำไมเราถึงต้องทำ Prototype กัน เราควรจะเข้าใจจุดประสงค์ของการทำกันก่อน แล้วเราจะสามารถตัดสินใจที่จะทำอะไรได้ดีขึ้น</p><ul><li><strong>เพื่อขายไอเดีย</strong> — Prototype ช่วนทำให้การไป pitching ขายไอเดียให้ลูกค้าได้ดีขึ้น การที่ลูกค้าสามารถสัมผัส website หรือ app จริงๆได้นั้น จะช่วยพิสูจน์ vision ได้ดีกว่าคำพูดนับพันๆ คำ</li><li><strong>เพื่อทดสอบไอเดีย</strong> — Wireframes, mockups และไอเดียที่เป็นลมปาก นั้น มันไม่สมจริงการทำ Prototype นั้นจะช่วยให้ทีม ทดลองและทดสอบกับผลลัพธ์ที่เสมือนจริง เมื่อเจอปัญหาและจุดบอดของไอเดียหรือ Design จะทำให้แก้ไข ได้รวดเร็วกว่า และยังช่วยให้ทีมเข้าใจตรงกันด้วย ว่าสิ่งที่ทีมต้องการมันหน้าตาเป็นยังไง โดยที่ไม่ต้องรองานจริงเสร็จ</li><li>ผู้อ่านสามารถ เข้าไปอ่านบทความนี้เต็มๆ ได้ที่ <a href="http://designshack.net/articles/graphics/how-why-prototypes-are-mandatory-for-good-design/">How &amp; Why Prototypes Are Mandatory for Good Design</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2WU8AZKVIOPSQXO3BelOA.png" /><figcaption>ที่มา <a href="http://designshack.net/articles/graphics/how-why-prototypes-are-mandatory-for-good-design/">http://designshack.net/articles/graphics/how-why-prototypes-are-mandatory-for-good-design/</a></figcaption></figure><h4><strong>2. ทำไมถึงไม่ใช้ Tool ที่ออกแบบมาเพื่อทำ Prototype โดยเฉพาะ</strong></h4><p>ยกตัวอย่างเช่น InVision, Origami หรือ FramerJS ออกตัวไว้ก่อนว่า แต่ละ Tool นั้นต่างก็มีข้อดีเสียต่างกัน ซึ่งผมลองใช้งานมาหมดแล้ว ถ้าให้ Review ให้ฟังทั้งหมดนั้นคงเขียนเป็นบทความใหม่ได้เลย ถ้าผู้อ่านสนใจ​ Tool เหล่านี้ สามารถไปอ่านเองได้ที่ <a href="https://medium.com/sketch-app-sources/five-app-prototyping-tools-compared-form-framer-origami-pixate-proto-io-c2acc9062c61#.taetjvbo7">Five app prototyping tools compared</a> ส่วนผมจะขอสรุปเอาแค่สั้นๆละกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PV348w3K7GTFjV8IUg3MOQ@2x.png" /></figure><p><strong>ข้อดีของการ Prototype ด้วย Code</strong></p><ul><li>ผลลัพธ์สมบูรณ์เหมือนกับแอพจริงๆ มากกว่า และสามารถส่งให้คนอื่นลองเล่นได้​โดยไม่ต้องบอกวิธีใช้อย่างละเอียด</li><li>การ Prototype ด้วย Code นั้นมี Flexibility สูงกว่า สามารถ Custom รายละเอียดหรือเพิ่ม Feature ได้ดีกว่า ทำให้รองรับการเปลี่ยนแปลง Requirement ได้ดีกว่าด้วย ผมจึงสามารถเริ่มทำไปพร้อมๆ กับ Wireframe ที่ฝั่งทีม Design ยังทำได้ไม่สมบูรณ์ได้เลย</li><li>เหมาะกับการแสดง flow การทำงานที่เยอะ หรือเป็น feature ที่ extend ต่อจากงานเดิม</li></ul><p><strong>ข้อเสีย</strong></p><ul><li>ต้องการความคล่องแคล่วในการ code สูง เพื่อที่จะกำหนดได้ว่างานจะออกมาเสร็จได้ตามเวลาแค่ไหน</li><li>ถ้า flow ของผลลัพธ์น้อยจะไม่ค่อยคุ้มเวลาที่ใช้เท่าไหร่ ยกเว้นเป็นการ extend ต่อจากของเดิม</li><li>ต้องทำงานเป็นทีม ต้องประกอบด้วย Project Owner, Developer และ Designer แทบจะไม่สามารถทำออกมาได้ด้วยตัวคนเดียวได้เลย เพราะฝั่งนึงต้อง Focus ในทาง Design อย่างเดียวและอีกฝั่งก็ Focus ด้าน Develop อย่างเดียวและต้องมีคนคอยคุมภาพรวมอีก</li><li>ซึ่งถ้าใช้พวก <a href="http://www.invisionapp.com/">InVision</a>, <a href="https://facebook.github.io/origami/">Origami</a> หรือ <a href="http://framerjs.com/">FramerJS</a> Designer จะสามารถทำได้ด้วยตัวคนเดียวได้เลย</li></ul><h4><strong>3. ทำไมถึงเลือก React ในการทำ Prototype</strong></h4><p><strong>[GEEK ZONE] คำเตือนสำหรับคนที่ไม่ใด้สนใจเรื่อง Coding ให้ข้าม Section นี้ไป</strong></p><ul><li>พอผลลัพธ์เป็น web เราสามารถที่จะแชร์ผลลัพธ์ออกให้คนดูได้โดยง่าย</li><li>React มีความสามารถในการแบ่งเป็น component ย่อยได้ดี โดย component ที่ถูกสร้างด้วย React จะมี scope การทำงานอย่างชัดเจน จึงเพิ่มอิสระในการทำงาน ทำให้ผู้เขียนสามารถนำ components ต่างๆ ที่เคยเขียนไว้ใน Project เก่าๆ กลับมา reuse ใช้ได้</li><li>React hot reload อีกหนึ่งตัวช่วย ที่หลังจากสั่ง save จะทำให้ผลลัพธ์ใน Browser เปลี่ยนไปตามนั้นทันที ผู้อ่านสามารถเลื่อนลงไปดู ตัวอย่างการใช้งานจากด้านล่างจะเข้าใจได้ทัน และเรื่องนี้ทำให้เราทำงานได้เร็วขึ้น 2–3 เท่า มันหมดยุคเขียนโค้ดเสร็จที ต้องรอรันเป็นนาทีแล้วครับ :D</li><li>ผู้เขียนมีความชำนาญและความมั่นใจจากการใช้ประจำ :)</li></ul><p><strong>ข้อเสียที่พบจากการใช้ React ทำ Mobile Prototype</strong></p><ul><li>ผู้ใช้ต้องมีความคล่องแคล่วและประสบการณ์จาก HTML, CSS และ React สูง ถึงจะสามารถคิดทางออกและสร้าง Prototype ออกมาได้อย่างไม่ติดขัด</li><li>Component ที่ถูกสร้างมาเพื่อ Mobile ยังน้อยเกินไป ส่วนใหญ่ผู้เขียนสร้างขึ้นมาเองด้วย HTML และ CSS โดยเลือกทำแต่ component ที่ไม่ยากจนเกินไป</li><li>เพราะสร้าง Mobile Specific Component ขึ้นมาเอง ตอนนำไปรันบน device จริงมี bug ในการแสดงผลประปรายเพราะ device จริงมาจาก browser และ OS ที่หลายหลาย ไม่ได้ดีเท่าเวลาทำใน Chrome Emulator</li><li>ที่จริงตอนนั้นมีอีกตัวเลือกคือใช้ <a href="https://facebook.github.io/react-native/showcase.html">React-Native</a> ข้อดีคือเขียน Syntax เหมือน React ทุกประกาน livereload ก็มี Component ก็เป็น Native Component คุณภาพสูง</li><li>แต่สุดท้ายก็เลือก React ธรรมดา เพราะมีความคล่องกว่ามั่นใจกว่า และยังสามารถ Share ให้คนอื่นดูได้ ตรงกับจุดประสงค์หลักมากกว่า :)</li></ul><p><strong>ตัวอย่าง Code และเทคนิคที่ใช้</strong></p><p>จะนำเสนอตัวอย่างคร่าวๆ รวมถึงเทคนิคที่ใช้นะครับ ส่วน code ตัวเต็มก็มี link ให้โหลดอยู่ด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*UCKU0WN1gQyiwXkhTeeqTg.jpeg" /><figcaption>ใช้ Chrome Inspector เพื่อจำลองการทำงานของมือถือ</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fzippy.gfycat.com%2FFailingVengefulInchworm.mp4&amp;src_secure=1&amp;url=https%3A%2F%2Fgfycat.com%2FFailingVengefulInchworm&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FFailingVengefulInchworm-thumb100.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=video%2Fmp4&amp;schema=gfycat" width="866" height="512" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c2c63df6b364542723faf7f1688aaae/href">https://medium.com/media/8c2c63df6b364542723faf7f1688aaae/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*EyMDE2lFPXPVKGGH3XaOfw.jpeg" /><figcaption>Generate Data เพื่อใช้ในการ Prototype</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*ps9ZM0Cfb_suGRAgkfnXVg.jpeg" /><figcaption>การสั่ง pre load image ทันทีที่เปิด เวลาที่เรา navigate ไปหน้าอื่นๆ จะได้พบรูปที่เสร็จหมดแล้ว</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*OTNCxIeQr48LpK6I-KJjfg.jpeg" /><figcaption>แบ่ง Component ใหญ่ๆ เป็น Page Component แล้วสร้าง Page Transition ด้วย <a href="https://facebook.github.io/react/docs/animation.html">ReactCSSTransitionGroup</a></figcaption></figure><p>สำหรับ code โดยละเอียด ผู้อ่านสามารถลองเข้าไปโหลด Source code มาแกะและลองรันเองได้ด้วยขั้นตอนง่ายๆ ได้ตามลิ้งด้านล่าง</p><p><a href="https://github.com/Ranatchai/co-study-prototype">Ranatchai/co-study-prototype</a></p><h4><strong>คำถามที่ถูกถามบ่อย</strong></h4><p>section นี้จะตอบคำถามที่ผมมักจะโดนถาม เมื่อผมใช้ React หรือการเขียน code จริงๆ ในการทำ Prototype</p><p><strong>ปกติ React เค้าใช้ร่วมกับ </strong><a href="http://redux.js.org/"><strong>Redux</strong></a><strong>, </strong><a href="https://github.com/rackt/react-router"><strong>React-Router</strong></a><strong> นิ?</strong></p><ul><li>Redux และ React-Router ต่างก็เป็นสิ่งที่ดีและจะยิ่งเห็นผลชัดเจนกับโปรเจ็คขนาดใหญ่ แต่การใช้ของเหล่านี้ จะทำให้เสียเวลาเพิ่มขึ้น 2–3 เท่า</li><li>อย่าลืม จุดประสงค์หลักเราคือการสร้างขึ้นมา เพื่อนำไปทดสอบไอเดีย​ อะไรก็ตามที่ไม่ fit กับเป้าหมายนี้ ก็ไม่ควรทำทั้งนั้น</li></ul><p><strong>ทำไมถึงไม่ใช้ CSS Framework เช่น </strong><a href="http://getbootstrap.com/"><strong>Bootstrap</strong></a><strong> หรือ </strong><a href="http://foundation.zurb.com/"><strong>Foundation</strong></a></p><ul><li>ถ้าเราทำงานคนเดียว การหา CSS Framework มาใช้จะเหมาะสม เพราะเราจะได้ไม่ต้องเปลี่ยนหัวไปมาระหว่าง design mode กับ dev mode บ่อยๆ</li><li>แต่เมื่อเราทำงานกับคนอื่น (Designer) การที่จะให้เค้าทำงานภายใต้กรอบของ CSS Framework จะทำให้สร้างสรรค์ผลงานออกมาได้ไม่สุด และสุดท้าย เค้าก็จะทำงานออกมาใน style ของตัวเอง การใช้ CSS Framework จะกลายตัวถ่วงแทน</li><li>เว้นแต่ว่าถ้าตัว Designer มี UI Kits ที่ fit กับตัวเองอยู่แล้ว ผมก็ยินดีที่จะใช้งาน</li></ul><h4>4. การทำงานเป็นทีมร่วมกับ Designer และกับฝั่ง Business</h4><p>เพราะ Product ที่ได้จะไม่มี hero แค่คนเดียว skill ในการประสานงานกับคนอื่น เป็นสิ่งที่สำคัญมากถ้าอยากได้ผลลัพธ์ที่ดี นอกจากเราที่จะใน state ที่สมบูรณ์ที่สุดแล้ว เราต้องทำให้คนอื่นในทีมได้ทำในสิ่งที่ตัวเองถนัดที่สุดอย่างเต็มที่ด้วย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*o4hxwVTTbieIBavvmOydjg.png" /><figcaption>Wireframe Sketch version สุดท้ายที่ฝั่ง Designer ส่งมา ที่มา <a href="http://designil.com/startup-weekend-education.html">http://designil.com/startup-weekend-education.html</a></figcaption></figure><blockquote>จุดประสงค์ของการเขียนโค้ดคือการแปลงจาก Static Prototype ไปเป็น Interactive Prototype เพื่อให้การทดสอบไอเดีย สมจริงมากยิ่งขึ้น</blockquote><ul><li>จากการได้รับคำแนะนำที่ดีจาก <a href="http://www.designil.com/intro-to-ux.html">mentor พี่ดาริน</a> เราเลยร่วมกันสร้าง User Journey ที่เราจะนำไป Pitch ก่อน โดยเริ่มจากหน้าแรกไปถึงหน้าสุดท้ายผลลัพธ์ที่ได้ จะเป็นภาพร่างคร่าวๆในกระดาษ</li><li>แยกกันไปทำงานโดยอีกฝั่งเริ่มเอาภาพร่างจากกระดาษไปทำเป็น Wireframe ด้วย<a href="http://sketchapp.com/">โปรแกรม Sketch</a> แล้วค่อยๆเพิ่มรายละเอียดลงไป ส่วนผมก็เริ่มทำงานโดยเริ่มจากในกระดาษเหมือนกัน แต่ก็จะค่อยๆได้ Wireframe ที่ยังไม่ละเอียดนักมาเรื่อยๆ ผมก็จะเลือกทำส่วนที่เป็นโครงที่ไม่น่าจะเปลี่ยนแปลงก่อน</li><li>ผมชอบการทำงานกับคนที่ใช้ Sketch มาก เพราะตัว Sketch เองถูกออกแบบมาสำหรับการทำ UI โดยเฉพาะ ด้วย Feature ที่ใช้บ่อยๆ อย่างการ Export Assets, Copy CSS Style โดยพบว่าจะช่วยลดเวลาถึง 2–3 เท่าเทียบกับเมื่อก่อนที่ทำงานกับ Photoshop</li><li>พอผม Focus ที่จะเขียนโปรแกรมแล้ว ผมจะหยุดรับ Requirement จากฝั่ง Business โดยตรง โดยจะฝาก Designer ที่ทำหน้าที่เป็น Project Owner ด้วยในการคิดและตรวจสอบว่าการเปลี่ยน Requiement ในตอนนั้นจะมีผลดีผลเสียแค่ไหน และจะต้องแก้อะไรบ้าง</li></ul><h4>5. จริงๆ แล้วสิ่งที่สำคัญที่สุดคือ การบริหารเวลา</h4><p>สิ่งที่ผู้เขียนคิดว่าช่วยในการทำ prototype ให้เร็วที่สุด ไม่ใช่ Sketch หรือ React เลย แต่คือการบริหารเวลา</p><ul><li>ผมเริ่มจากการสอบถามเพื่อนที่เคยมางานแบบนี้แล้ว ว่า timeline ของงานจะเป็นประมาณไหน เพื่อที่จะได้สามารถบริหารเวลาได้ดีขึ้น</li><li>ไม่รีบเร่งที่จะเริ่มเขียน code แต่พยายามที่จะเก็บข้อมูล เข้าใจปัญหา และเข้าใจจุดประสงค์ที่เรากำลังสร้าง สุดท้ายได้ช่วยกันทำ User Journey มาก่อนถึงเริ่มต้นเขียน code จริง <a href="https://www.psychologytoday.com/blog/the-end-work-you-know-it/201405/achieving-your-objectives-starting-slow-in-order-go-fast">Starting Slow In Order to Go Fast</a> ครับ</li><li>กว่าผมได้เริ่มเขียน code ก็ 5 โมงเย็นเสาร์แล้วครับ โดยในช่วงแรก จะเน้นใช้เวลาไปกับการขึ้นโปรเจ็ค ทำตั้งแต่หน้าแรกไปจนถึงหน้าสุดท้าย โดยที่ยังไม่เก็บรายละเอียดให้ครบทุก flow และเน้นทำเฉพาะสิ่งที่ตัวเองมั่นใจว่าจะไม่เปลี่ยน อันนี้เสร็จตี 1 วันอาทิตย์รวมแล้วประมาณ 8 ชม.</li><li>แล้วคุยกับ Designer ว่า เก็บแรงไว้เผื่ออีกวันดีกว่า เพราะทีม Business กลับไปหมดแล้ว ไม่มีคนช่วยดูว่า ผลลัพธ์ไปถูกทิศทางรึเปล่า</li><li>วันที่สอง 9 โมงเช้าวันถัดมา ก็เริ่มจากการเอาผลลัพธ์ของเมื่อคืนให้ทีมดูก่อน พร้อมรับ feedback ต่างๆ ดูว่ามาถูกแนวทางไหม แล้วก็โฟกัสไปที่การแก้ไข Design และเก็บรายละเอียด รวมๆแล้วประมาณ 6 ชม.</li><li>สรุปว่าใช้เวลาตั้งแต่เริ่มเขียน code รวมแล้ว 14 ชม. ยังไม่หักเวลาคุยงานและเวลากินข้าว</li></ul><h4>สรุป</h4><ul><li>ในบทความ ผมจะพูดซ้ำหลายรอบมาก ถึงเป้าหมายของในการสร้าง Interactive Prototype ขึ้นมา นั่นคือการทดสอบไอเดียที่มีความสมจริง มีน้ำหนักสูง</li><li>แต่ถ้า idea นั้นๆ มีวิธีอื่น ที่จะ validate ผลลัพธ์ได้เร็วกว่าและได้ผลลัพธ์ที่เพียงพอ เราก็ไม่จำเป็นที่ต้องเขียน Code ออกมาเลยด้วยซ้ำ</li><li>หากเริ่มเขียนแล้ว เราไม่สามารถหลีกเลี่ยงการแก้งานได้ แต่สามารถลดมันได้ ด้วยการบริหารเวลาและการคุยงานที่ดี</li><li>ในเวลาที่จำกัด เราไม่ควรใช้วิธีที่หวือหวา หรือวิธีที่คนอื่นแนะนำแต่เราไม่คุ้นเคย แต่เราควรจะใช้วิธีที่เราถนัดที่สุด มั่นใจ ฝึกมาแล้วซึ่งคาดการณ์เวลาที่ใช้ได้โดยคร่าวๆ มากกว่า ซึ่งจริงๆ แล้ว Project ที่นำมาใช้ทำ Prototype ในงานนี้ ก็คือ Project ที่ผู้เขียนนำมาใช้ทำ Prototype หลายๆรอบแล้ว ในงานของตัวเอง หลายๆอย่าง จึงถูกปรับแต่งมาเป็นอย่างดีแล้วนั้นเอง</li><li>แต่ในช่วงที่เราไม่มีอะไรเร่งด่วน เราควรหาวิธีใหม่ๆ และปรับปรุงวิธีทำงานให้เร็วขึ้นเสมอ Always optimize your workflow ครับขอบคุณครับ :)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95bdd41bed0a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/%E0%B9%81%E0%B8%99%E0%B8%A7%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-prototype-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-react-95bdd41bed0a">เผยเทคนิคการทำ Prototype สำหรับ Startup ภายใน 1 คืนด้วย React</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ประสบการณ์ออกแบบโต๊ะไว้ใช้ในที่ทำงาน — Cleverse Desk 1.0 — How I designed my office desk]]></title>
            <link>https://medium.com/cleverse/how-i-designed-ergonomic-office-desk-cleverse-desk-eff1c65ce88e?source=rss----6e648ae9c812---4</link>
            <guid isPermaLink="false">https://medium.com/p/eff1c65ce88e</guid>
            <category><![CDATA[office]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[design-process]]></category>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Kittichai Jirasukhanon]]></dc:creator>
            <pubDate>Mon, 20 Nov 2017 09:44:51 GMT</pubDate>
            <atom:updated>2022-01-14T08:25:59.480Z</atom:updated>
            <content:encoded><![CDATA[<h3>ประสบการณ์ออกแบบเฟอร์นิเจอร์ไว้ใช้ในที่ทำงาน — Cleverse Desk 1.0 — How I designed my office desk</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9wpHW_YY_Z9hhWZQam9HWg.jpeg" /></figure><p>เนื่องจากตอนนี้ (May 2017) ผมกำลังออกแบบโต๊ะทำงาน version 2.0 อยู่ — เลยอยากเขียนบันทึกไว้ว่าออกแบบ version 1.0 ไว้อย่างไรบ้าง</p><p>ด้วยความเรื่องมากส่วนตัว ผมจึง(ร่วม)ออกแบบโต๊ะทำงานไว้ใช้เองในออฟฟิศ</p><p>เรื่องนี้ เริ่มจาก Version 1.0 ซึ่งออกแบบไว้ตั้งแต่ปี 2009</p><h3>รวบรวม Requirement</h3><p>ก่อนออกแบบ ผมรวบรวม requirement จากความชอบส่วนตัวและหลัก ergonomic ไว้ดังนี้</p><h4>ขนาด</h4><p>การออกแบบโต๊ะ ต้องคำนึงถึงการจัดวางและพื้นที่ในออฟฟิศด้วย</p><p>ผมตั้งใจให้โต๊ะมีขนาด 200cm x 90cm กะว่าให้นั่งสองคนแบบทแยงข้างกัน แต่ละคนจะมีพื้นที่ทำงานเป็นสามเหลี่ยมมุมฉาก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ObKyCm3jIuEy5wpus-XcBA.png" /><figcaption>กรณีเรียงโต๊ะเป็น 2 แถว ๆ ละ 3 ตัว</figcaption></figure><p>โต๊ะทำงานทั่วไป (แบบที่เป็นคอก partition) มีขนาด 120 x 60 ซึ่งถ้าใช้กับจอขนาดเล็ก ๆ (สมัยนั้นออฟฟิศทั่ว ๆ ไปใช้จอ 14–17 นิ้ว — ถ้ามีจอ 19-21 นิ้วก็ถือว่าหรูแล้ว) แต่ที่ออฟฟิศเราให้ทุกคนใช้จอ 24 นิ้วขึ้นไป ทำให้โต๊ะ 120 x 60 เป็นขนาดที่เล็กไป</p><p>การให้ทุกคนนั่งทแยงกันแบบนี้ จะทำให้แต่ละคนนั่งห่างกันถึง 2 เมตร! มีที่กว้างขวางสำหรับเหยียดแขนกันได้สบายใจ รู้สึกเป็นส่วนตัวสุด ๆ</p><h4>วัสดุ</h4><p>ผมต้องการให้ใช้วัสดุแสตนเลสและกระจก ข้อนี้มีหลายเหตุผล</p><ul><li>ผมเกลียดโต๊ะทำงานสำเร็จรูปทั่ว ๆ ไปที่มักใช้วัสดุไม้อัดปิดผิว</li><li>โต๊ะไม้มีความคงทนต่ำ ใช้ไม่กี่ปีก็เป็นรอย — ในขณะที่กระจกทำให้คุณสามารถทำงานโหด เช่น กรีดกระดาษ ได้โดยไม่ต้องกลัวเป็นรอย</li><li>Brushed stainless steel คงทนมาก แทบจะเรียกได้ว่าอยู่ไปจนคุณแก่ได้เลย แถมยังดูแพง (ราคาก็แพงจริง ๆ) และให้ feel แบบ industrial นิด ๆ แบบที่ผมชอบ</li></ul><h4>ต้องสอดที่วางแขนของเก้าอี้เข้าไปใต้โต๊ะได้</h4><p>ข้อนี้คือเพื่อผลทางด้าน ergonomic และเป็นเหตุที่เราต้องใช้กระจก— โต๊ะไม้โดยทั่วไปจะมีความหนาประมาณ 2cm เพื่อให้แข็งแรงพอ มีผลให้เวลาเรานั่งต้องเลือกทำอย่างใดอย่างหนึ่ง ระหว่าง</p><ol><li>สอดที่วางแขนเข้าไปใต้โต๊ะ ซึ่งเวลาวางมือบน keyboard จะทำให้มืออยู่บนโต๊ะ แต่แขนอยู่บนที่วางแขนของเก้าอี้ที่ต่ำลงไป 2cm ทำให้ข้อมือต้องงอ — เจ็บข้อมือ</li><li>ปรับที่วางแขนให้สูงเสมอโต๊ะ ทำให้ข้อมือไม่งอ แต่จะมีผลให้ตัวเราถอยออกมาข้างหลังมากขึ้น ทำให้ต้องโน้มตัวมาข้างหน้าเข้าหาจอเวลาพิมพ์งาน — ปวดคอ</li></ol><p>กระจกเป็นวัสดุที่บางแต่แข็งแรง ทำให้ถ้าคนเลือกใช้การสอดที่วางแขนใต้โต๊ะ จะไม่มีมุมตรงใต้ข้อมือมากนัก — หากนึกภาพไม่ออก ลองดูรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXO48J8BQsBiL0a2Yp0zFQ.jpeg" /><figcaption>โต๊ะที่เสร็จแล้ว — Cleverse Desk 1.0 — Production</figcaption></figure><p>การที่พื้นผิวทำด้วยกระจก ทำให้ที่วางแขนสอดเข้าไปได้แบบในรูป — สังเกตว่าแขนและมือเวลาพิมพ์งานอยู่ในระดับเดียวกันพอดี</p><p>ทั้งนี้ หากใช้ไม้ก็มีวิธีแก้ไขอยู่ แต่สมัยนั้นผมยังนึกไม่ถึง</p><p>หลังจากทำแบบและความต้องการ ก็ส่งให้สตูดิโอออกแบบเฟอร์นิเจอร์ที่เคยใช้ตอนแต่งบ้านทำแบบมาให้ ซึ่งแน่นอนว่ามืออาชีพย่อมจิ้มปัญหาที่เราไม่รู้ เช่น การโก่งตัวของคานเหล็ก การรับน้ำหนักของกระจก เป็นต้น</p><p>ได้แบบ version 1.0 มาแบบนี้</p><h3>Draft 1.0</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HR_Tf5Xvudg9umkR25OmSg.jpeg" /><figcaption>Cleverse Desk 0.1</figcaption></figure><p>ขาโต๊ะเป็นแบบพับเข้า — ในตอนแรกผมอยากให้เป็นแบบขาพับออก เหมือนโต๊ะ Atavola ของ B&amp;B Italia แบรนด์สุดโปรด ซึ่งให้ feel industrial นิด ๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*k6mvgGFy4n4Cwc31nUDy8Q.jpeg" /><figcaption>Atavola — B&amp;B Italia</figcaption></figure><p>แต่ด้วยความกลัวว่าจะเกิดโศกนาฎกรรมได้ง่ายเพราะหันคมกระจกออก เลยกลับที่พับเข้า ทำให้ความ unique หายไปเยอะ</p><p>แบบ 1.0 ไม่ผ่าน ด้วยเหตุผลว่า มีคานด้านหนึ่งที่อยู่ชิดขอบ ทำให้เจอปัญหาสอดเก้าอี้เข้าไปไม่ได้ (สตูดิโอนึกว่าจะนั่งทำงานฝั่งเดียวกัน)</p><h3>Draft 1.0_Final</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48VglNf1Bo9IpBSvkUzW_A.jpeg" /><figcaption>Cleverse Desk 0.2</figcaption></figure><p>Version นี้คานเข้ามาแล้ว แต่มีปัญหาด้านการรับน้ำหนัก</p><p>เนื่องจากจอในสมัยที่ออกแบบโต๊ะรุ่นแรกเมื่อหลายปีก่อนยังมีน้ำหนักมาก จึงมีผลให้ต้องกำหนด spec ให้รับน้ำหนักได้อย่างน้อย 40kg</p><p>ความยากคือ เราอยากใช้กระจกเป็น top โต๊ะ ทำให้ version นี้ที่เป็นคานเดี่ยวอาจไม่มีการรองรับกระจกที่ดี มีผลให้มีจุดเปราะง่าย</p><p>นอกจากนี้ การเชื่อมขาโต๊ะสองฝั่งด้วยคานเดี่ยว จะมีผลให้เหล็กบิดตัวได้ง่าย อาจทำให้สองฝั่งไม่ระนาบกันได้ในระยะยาว ขาดความแข็งแรง</p><h3>Draft 1.0_Final2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCguTCXfBkGGNudzJ8VO7A.jpeg" /><figcaption>Cleverse Desk 0.3</figcaption></figure><p>ปรับแบบโดยเอาคานเข้าไปอยู่ด้านใต้ ตรงนี้มี trade-off คือ ถ้าเอาคานเข้าไปตรงกลางมากไป ตรงขอบก็จะเปราะ แต่ถ้าเอาคานมาตรงขอบมากไปก็จะสอดเก้าอี้ไม่ได้</p><h3>Version 1.0 — Production</h3><p>Version จริงตอนผลิต เจอปัญหา(ที่ไม่รู้ว่าจริงหรือเปล่า) คือ การเอาคานหลบเข้าไปในโต๊ะ มีผลให้มุมโต๊ะไม่แข็งแรง โดยเฉพาะด้านที่เป็นตัวยู (จินตนาการว่ามองจากด้านแคบ มองเข้าหาโต๊ะ จะเห็นขาโต๊ะกับคานเป็นรูปตัวยูคว่ำ) โก่งได้ง่าย (คือ มุมแทนที่จะเป็น 90 ถ้าใช้ไปนาน ๆ อาจจะอ้าออกได้) เลยแก้แบบโดยมีคานเพิ่มที่พื้นเพื่อเชื่อมขาโต๊ะเข้าด้วยกัน ดังรูป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*x5Ufb6_SY95yLUof0kuEqA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*QSyshR6oiSoCEMDBhJp50g.jpeg" /><figcaption>Cleverse Desk 1.0 — Production</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*xJTotZGTHju5uNVmty6Pqg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*VASxVbHTwqEiGczu68-7jQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*4LOpDwfrxmPbl-CgKYiVaA.jpeg" /></figure><h3>Feedback — ปัญหาของ Version 1.0</h3><h4>ใหญ่ไปสำหรับ 2 คน เล็กไปสำหรับ 4 คน</h4><p>ปัญหา Classic ด้าน User Experience Design คือ User มักไม่ใช้อย่างที่เราออกแบบให้ใช้</p><p>อย่างที่บอกไว้ตอนต้น ผมตั้งใจให้ทุกคนนั่งทแยงกันแบบนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8_MxAfww2UF-37xeEnOwpw.png" /></figure><p>แต่พอปรับกันไปมา คนไม่ชอบนั่งแบบนี้ เพราะบอกว่าห่างไป คุยไม่สะดวก เลยเปลี่ยนมานั่งฝั่งเดียวกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XaW_geMzw8q7oT8JROSUoA.png" /></figure><p>คราวนี้ ทุกคนเลยมีที่แค่ 100cm x 90cm — แคบกว่าที่ทำงานทั่วไป ส่วนด้านลึก 90cm ก็ลึกไป ไม่ได้ใช้</p><h4>Mouse…</h4><p>กระจกมีข้อเสียใหญ่ เนื่องจากสมัยนั้นทีมของเรายังใช้ mouse ค่อนข้างมาก และ mouse ยี่ห้อดีที่สุดในสมัยนั้น (Razer Mamba) ก็ยังทำงานบนกระจกใสไม่ได้</p><p><em>วิธีแก้ไขก็คือ แจกแผ่นรองเมาส์ให้ทุกคนซะ!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DW7X7jwlaRxwmELcJMlGFQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*tY7_Y5Fcy88-osurvoOonQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*WP3rrc2uqUnTKDHyEEwZuw.jpeg" /><figcaption>Left: Razer Imperator + Razer Destructor — Center: Razer Lachesis + Razer ExactMat — Right: Razer Lachesis white + Sphex Mousesports Edition</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*kIkpS33LexoYm-FGQLjWDQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*BvbjKPioyFBJ_IW8xsmoLQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*63XqUMEQEOiemMNJnG9H-g.jpeg" /><figcaption>Left: Razer Aurantia + Microsoft Sidewinder X5 + Razer Sphex — Center: Right: Logitech G500, Sphex mouse surface and Razer Aurantia — Right — Razer Imperator + Razer Destructor Limited Edition (อันสุดท้ายไม่ได้ถ่ายที่ออฟฟิศ)</figcaption></figure><p>นอกเรื่องนิดหนึ่ง</p><ul><li>อย่าใช้ Mouse Razer — การใช้งานดีมากแต่อายุการใช้งาน 13 เดือนเป๊ะ หมด warranty ปุ๊บเสียเลย ซึ่งที่ผมเจอไม่ได้เป็นแค่อันสองอันนะครับ (สังเกตตัวอย่างที่ผมลง ที่ออฟฟิศในยุคนั้นใช้ Razer เยอะขนาดไหน) — อันที่ปวดใจที่สุด คือ Imperator ที่ผมชอบมากจนซื้อไว้ 2 ตัวที่บ้านกับที่ทำงาน มันเสียตอนเดือนที่ 13 พร้อมกันเลย (น่าจะตั้งไว้ใน firmware) — ตอนนี้ลดลงมาใช้ Logitech เป็นหลัก เพราะ warranty 3 ปี</li><li>ถ้าจะใช้แผ่นรองเมาส์​ การลงทุนกับ Destructor เป็นสิ่งที่คุ้มค่าที่สุด — ตอนนี้บางอันอยู่มา 8 ปี ใช้งานอย่างสมบุกสมบัน มีน้องบางคนเอาไปรองแก้วน้ำ (เวลาเห็นแล้วปวดใจมาก) ทุกวันนี้ยังใช้งานได้ดีเหมือนเดิม — บางคนชอบ ExactMat แต่สำหรับผมมันไม่ได้ฟีล — Sphex เป็นรุ่นที่กระจุยเร็วมาก ไม่คุ้มเงินเลย ส่วน Goliathus ที่เป็นผ้าก็เน่าเร็วมาก</li></ul><h4>ปัญหาอื่น ๆ ของกระจก</h4><p>กระจกไม่สามารถเจาะรูได้ง่าย ๆ ทำให้สายไฟต้องพาดบนโต๊ะ ทำให้ดูรกมาก</p><p>ด้วยความใสของกระจก ทำให้การเวลายืนมองทะลุลงไปถึงข้างล่างได้ — ผู้หญิงจะไม่ชอบโต๊ะแบบนี้ เพราะแอบนั่งไม่เรียบร้อยไม่ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2PeEpmDeIHMKGh1Tp_CTZA.jpeg" /></figure><h3>… Version 2.0</h3><p>ผมรับทราบปัญหาข้างต้นมาหลายปี แต่ดองเรื่องไว้ไม่แก้มาโดยตลอด จนตอนนี้มีการเพิ่มคนจนถึงจุดที่การเปลี่ยนโต๊ะจะช่วยชะลอการย้ายออฟฟิศซึ่งเป็นงานใหญ่กว่าไปได้ ผมจึงกำลังลงมือออกแบบโต๊ะ version 2.0 อยู่ในขณะนี้</p><p>เสร็จเมื่อไร ผ่าน User Acceptance Testing แล้วจะเอามาอวดให้ชมครับ</p><p>You might also</p><ul><li><a href="https://jirasukhanon.com/full-time-job-is-obsolete-20711ec04c38">การทำงานแบบ Full-time คือ concept ที่ล้าสมัย</a></li><li><a href="https://jirasukhanon.com/%E0%B8%AA%E0%B8%B4%E0%B9%88%E0%B8%87%E0%B8%97%E0%B8%B5%E0%B9%88-early-stage-startup-%E0%B8%84%E0%B8%A7%E0%B8%A3%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B8%81%E0%B9%88%E0%B8%AD%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%81%E0%B8%9A%E0%B8%B9%E0%B8%98%E0%B9%83%E0%B8%99%E0%B8%87%E0%B8%B2%E0%B8%99-tech-startup-3c98ffdbce7c">สิ่งที่ early-stage startup ควรคิดก่อนออกบูธในงาน Tech Startup</a></li></ul><p><em>Kittichai Jirasukhanon co-founded Cleverse, a venture builder, with people who have fun building the future. If you also think building/dreaming of the future a fun and meaningful purpose — let’s find a way we can work together.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eff1c65ce88e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cleverse/how-i-designed-ergonomic-office-desk-cleverse-desk-eff1c65ce88e">ประสบการณ์ออกแบบโต๊ะไว้ใช้ในที่ทำงาน — Cleverse Desk 1.0 — How I designed my office desk</a> was originally published in <a href="https://medium.com/cleverse">Cleverse, a Web3 Focused Venture Builder</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>