<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AnggaPurz</title>
    <description>The latest articles on DEV Community by AnggaPurz (@anggapur).</description>
    <link>https://dev.to/anggapur</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F911198%2Fdf753c6e-f509-420a-89eb-dbc7495296bf.jpg</url>
      <title>DEV Community: AnggaPurz</title>
      <link>https://dev.to/anggapur</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anggapur"/>
    <language>en</language>
    <item>
      <title>Build a Better Commitment between Client and Worker in Freelance Market with Blockchain Technology</title>
      <dc:creator>AnggaPurz</dc:creator>
      <pubDate>Sat, 24 Jun 2023 06:00:04 +0000</pubDate>
      <link>https://dev.to/anggapur/build-a-better-commitment-between-client-and-worker-in-freelance-market-with-blockchain-technology-4092</link>
      <guid>https://dev.to/anggapur/build-a-better-commitment-between-client-and-worker-in-freelance-market-with-blockchain-technology-4092</guid>
      <description>&lt;p&gt;Have you ever experienced payment problems in your freelance jobs?. Maybe your client doesn’t want to pay you after the work you’ve done or maybe they don’t want to pay you in the first place. It must be a bad experience in your career as a freelancer 😢. &lt;/p&gt;

&lt;p&gt;When this problem occurs, you must do something to make you get paid. From frequently contacting your client, send them the invoices to remind them of their responsibility and the bad one is preparing yourself for suing them in court 🙀 .&lt;/p&gt;

&lt;p&gt;The preventive action regarding this problem to occur is to make a legal agreement, but still, when a bad thing happens, you need to go to court, pay for a lawyer, and go through a long path of court. However it cannot guarantee you to get your payment 😱 .&lt;/p&gt;

&lt;p&gt;Another preventive action is to ask the client to put some deposit before starting any work. While it shows the client's good faith, it still has some problems. The worker can run away without needing to work on the projects or tasks. &lt;/p&gt;

&lt;p&gt;So, how to ensure the client has the money to pay the workers  or guarantee the workers not run away with the deposits? 🤔 &lt;/p&gt;

&lt;p&gt;We can utilize Smart Contracts that are written on top of blockchain technology to make it possible. Since smart contracts is a n immutable set of rules that are written on top of blockchain technology, it can be used to write a kind of contract that makes the client deposit their money in the contract and guarantee the workers not run away with their money.  On the other side, the workers are able to see the client’s good faith (ensure the client has the money).&lt;/p&gt;

&lt;p&gt;Here the scenario:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The client locks their money in a smart contract. Since smart contracts live in blockchain, the money must be in the form of coins/tokens.&lt;/li&gt;
&lt;li&gt;After the client locks their money in a smart contract, the worker will be able to see it and have confidence that the client has the money.&lt;/li&gt;
&lt;li&gt;While projects usually have milestones, we can use it on smart contracts as a mark of partial payment of the projects. Let say the cost of project is 10K USDT and have 10 milestones, after the workers achieve their first milestones, they will be able to withdraw 1K USDT as the payment (it will be good if it require both signatures for the withdrawal process)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It’s not always sunshine and rainbows, sometimes both parties cannot come to an agreement on the withdrawal process, it will make the workers unable to get their payment and the client’s money stuck on smart contracts. In this scenario, we will need someone to judge the case. This is not really “someone” (one person), we can utilize DAO to judge the case in a fair manner. &lt;/p&gt;

&lt;p&gt;I will elaborate on the DAO mechanism and reward for the voters in the other part.&lt;/p&gt;

&lt;p&gt;Enjoy the weekend 🏖&lt;/p&gt;

</description>
    </item>
    <item>
      <title>(Cross Token) Blockchain Bridge?</title>
      <dc:creator>AnggaPurz</dc:creator>
      <pubDate>Sat, 27 Aug 2022 16:49:00 +0000</pubDate>
      <link>https://dev.to/anggapur/cross-token-blockchain-bridge-2ika</link>
      <guid>https://dev.to/anggapur/cross-token-blockchain-bridge-2ika</guid>
      <description>&lt;p&gt;Emerging trends of blockchain &amp;amp; crypto have bring enormous blockchain network. Bitcoin network, Ethereum, Polygon, Solana, Binance, Arbitrum, and many other network, you can name it.&lt;/p&gt;

&lt;p&gt;While each network compete to be fastest, safest or cheapest network, a problem arise. They stand by themself. No communication between networks. &lt;/p&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0aBdp1Ey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b1ckj4g9ojkiketfoo6e.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0aBdp1Ey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b1ckj4g9ojkiketfoo6e.jpeg" alt="No Communnication" width="600" height="455"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Ethereum network is a famous network, it brought concept of smart contract to blockchain, it start era of DeFi, (Shit)Token Era and NFTs. It makes traffic on Ethereum network, and trigger spike on gas price. People charged by high fee for transfering token (PoW also takes credit for this fenomena). That was insane moment. &lt;/p&gt;

&lt;p&gt;This problem then inspire creation of other network. Some comes as L2 network (Network to support Ethereum) such as Polygon Network, others come as Ethereum Competitor.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xZFDe5hD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb34i36y6kt30uyw9d6z.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xZFDe5hD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hb34i36y6kt30uyw9d6z.jpeg" alt="Blockchain Everywhere" width="500" height="381"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;em&gt;A solution is just an opportunity for a problem to be born&lt;/em&gt;. &lt;/p&gt;



&lt;p&gt;Let say you invest in a DeFi Project and hold their tokens called "ShittyToken" on Ethereum Network. You enjoy creating transactions on this ShittyToken project and gain rewards. Suddenly, the gas price goes high. People stop using the project because they cannot make transaction caused by the gas price. Then the developer move their project to other Network, let say they move to NewEthereum Network because the gas is cheap, they re-create their ShittyToken and ask you to buy their ShittyToken on NewEthereum Network and ask you to start the transactions on NewEthereum Network.&lt;/p&gt;

&lt;p&gt;Will you do that?&lt;/p&gt;

&lt;p&gt;You might not doing that, because it means you need to spend your money to buy same ShittyToken (just in this time on different network). You possibly pay more expensive price to buy the token on new network &amp;amp; gain less token. And your ShittyToken on Ethereum now just a useless token.&lt;/p&gt;

&lt;p&gt;To prevent angry users, ShittyToken Developer start to figuring out how to make the token able to move from Ethereum Network to NewEthereum Network. And they create a Token Bridge. This Token bridge will facilitate the token to move between these networks. Some famous bridge are Polygon Bridge, Binance Bridge, Anyswap, Allbridge.&lt;/p&gt;

&lt;p&gt;As long as I see, all these bridge just moving the same asset between network and I didn't find any bridge that able to bridge and converting token at the same time. Let say you have $1000 ETH on Ethereum Network, and you see opportunity to gain 20% APY from staking on a ShittyToken Project on Arbitrum Network. All you need to do is bridge your ETH to Arbitrum, and then swap ETH to ShittyToken and then stake. looks like a big effort, huh?&lt;/p&gt;

&lt;p&gt;How about a bridge that can move your Tokens from a network/chain to other network/chain and it will convert your token to any token that you want?&lt;/p&gt;




&lt;h2&gt;
  
  
  Let's start with WHY
&lt;/h2&gt;

&lt;h3&gt;
  
  
  WHY the existing bridge not doing that?
&lt;/h3&gt;

&lt;p&gt;If that is really that good , why the existing bridge not doing it?&lt;br&gt;
In my opinion, they not doing it because they not own the money or liquidity pool. Even if they wanna doing it they need to handle the swap process and using DEX that not owned by them, and they cannot guarantee about how much token you will get after swap (cause the DEX is not owned by bridge, and everything is decentralized, it makes bridge cannot guarantee amount of token users will get in other chain, too much to risk).&lt;/p&gt;

&lt;h3&gt;
  
  
  WHY that kind of bridge needed?
&lt;/h3&gt;

&lt;p&gt;We can say blockchain is a new thing, many improvement needed, and this new kind of bridge is something that I believe can improve user experience. &lt;/p&gt;

&lt;h3&gt;
  
  
  How to make that kind of bridge?
&lt;/h3&gt;

&lt;p&gt;Let's call this bridge as "Cross Token Bridge" or CTB. We will make this CTB simple as possible, bridging 2 network that support smart contract. &lt;br&gt;
We only need to add simple swap process before bridging the tokens. &lt;br&gt;
We assumed both network are L1 network, and the bridge operator holding some amount of tokens on both network (Not like Polygon bridge, on polygon bridge they have authority to mint token in L2 network).&lt;br&gt;
Here the diagram :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rjn2LQ2U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mudwp4rblgs7iau549e3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rjn2LQ2U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mudwp4rblgs7iau549e3.png" alt="Cross Chain Bridge" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This bridge come with some challenges :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Bridge need to hold token on both sides&lt;/li&gt;
&lt;li&gt;If the token is not exist on destination chain, user cannot bridge the token&lt;/li&gt;
&lt;li&gt;Bridge monitor need to maintain tokens supply that owned/hold by bridge to prevent insufficient amount of token when user bridge their tokens&lt;/li&gt;
&lt;li&gt;User will be charged for the fees : Transaction fees on Source Chain (when user Approve and Trigger Swap&amp;amp;Bridge function), Transaction fee when The Bridge Monitor transfer token to user on Destination Chain (User cannot directly pay for this transaction because The Bridge Monitor is the initiator of the transaction. The solution might be taking additional fee when user trigger Swap&amp;amp;Bridge function)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>web3</category>
      <category>crypto</category>
      <category>blockchain</category>
      <category>bridge</category>
    </item>
    <item>
      <title>User Authentication with Web3</title>
      <dc:creator>AnggaPurz</dc:creator>
      <pubDate>Thu, 18 Aug 2022 16:28:00 +0000</pubDate>
      <link>https://dev.to/anggapur/user-authentication-with-web3-4he8</link>
      <guid>https://dev.to/anggapur/user-authentication-with-web3-4he8</guid>
      <description>&lt;p&gt;Hi, I'm assume you're familiar with Web3, and have understanding about cryptography, DeFi or Web3 Project.&lt;/p&gt;

&lt;p&gt;I will introduce you to a new way of User Authentication using Web3 technology (Actually using power of Cryptography).&lt;/p&gt;

&lt;p&gt;If you ever land yourself to DeFi or Web3 Project, you must be aware that the platform never force you to Login into platform. It's simply because in Web3, we don't store your personal information. We recognize you by your signature (We're not talking about your handwrite signature, it's about &lt;a href="https://en.wikipedia.org/wiki/Digital_signature"&gt;Digital Signature&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;You also must be aware that you will require to install a &lt;a href="https://www.investopedia.com/terms/b/bitcoin-wallet.asp"&gt;Wallet&lt;/a&gt; to join into Web3/Blockchain World. This wallet will be used to manage your private key, and used to sign your transaction that will be send to blockchain. (By any chance, &lt;strong&gt;NEVER SHARED YOUR PRIVATE KEY&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Currently, I have a "hybrid" project. I called this project "hybrid" because it utilize power of web3 but most the feature are web2.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PBtvLU_5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4yqwn3lwb4krarywpmrg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PBtvLU_5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4yqwn3lwb4krarywpmrg.jpeg" alt="What are you talking?!" width="880" height="606"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;It must be a bit confusing, I will give you a litte context. So, the Play to Earn games is getting hype in Web3 World. There is a lot of games like &lt;a href="https://axieinfinity.com/"&gt;Axie Infinite&lt;/a&gt;, &lt;a href="https://splinterlands.com/"&gt;Splinterlands&lt;/a&gt;, &lt;a href="https://www.sandbox.game/en/"&gt;Sandbox&lt;/a&gt; and many more. And my current project is a Play to Earn games, users will need to buy a NFT, and then used their NFT to play and gained reward. &lt;/p&gt;

&lt;p&gt;After a research that have been done by UX team, they found that most of crypto games are a bit annoying to players because it need to do a lot of signing using Wallet, and this submitting process to blockchain is not cheap (At that time, Gas Price on Ethereum was Crazy).&lt;/p&gt;

&lt;p&gt;Engineer team also consider that most of game data (data that generated when player play the games) is not necessary to be written on blockchain. So we decided to using NoSQL Database to store game data. And then UX team asking about how the user onboard to the games? Do they need to login using Email/Username &amp;amp; Password?. Well, login using email and password just not really "Web3 things".&lt;/p&gt;

&lt;p&gt;We want to identified the player without taking their personal information. So we decide to utilize the essential power of Blockchain. &lt;strong&gt;The Cryptography Signing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X_kg87pV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7i7d70vz8for3xqzajmq.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X_kg87pV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7i7d70vz8for3xqzajmq.jpeg" alt="Yohohohoo" width="231" height="218"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;So, I will show you how to make user authentication on &lt;strong&gt;EVM Blockchain Based&lt;/strong&gt;, using &lt;strong&gt;Ethers.js&lt;/strong&gt; &amp;amp; &lt;strong&gt;Metamask&lt;/strong&gt;. You can pick any framework for your Backend.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b-ev08B8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2sai10r90s3f6r6mndq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b-ev08B8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2sai10r90s3f6r6mndq1.png" alt="Web3 Login Mechanism" width="880" height="578"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  User request Nonce to Backend
&lt;/h4&gt;

&lt;p&gt;User will send request to Backend to retrieve information about User's &lt;a href="https://en.wikipedia.org/wiki/Cryptographic_nonce"&gt;Nonce&lt;/a&gt;. &lt;/p&gt;
&lt;h4&gt;
  
  
  Backend send Nonce to User.
&lt;/h4&gt;

&lt;p&gt;User will retrieve the Nonce. User will construct a message that contain information about the Nonce. Let say the nonce is 100, the message will be is &lt;code&gt;Hi I wanna play the Games | 100&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  User Sign Message &amp;amp; Wallet Generate Signature
&lt;/h4&gt;

&lt;p&gt;User need to sign a message, we will utilize ethers.js library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This nonce come from Backend
const nonce = 100;

// Get User's Public Key
const [account]: string[] = await window.ethereum.request({
    method: 'eth_requestAccounts',
});
const publicKey = await ethers.utils.getAddress(account);

// Sign Message
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const message = `Hi I wanna play the Games | ${nonce}`;
const messageUtf8Bytes = ethers.utils.toUtf8Bytes(message);
const testBytes = ethers.utils.arrayify(messageUtf8Bytes);
const signature = await signer.signMessage(testBytes);
const accountSignature = {
    publicKey: publicKey,
    message: message,
    signature: signature,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  User submit Signature, Message &amp;amp; Public Key
&lt;/h4&gt;

&lt;p&gt;After sign the message, user will get the signature. User need to submit Signature, Message &amp;amp; Public Key to Backend. &lt;/p&gt;

&lt;h4&gt;
  
  
  Verify &amp;amp; Validate Signature
&lt;/h4&gt;

&lt;p&gt;User received Signature, Message &amp;amp; Public Key. Backend will check the Nonce on the message, this Nonce must be correct with the Nonce that written on Backend Database. To Validate the Signature, Backend will need to utilize ethers.js library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const checkValidSignature = (message, signature, pubKey) =&amp;gt; {
  const messageUtf8Bytes = ethers.utils.toUtf8Bytes(message);
  const arrayifyMessage = ethers.utils.arrayify(messageUtf8Bytes);
  const recoveredAddress = ethers.utils.verifyMessage(
    arrayifyMessage,
    signature
  );
  const publicKeyLowerCase = pubKey.toLowerCase();
  const recoveredAddressLowerCase = recoveredAddress.toLowerCase();
  if (publicKeyLowerCase === recoveredAddressLowerCase) {
    return true;
  }
  return false;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Send Auth Token
&lt;/h4&gt;

&lt;p&gt;If the signature is valid and user send correct nonce, Backend will give Authentication Token to User. This token will be used by user to authenticate themself when play the game.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
So, we are not store any Personal Information about users. We don't have a &lt;strong&gt;Users table&lt;/strong&gt; on Backend to store user's username &amp;amp; password.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
This is an adequate method that you can apply when build Hybrid apps. You still able to identified your users without collecting their personal information.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Notes&lt;/strong&gt;&lt;br&gt;
In step above, we signing message using standard &lt;a href="https://eips.ethereum.org/EIPS/eip-191"&gt;EIP-191&lt;/a&gt;. If you consider about to have more complex message to sign, you can use &lt;a href="https://eips.ethereum.org/EIPS/eip-712"&gt;EIP-712&lt;/a&gt; &lt;/p&gt;

</description>
      <category>web3</category>
      <category>crypto</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
