<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jeff Scott on Medium]]></title>
        <description><![CDATA[Stories by Jeff Scott on Medium]]></description>
        <link>https://medium.com/@JeffWScott?source=rss-6159d4797ba5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YxsDUqKqfXlQdmMBKr2KyA.png</url>
            <title>Stories by Jeff Scott on Medium</title>
            <link>https://medium.com/@JeffWScott?source=rss-6159d4797ba5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 24 May 2026 02:28:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@JeffWScott/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Lamden ARKO is now LIVE!]]></title>
            <link>https://medium.com/lamden/lamden-arko-is-now-live-3d92fa863fdb?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d92fa863fdb</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Mon, 30 Jan 2023 21:31:45 GMT</pubDate>
            <atom:updated>2023-01-30T21:47:37.797Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*E57LVIKH-wN0PNQO4GYUbQ.png" /></figure><p>After a long development cycle, <strong>Arko FINALLY lives!</strong></p><p>Before I get to anything I just want to say that I am honored to work with some of the best and brightest people and I just want to call them out.</p><p>Stuart, Mykyta, Glen, and Allen have contributed a lot of time to get this deployment out the door and I want to thank them for being the best and smartest people I have worked with.</p><p>I also want to call attention to Paul Donald, Endogen (if that is your real name), Benji, and Crosschainer for keeping me honest about bugs and testing things as we went. You can never catch all the bugs, but you guys sure found a lot.</p><p>A final thank you to those that ran Testnet nodes and dealt with our development process in real-time. Thanks for sticking with us!</p><p>I’m sure I have forgotten many people, but I think you all know who you are.</p><h3>Let’s get to the important stuff!</h3><p>If everything goes according to plan the Lamden Vault Wallet should make the Arko Mainnet network option available at 5 pm EST (make sure you refresh the Vault after that time). Also, make sure you are on version v2.4.0. You can download the latest <a href="https://chrome.google.com/webstore/detail/lamden-vault-browser-exte/fhfffofbcgbjjojdnpcfompojdjjhdim">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*_vsBgvm08hb9IerhSTu5TQ.png" /></figure><p>“<strong>Arko Mainnet</strong>” is now the network you should use. A future update will remove the “Lamden Mainnet” and “Lamden Testnet” network options entirely to avoid confusion.</p><p>All $TAU balances and smart contracts values were transferred over to the new network.</p><p>Contact your favorite Dapp operator to see if you should start using their app.</p><p>Lamden Link will be down till at least tomorrow with Pixel Whale returning later this week.</p><h3>Node Dashboard</h3><p>The wallet now has a node dashboard section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kMnJoopEJjp-8tXhYVypLw.png" /><figcaption>This is an image from Arko Testnet</figcaption></figure><p>This will be where Node Owners can view their rewards gained as well as raise and vote on network policies and motions.</p><h3>Block Explorer</h3><p>The great and powerful Coindab will have the Arko Mainnet Explorer up today after 5pm EST.</p><p>We will tweet out when it is live.</p><h3>How do I become a Node?</h3><p>A popular question! We will begin onboarding community nodes the week of Feb 13th. This will let us monitor the network for a couple of weeks as well as release some guidance on how to properly set up a node and what should be expected.</p><p>We will start by onboarding nodes from our Testnet node runners. After that Lamden will no longer have control of the network and it will be in the community&#39;s (your) hands.</p><h3>DAO Funds</h3><p>The DAO will be funded this week with roughly 40 million TAU will be put in the hands of the Lamden Node Group to make the project stronger than it has ever been.</p><h3>Node Details</h3><p>For developers, these are the master nodes and block services that Lamden is now running.</p><p><strong>Masternodes</strong></p><ul><li><a href="https://arko-mn-1.lamden.io">https://arko-mn-1.lamden.io</a></li><li><a href="https://arko-mn-2.lamden.io">https://arko-mn-2.lamden.io</a></li><li><a href="https://arko-mn-3.lamden.io">https://arko-mn-3.lamden.io</a></li></ul><p><a href="https://arko.lamden.io/">Masternode documentation</a></p><p><strong>Block Services:</strong></p><ul><li><a href="https://arko-bs-1.lamden.io">https://arko-bs-1.lamden.io</a></li><li><a href="https://arko-bs-2.lamden.io">https://arko-bs-2.lamden.io</a></li><li><a href="https://arko-bs-3.lamden.io">https://arko-bs-3.lamden.io</a></li></ul><p><a href="https://docs.lamden.io/develop/blockservice/installation/">Block Service Documentation</a></p><p>The best practice should be to use WebSockets for getting state updates. Refrain from polling for updates as it causes too much traffic (ie sending “latest_block” requests a few times a second.</p><p>If you MUST poll, use all URLs in a round, robin fashion so you are not hammering one node in particular. As more nodes and block services come online the load can be spread around even more.</p><h3>Network Stability</h3><p>Arko has undergone months of testing but nothing is 100%. From a security standpoint, the code underwent an audit, and it contains the latest and greatest contracting version which also underwent an audit.</p><p>Just like the last chain we DO expect some downtime. I know this is crazy for a project to admit but nothing is bulletproof. Please be patient with the node group if issues arise and we need to fix things. In the short term, Lamden controls all the nodes so we hope that means a quick resolution to issues. In the long term, as a decentralized group, the Node owners will need to communicate on fixes and get the network back up in a timely fashion if something happens.</p><h3>Issues</h3><p>Please report any issues in the <a href="http://t.me/lamdenchat">Lamden Telegram Room</a></p><p><em>Why Lamden?</em></p><p>It’s fast, with tiny transaction fees, and a <a href="https://blog.lamden.io/high-performance-and-scalability-on-a-python-blockchain-47c0200c3ef6">developer-focus</a>. Built from the ground up to remove technical hurdles and empower developers. Choose to program in Python, or your preferred language, and significantly reduce the time to produce your dApps. Developers are further incentivized since 90% of each <a href="https://masternode-01.lamden.io/contracts/rewards/S?key=value">transaction fee</a> is returned to the dApp creator. $TAU has a maximum supply of 248 million and is deflationary with 1% of each transaction fee <a href="https://www.tauhq.com/stats/burned">burned</a>. Lamden is paving its own path as the premier Python-based layer-1 blockchain platform. With access to a potential developer base of over 10 million, the sky is the limit. <a href="https://blog.lamden.io/welcome-to-lamden-cb722d2a588a">Welcome to Lamden</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d92fa863fdb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/lamden-arko-is-now-live-3d92fa863fdb">Lamden ARKO is now LIVE!</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lamden Link Activated]]></title>
            <link>https://medium.com/lamden/lamden-link-activated-4283334deb03?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4283334deb03</guid>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Wed, 14 Dec 2022 18:04:09 GMT</pubDate>
            <atom:updated>2022-12-14T18:04:09.946Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_etHDoPnQcLMdctyCYvk-A.jpeg" /></figure><p>It’s been a long road to recovery since the exploit took down <a href="https://www.lamdenlink.com/">Lamden Link</a> but I am very happy to report that the <a href="https://www.lamdenlink.com/">Lamden Link</a> bridge is now back up!</p><h3>Here are some things you should know.</h3><h4>New BSC TAU contract</h4><p>The exploiter bridged a sizeable amount of TAU to BSC and that caused us to pause the BSC TAU token contract to prevent a sell-off on Pancake Swap.</p><p>We have deployed a new TAU token contact on BSC and airdropped everyone their balances back, except the exploiter.</p><p>The new token contract is now unpaused and you can begin to trade on PCS again.</p><p><a href="https://bscscan.com/address/0x5d9Cb4C6F988f8eD166F175a5B8be7E3CBCA850d"><strong>New TAU contract address (add to your crypto wallet)</strong></a><br><a href="https://pancakeswap.finance/swap?outputCurrency=0x5d9Cb4C6F988f8eD166F175a5B8be7E3CBCA850d"><strong>Trade on Pancake Swap</strong></a></p><h4>Limited Tokens</h4><p>We removed all tokens from the bridge except for LUSD/BUSD and TAU. So right now that’s all you can bridge. For most people that is enough.</p><p>We will be activating ETH within the next week or so.</p><p>As far as LIQ, BDT and DC are concerned we do not have the liquidity to restore these on the bridge yet. However, we will make every effort in the new year to restore these tokens.</p><h4>Liquidity</h4><p>Lamden had to burn all of their WETH and LUSD liquidity on Rocketswap. This allowed Lamden to absorb the financial loss of the exploit and not pass it on to the community. For now, I encourage the community to provide liquidity to the LUSD/TAU pair as we aren’t able to replace it in the short-term.</p><p>The Bridge BSC contract will be 100% funded with an amount of BUSD equal to the total LUSD that exists on Lamden.</p><p>When it becomes available, the WETH bridge to Ethereum will be 90% funded with the hopes of getting it to 100% in the future.</p><p>The TAU/BNB pool on Pancake Swap will remain as liquid as it was before, there is no change there.</p><h4>New Bridge Feature</h4><p>The bridge is made up of two types of contracts. One that handles tokens created on Lamden (Lamden Native Bridge) and one that handles tokens created on Ethereum Based Blockchains, like BSC (ETH Native Bridge). Previously to this update, the Lamden Native Bridge was only able to handle one token, TAU. But the new contract can now handle multi-tokens and as such, we can add other Lamden Based tokens to the bridge!</p><p>More on this to come and how project owners can bridge their tokens to BSC later.</p><h3>Housekeeping</h3><p>In order to move funds out of the old BSC bridge contract I had to mint and burn LUSD on Lamden. I did it incorrectly the first time so, I had to do it twice. For transparency, here are those transactions.</p><p><strong>ATTEMPT #1</strong></p><p><a href="https://www.tauhq.com/transactions/05ebe9a1fa28561c4e9cef3cb0b64c262d51bfc96c6db655545c7af7df9de39b">MINT 38,887.65 LUSD on Lamden</a><br><a href="https://www.tauhq.com/transactions/5cefa6cd824c60e3d68e0c54f6021537eec06ec271e9670263b017a788c5837f">Burn 38,887.65 LUSD on Lamden</a><br><a href="https://bscscan.com/tx/0xab2a8f9d9c39686c8906bdacf974c4b3d2c5cb1f42c9883352470567ac74ee5c">Withdraw tokens from old BSC Lamden Link contract</a> <strong>(FAILED INVALID NONCE)</strong></p><p><strong>ATTEMPT #2</strong></p><p><a href="http://RE-MINT MINT 38,887.65 LUSD on Lamden RE-Burn 38,887.65 LUSD on Lamden Withdraw tokens from old BSC Lamden Link contract">RE-MINT MINT 38,887.65 LUSD on Lamden</a><br><a href="https://www.tauhq.com/transactions/d7c41c2239b93c607897cf687c9b86cb02603719687b7c5c347587b2ca4bb965">RE-Burn 38,887.65 LUSD on Lamden</a><br><a href="https://bscscan.com/tx/0xa901f0cba6d1eca9e3ee7497665a33ea5219b091c352296cfc10bb1d0c21202b">Withdraw tokens from old BSC Lamden Link contract</a></p><p><a href="https://bscscan.com/tx/0x7c1227d05788326ce9248c636a5519a337f8de7e0d8a4e1d71530ea2dc7c48b6">Send test 1000 BUSD to new contract</a></p><p><a href="https://bscscan.com/tx/0x3680267525a804f8cffcf4bf1a0e09ce325830ad7ed7f7faf44a3517c50c5db8">Send rest 37,887.65 BUSD to new contract</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4283334deb03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/lamden-link-activated-4283334deb03">Lamden Link Activated</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lamden Wallet v1.8.0 — Cleaning House]]></title>
            <link>https://medium.com/lamden/lamden-wallet-v1-8-0-cleaning-house-9175d95732a8?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9175d95732a8</guid>
            <category><![CDATA[cryptocurrency-news]]></category>
            <category><![CDATA[lamden]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Thu, 21 Oct 2021 18:00:50 GMT</pubDate>
            <atom:updated>2021-10-21T21:57:24.202Z</atom:updated>
            <content:encoded><![CDATA[<h3>Lamden Wallet v1.8.0 — Cleaning House</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_nMOXv_IuSGgnUkStFyEg.jpeg" /></figure><p><em>This is a guide to be able to merge and cleanup your Lamden Wallet accounts. There is no requirement or a deadline to do this, it’s just information if you want it</em>😎<em>.</em></p><h3>Time to tidy up our wallets 🧼 🧽</h3><p>With the new <a href="https://github.com/Lamden/wallet/releases/tag/v1.8.0">Lamden Wallet v1.8.0 release</a> we now have <strong>Dynamic DAPP Connections</strong>.</p><p>This is a departure from how the wallet worked previously.</p><p>Previous to v.1.8.0 each time the wallet connected to a DAPP it would create a NEW account for that DAPP in the wallet. This was done to silo the DAPP away from your Main Account and provide an extra level of security between a malicious app and your funds.</p><p>While this seemed like a good idea when the Lamden Ecosystem was quite small the reality was, as Lamden became more popular, the amount of accounts the user had to deal with became unwieldy. This included keeping TAU in each account to allow transactions and tracking which account held which tokens or NFTs.</p><p>A bigger issue that I personally did not see was the paradigm shift for users who were just familiar with how other wallets like Metamask usually handle these connections. Even though users got comfortable with our paradigm, onboarding those users to Lamden had more friction than it was worth.</p><p>Thank god that’s all in the past!</p><h3>Or is it? 🕵️‍♀️</h3><p>After v1.8.0 you will have a new menu item called <strong>Dapp Connections</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*oohDA_OJ7H6lBJw4YacLXQ.png" /><figcaption>This one</figcaption></figure><p>Clicking this will take you to a new screen that lists all the DAPP connections your wallet has made. Next to the DAPP is the the account that you currently have linked. Clicking “Change Account” will bring up a screen that lets you change to a different account.</p><p>But, if you navigate back to the <strong>Accounts</strong> screen for a moment you’ll notice that it looks just a cluttered as ever! That’s because all the accounts that the DAPPS create still exist in the wallet. It seems we have some house cleaning to do!</p><p>The ideal situation is to take all these accounts and combine them into 1 or 2 accounts that hold ALL of our assets. And then point all of our DAPPs at just our main account. So when you go from <a href="http://www.lamdenlink.com">Lamden Link</a> to <a href="https://rocketswap.exchange/">Rocketswap</a> the same assets are being accessed.</p><h3>Step 1a: BACKUP! 💾</h3><p>Before we do anything, including deleting accounts, we need to do a backup. This is so if future us realizes we missed moving any assets we can recover the account to the wallet and have access to those assets.</p><p>You can <a href="https://docs.lamden.io/docs/wallet/backup_keystore"><strong>CREATE A KEYSTORE</strong></a>, <a href="https://docs.lamden.io/docs/wallet/backup_view_keys"><strong>BACKUP KEYS MANUALLY</strong></a><strong> </strong>or both.</p><p>Whichever you decide make sure you store the information SECURELY.</p><p>Be nice to future you, use something like <a href="https://www.lastpass.com/">LastPass</a> to keep complex passwords safe but accessible. You will thank you later.</p><h3>Step 1b: BACKUP!! 🛑</h3><p>Seriously. Do it. This article will not be held responsible for lost assets.</p><h3>Step 2: Select a main account 💃</h3><p>From your list of accounts select which will be your MAIN ACCOUNT. I suggest going into this account’s properties and renaming it to just that. This will help to avoid confusion as to which account we are moving our assets to.</p><h3>Step 3: Move Tokens 🪙</h3><ul><li>You can easily click on any of the tokens listed in your wallet to see which accounts have balances. <a href="https://www.youtube.com/watch?v=WZnjS0J0Y3o">Use this great tutorial</a> to transfer those tokens to your MAIN ACCOUNT</li><li>What about tokens that you didn’t know you had? YOU’RE RICH BITCH! lookup your wallet address on <a href="https://www.tauhq.com/">www.tauhq.com</a> it should show you all your token balances. Add any tokens to the wallet <a href="https://www.youtube.com/watch?v=Bv_RT0-j8zw">following this fantastic tutorial</a> and then move them to your MAIN ACCOUNT</li></ul><h3>Step 3: Rocketswap Staking and Liquidity 🚀</h3><p>Any staking you’re doing on Rocketswap will be tied to the Rocketswap account.</p><p>You have a couple options here:</p><p><strong>Move everything:</strong></p><ul><li>Un-stake from all <a href="https://rocketswap.exchange/#/farm/">Rocket Farms</a>. This will get back your tokens as well as any LP you had staked.</li><li>Remove all liquidity from the <a href="https://rocketswap.exchange/#/pool-main/">Rocketswap Pools</a> dashboard</li><li>Un-stake anything in your <a href="https://rocketswap.exchange/#/rswp/">RSWP Rocket Fuel Tank</a></li><li><a href="https://www.youtube.com/watch?v=WZnjS0J0Y3o">Using this great tutorial</a> transfer all tokens and TAU to your MAIN ACCOUNT</li><li>Rename Rocketswap account to OLD ROCKETSWAP ACCOUNT</li></ul><p><strong>Keep Account for Staking</strong></p><ul><li>If you’re heavy into the staking and liquidity pools and you just want to deal with this later then you can leave this account as is. You’ll essentially be swapping back and forth in the Dapp Connections page between your MAIN ACCOUNT for trading and this account for staking. If you empty your farms daily they may not be a great option. But if you’re a set it and forget it farmer then it’s probably the easiest for you.</li><li>Rename the account to Rocketswap Staking and leave some amount of TAU in this account for making transactions later</li></ul><h3>Step 4: Pixel Whale 🐳</h3><p>There are two considerations for merging our <a href="https://www.pixelwhale.io/">Pixel Whale</a> NFTs with our MAIN ACCOUNT.</p><p><strong>Owned NFTs:</strong></p><ul><li>Anything you own can be transferred to your MAIN ACCOUNT by visiting the NFTs page on Pixel Whale and using the Gift button. Be sure the MAIN ACCOUNT address you paste in has no leading or trailing spaces!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*_bFNs7Wpi1pFML-RRABaLw.png" /><figcaption>Get yourself something nice</figcaption></figure><p><strong>Created NFTs</strong></p><ul><li>If you have not created any NFTs from this account then move on</li><li>Creators are meant to never change. The creation of an NFT will always be tied to the account that created it. This was a design decision which I regret now but it is what it is.</li><li>This means that we need to keep this account around because anytime one of your Creations is sold then you will get royalties collecting in this account and you will want to have access to those</li><li>Rename this account to Pixel Whale Creator</li></ul><h3>Step 4a: Contract Developers 🤓</h3><p>If you have ever submitted a contract you will get a cut of every transaction fee that goes through that contract. If you have not, then you can move ahead.</p><p>You can view the developer of any contract by replacing the contract name in <a href="https://masternode-01.lamden.io/contracts/con_rocketswap_official_v1/__developer__">THIS URL</a> with your own.</p><p>So if you have an account that you want to get rid of now. You can change the developer of your smart contract to your MAIN ACCOUNT by creating this transaction. If you are a developer this should be familiar to you.</p><p>Make sure the account selected in the top box is the current developer account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*_1WrYggK4zcfaDUk9IsYaw.png" /><figcaption>Developers should hopefully understand this</figcaption></figure><h3>Step 4b: Contract Operators 🏗️</h3><p>If you have never developed a Lamden Smart contract then you can skip this.</p><p>If you use the operator (or owner) paradigms in your smart contracts then hopefully you have built a mechanism to change who that is.</p><p>Implementation of something like this is in the hands of the developer. I just wanted to have this item here to remind you to check if any of your accounts are currently set as the operator or owner of any current contract before you toast them.</p><h3>Step 5: Other considerations 💭</h3><p>There are a lot of DAPPS on Lamden. New and OLD and depending on your time using Lamden you could have accounts and items all over the place.</p><p>Visit the communities that you value the most and ask around if there is anything more you should do before deleting an account.</p><p>Some communities to consider:</p><ul><li><a href="https://t.me/LamdenNebula">Nebula (NEB)</a></li><li><a href="https://t.me/underground_warriors">Underground Warriors (WP)</a></li><li><a href="https://t.me/lambdoge">LambDoge</a> (LDOGE)</li><li>CRUSADERS of LIGHT (search Telegram)</li></ul><p>Hopefully these and other communities publish their own migration steps to help people clean up old accounts</p><h3>Step 6: Send TAU and Remove accounts 🗑️</h3><p>If you have backed up your accounts, <em>and we all know you have</em>, then you can go ahead and delete accounts that no longer are tied to any assets or you don’t ever plan to need again.</p><p>Before we do let’s get as much TAU out of the account as possible (dust may remain). <a href="https://www.youtube.com/watch?v=WZnjS0J0Y3o">Use this brilliant tutorial</a> to send TAU from all accounts you are going to delete to your MAIN ACCOUNT.</p><p>How to squeeze out as much TAU as possible?</p><ul><li>Stamp Limit: 25 Stamps</li><li>Amount to send: Total TAU in account subtract 0.4 TAU</li></ul><p>SO if I have 10.8 TAU in my account I’m going to set the stamp limit to 25 and then set my amount for the transaction to 10.4 (10.8–0.4).</p><p>If you need them in the future you can <a href="https://docs.lamden.io/docs/wallet/accounts_creation#existing-account">restore them from the keystore backup</a> or add specific accounts back <a href="https://docs.lamden.io/docs/wallet/accounts_creation#existing-account">via private key</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VW1w1Pf7Ggh4OLUH.jpg" /><figcaption>Wallet may be less shiny than picture depicts</figcaption></figure><p>All done! Hopefully we have cleaned up your wallet even a little and it’s now a happier place to be!</p><h3>Learn more about Lamden</h3><ul><li>Check out our <a href="https://lamden.io/">website</a></li><li>Chat with us on <a href="https://t.me/lamdenchat">Telegram</a> or <a href="https://discord.gg/SgEApnDx">Discord</a></li><li>Follow us on <a href="https://twitter.com/lamdentau">Twitter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9175d95732a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/lamden-wallet-v1-8-0-cleaning-house-9175d95732a8">Lamden Wallet v1.8.0 — Cleaning House</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lamden Link: Lamden’s Bridge to the Blockverse]]></title>
            <link>https://medium.com/lamden/lamden-link-lamdens-bridge-to-the-blockverse-bbe4cb01c8be?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbe4cb01c8be</guid>
            <category><![CDATA[cryptocurrency-news]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Fri, 02 Jul 2021 13:57:29 GMT</pubDate>
            <atom:updated>2021-07-02T14:25:36.880Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WOF2fZTS_yAkyBn3VruNyQ.jpeg" /></figure><p>Introducing <a href="http://www.lamdenlink.com">Lamden Link</a>!</p><p>Blockchain has dominated the technology space for the last decade just like the internet has done for the past two decades. Blockchain provides a secure and fast means of carrying out transactions with the use of impossible to hack ledger technology. Blockchain technology continues to grow both in popularity and usage as many industries are starting to accept it as a reality.</p><p>The benefits of blockchain technology cannot be overemphasized with quite a number of industries already implementing blockchain solutions ranging from finance, health, service etc. However, business implementation of blockchain technology is still quite difficult and this leaves a gap between businesses and decentralized technologies. There are many challenges that enterprises face when trying to adopt public and private blockchain technologies.</p><p>This is where the Lamden blockchain comes in handy. Lamden is a blockchain built with python. It’s open source, cheap and fast to use. It supports python contracts that are easy to write and test. That means Developers who already know python don’t have to learn any new programming languages or workflows. With Lamden, everything is open-source. You can re-use functionality that others have built into their smart contracts. This means you can build smart contracts faster with Lamden.</p><p>Lamden has been around since 2018, and having launched their <a href="https://mainnet.lamden.io">Mainnet</a> in September 2020, the team has been able to spur the community run DEX <a href="https://rocketswap.exchange/">Rocketswap</a>, an NFT minting and marketing place <a href="https://www.pixelwhale.io">pixelwhale.io</a> and a NFT based game <a href="https://undergroundwarriors.io/">Underground Warriors</a> which is still under active development.</p><p>Our blockchain basically focuses on the needs of our:</p><ul><li>Users/Investors</li><li>Developers</li></ul><p><a href="http://www.lamdenlink.com">Lamden Link</a>, which enables interoperability, is a two-way bridge built to convert ERC20 tokens from the Ethereum blockchain to the Lamden blockchain and back again.</p><p>You might want to ask what the <a href="http://www.lamdenlink.com">Lamden Link</a> is all about. What is an Ethereum bridge, or more precisely what is a Lamden-Ethereum Bridge? As the name implies it allows movement of ERC20 tokens between two chains. So tokens can flow across to be used within the Lamden ecosystem. This includes <a href="https://weth.io/">Wrapped Ethereum Token</a> (WETH) which is the first to launch and effectively bridges Ethereum’s value to the Lamden ecosystem.</p><p><a href="http://www.lamdenlink.com">Lamden Link</a> is very important because currently Ethereum has a lot of dapps being built on it which means a larger market capitalization for Ethereum tokens and this bridge allows these dapps and tokens to be able to easily migrate to the Lamden chain to enjoy lower gas fees, fast transactions and listing on the blazingly fast <a href="https://www.rocketswap.exchange">Rocketswap DEX</a>.</p><h4>The Future Of Lamden Link</h4><p><a href="http://www.lamdenlink.com">Lamden Link</a> is launching with <a href="https://weth.io/">Wrapped Ethereum Token</a> (WETH) but will add more ERC20 tokens including stable-coins in the near future.</p><p>More chains will be added to the bridge as time goes by with the devs already working on that possibility.</p><p>Visit here <a href="https://www.lamdenlink.com">https://www.lamdenlink.com</a></p><p><a href="https://lamden.io/en/">Website</a> | <a href="https://t.me/lamdenchat">Telegram</a> | <a href="https://twitter.com/LamdenTau">Twitter</a> | <a href="https://www.reddit.com/r/lamden">Reddit</a> | <a href="https://web.facebook.com/LamdenTau/">Facebook</a> | <a href="https://github.com/Lamden">Github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbe4cb01c8be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/lamden-link-lamdens-bridge-to-the-blockverse-bbe4cb01c8be">Lamden Link: Lamden’s Bridge to the Blockverse</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Life Happens]]></title>
            <link>https://medium.com/rswp-io/life-happens-7f7feae6ec64?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f7feae6ec64</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[lamden]]></category>
            <category><![CDATA[cryptocurrency-news]]></category>
            <category><![CDATA[crytpo]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Thu, 04 Mar 2021 19:15:26 GMT</pubDate>
            <atom:updated>2021-03-04T19:15:26.209Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhJQ_s4u0Z527Lae_vY8wg.png" /></figure><p>The Rocketswap team has some <strong><em>good news </em></strong>and <strong><em>bad news</em></strong>.</p><h3>Good News:</h3><p>Benji’s and his wife welcomed their second child today!</p><p>If you’re in the <a href="https://t.me/rocketswap">Rocketswap Telegram</a> room I hope you can wish him congratulations!</p><h3>Bad News:</h3><p>Benji is one of Rocketswaps lead developers and general project manager. We were hoping to get Rocketswap launched before the baby came, but, as they say, “Life happens”. So we’re going to postpone the launch of Rocketswap by one week so that Benji can take care of his family.</p><p>The rest of the team will continue development and Benji will catch back up with us next week to polish off the product.</p><h3>Updated Timelines</h3><p>All dates and events have been pushed one week. The new dates are as follows:</p><ul><li>Rocketswap Launch: <strong>March 15th, 2021, 18:00 UTC</strong></li><li><a href="https://medium.com/rswp-io/preparing-for-launch-day-97afeb6e5515">MAKE IT RAIN Event</a><strong><em>: </em>March 11th, 2021, 22:00 UTC</strong></li><li>* Dates have been changed in all previous blog posts</li></ul><p><em>With ❤ — The Rocketswap Team 🚀🚀</em></p><ul><li>Follow us on <a href="https://twitter.com/RSwapOfficial">Twitter</a></li><li>Talk to us on <a href="https://t.me/rocketswap">Telegram</a></li><li>Live on <a href="http://www.rswp.io/">Testnet</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f7feae6ec64" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rswp-io/life-happens-7f7feae6ec64">Life Happens</a> was originally published in <a href="https://medium.com/rswp-io">Rocketswap 🚀</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4: Uploading your Smart Contract to the Blockchain]]></title>
            <link>https://medium.com/lamden/4-uploading-your-smart-contract-to-the-blockchain-fe0178d90df6?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe0178d90df6</guid>
            <category><![CDATA[lamden]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Sat, 14 Nov 2020 15:34:18 GMT</pubDate>
            <atom:updated>2020-11-14T15:34:18.065Z</atom:updated>
            <content:encoded><![CDATA[<h3>Wow, you made to Part 4!</h3><p><a href="https://github.com/JeffWScott/my_token_lamden_tutorial">Go Here to take a look at the previous tutorial parts.</a></p><p>To begin this tutorial you should have a project that mirrors <a href="https://github.com/JeffWScott/my_token_lamden_tutorial/tree/part_3b">this git repo</a>.</p><h3>Part 4 — Setup</h3><p>At this point we have a smart contract and some interactions, but none of it is on the blockchain. A lot of the Dev Server and API work was to give you a ground level introduction to working with a blockchain and I hope you now have that understanding.</p><p>This next set of tutorials will have us uploading our smart contract to Lamden’s TestNet and applying what we have learned about interacting with the smart contract to change our frontend to work with the Lamden TestNet.</p><h4>Lamden Wallet</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gjc99I62MjG0kiuAMMUZw.png" /><figcaption><a href="https://chrome.google.com/webstore/detail/lamden-wallet-browser-ext/fhfffofbcgbjjojdnpcfompojdjjhdim">Install</a></figcaption></figure><p>The first thing we need is Lamden’s Wallet. The wallet is a Chrome Extension that can be <a href="https://chrome.google.com/webstore/detail/lamden-wallet-browser-ext/fhfffofbcgbjjojdnpcfompojdjjhdim">installed from the Chrome Web Store.</a></p><p>The wallet will allow us to do the following:</p><ul><li>Make and safely store Lamden keypairs (wallets)</li><li>Upload our Smart Contract to the blockchain</li><li>Log users into our frontend by talking to the wallet</li><li>Have our frontend initiate transactions on behalf of the user</li></ul><p>Once you have downloaded the wallet, open it and complete the first-time user setup.</p><p>When you get to the main screen <strong>you will need some test TAU</strong> (called dTAU). Head over to the <a href="https://faucet.lamden.io/">Lamden Faucet</a> to get some by copying your account address (vk)from the the Lamden Wallet and pasting it in the site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*fpjoPEwpx1CHj5qLRiMIPg.png" /><figcaption><strong>dTau is free and has no value.</strong></figcaption></figure><p><strong>A quick note on keys.</strong> In cryptocurrency you have two keys referred to as a keypair. One of these keys you can share and one you keep secret. In this tutorial we will refer to the one you share as a <strong>vk </strong>or “verifying key” but you might have also heard it called a <em>public key</em> or <em>account address</em>. The wallet itself calls it an account address. Why are we calling it a vk and not an account address? Well we are developers now, and we need to use proper terminology!</p><p>The other key, the <strong>sk, </strong>is your “secret key” and is used to sign translations. Using cryptography the blockchain can read the digital signature of your transaction and match the vk to it. The Lamden Wallet takes care of safely storing your <strong>sk</strong> and automatically signing transactions. You should never need to manipulate your sk manually, and you can back it up using the <a href="https://docs.lamden.io/docs/wallet/backup_overview"><strong>Backup</strong></a> process on the left menu bar. <strong>(Which you should do now)</strong></p><p>To <strong>copy your vk to the clipboard</strong>, click on your account in the list from the main Accoutns menu. Then click the <strong>Copy Address </strong>button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*bbFvEXRp3A3BvH7QDJaTAg.png" /></figure><p><strong>**Make note of this vk as we will need to reference it later in the tutorial. This key is public information and is safe to share.</strong></p><h3>my_token.py</h3><p>The first thing we need to do is make our seed method more dynamic. We hardcoded the value “me” to get 50 tokens but, we may not know the vk (public key) we will be using or the number of tokens we want as as supply, till later.</p><p>Open <strong>my_token.py </strong>and<strong> </strong>let’s give our <strong>seed</strong> method a “vk” argument and define it as <strong>string</strong> (str). We then will pass the <strong>vk</strong> argument down to the assignment statement where we assign 50 tokens. Now whatever vk we pass into this method will get minted the tokens.</p><p>Then we will give <strong>seed</strong> a second argument called <strong>amount</strong>, defined as an <strong>integer</strong> (int), which will be the token amount to mint at the time the contract is submitted. Replace the value <strong>50</strong> with our new variable <strong>amount.</strong></p><pre>#my_token.py<br><br>#Smart Contract State<br>S = Hash(default_value=0)<br><br>#This runs when our contract is created on the blockchain, and never again.<br>@construct<br>def seed(<strong>vk</strong>: str,<strong> amount</strong>: int):<br>    S[<strong>vk</strong>] = <strong>amount</strong><br><br>#This method will be exported so our users can call it<br>@export<br>def transfer(amount: int, receiver: str):</pre><p>We can now set these values when the smart contract is submitted. Then a <strong>vk</strong> of our choosing will get the initial supply of whatever amount we decide.</p><p><strong>Save my_token.py</strong> our changes are complete</p><h3>tests/test_contract.py</h3><p>Let’s update our tests to pass <strong>vk =</strong> “me” and <strong>amount</strong> = 50 when we submit our contract to contracting. See changes in <strong>bold</strong>.</p><pre>#tests/test_contract.py<br>import unittest<br><br>from contracting.client import ContractingClient<br>client = ContractingClient()<br><br>with open(&#39;../my_token.py&#39;) as f:<br>    code = f.read()<br>    client.submit(code, name=&#39;my_token&#39;, <strong>constructor_args={&#39;vk&#39;: &#39;me&#39;, &#39;amount&#39;: 50}</strong>)</pre><p><strong>client.submit()</strong> calls our smart contract’s seed method when it submits the contract. It knows to do this because of the CONSTRUCT decorator we used above the seed function. The <strong>constructor_args </strong>property tells submit to pass along this object as arguments to the seed method.</p><p>When <strong>client.submit()</strong> runs our seed method it will now run it like this:</p><pre>seed(vk=”me”, amount=50)</pre><p><em>When the above method runs </em><strong><em>me</em></strong><em> will get assigned 50 tokens to start.</em></p><p>Run the test file.</p><pre>cd tests<br>python3 test_contract.py</pre><p>All 3 tests should pass</p><pre>Ran 3 tests in 0.016s</pre><pre>OK</pre><h3>server/contracting_server.py</h3><p>Let’s make the same change in <strong>server/contracting_server.py</strong>.</p><p>See changes in <strong>bold.</strong></p><pre># server/contracting_server.py<br><br>from sanic import Sanic, response<br>from sanic_cors import CORS, cross_origin<br>import ast<br>import json</pre><pre>from contracting.db.encoder import encode<br>from contracting.client import ContractingClient<br>client = ContractingClient()<br><br>with open(&#39;my_token.py&#39;) as f:<br>    code = f.read()<br>    client.submit(code, name=&#39;my_token&#39;, <strong>constructor_args={&#39;vk&#39;: &#39;me&#39;, &#39;amount&#39;: 50}</strong>)<br><br>app = Sanic(&quot;contracting server&quot;)<br>CORS(app)</pre><h3><strong>Upload to the Blockchain</strong></h3><p>Uploading a contract to the Lamden Blockchain is done by calling the submission contract.</p><p>You can view the code for the submission contract on the blockchain <a href="http://167.172.126.5:18080/contracts/submission">here</a>.</p><p>Let’s look at the submission contract code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/976a455cf933a481548f4dd7dc5512e1/href">https://medium.com/media/976a455cf933a481548f4dd7dc5512e1/href</a></iframe><p>The submission contract is just 1 method called <strong>submit_contract</strong> and it take 4 arguments. Most of which should be familiar to you by now.</p><ul><li><strong>name</strong>: Contract name. <strong>Must be unique</strong> on the blockchain and <strong>must start with “con_”</strong></li><li><strong>code</strong>: Your contract code</li><li><strong>constructor_args</strong>: Arguments for our seed method</li><li><strong>owner</strong>: If an owner is specified then only that user (or contract) can transact with this contract. This is an advanced feature not needed for this tutorial series.</li></ul><p>So, to upload our contract we need to make a Transaction with the same information we provided to server/contracting_server.py in Part 3b.</p><pre>contractName: &#39;submission&#39;,<br>methodName: &#39;submit_contract&#39;,<br>kwargs: {<br>    name: &quot;con_my_token&quot;,<br>    code: &quot;contact code here&quot;,<br>    constructor_args: {<br>        &quot;vk&quot;: &quot;our public key&quot;,<br>        &quot;amount&quot;: 1000000<br>    }<br>}</pre><p>Luckily the Lamden Wallet will simplify this process for us.</p><ul><li>Open up the wallet and click <strong>Smart Contracts</strong> on the left side menu. You should get taken to this screen.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T6bPoxZHuoMbSclMJnVfcA.png" /><figcaption>Lamden Wallet — Smart Contract IDE</figcaption></figure><ul><li>Click the <strong>blue + button</strong> next to the IDE tabs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*6LF7mtyur8nwiDzE_TVxFw.png" /></figure><ul><li>Click the <strong>Blank Contact </strong>button.</li><li>Paste the contents of <strong>my_token.py</strong> into the IDE.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*h27lMvAOjqm7OxEY-zaMog.png" /><figcaption>my_token.py code in Lamden Wallet IDE</figcaption></figure><ul><li>Clicking <strong>Check Contract </strong>should return the message <strong>Contract is Okay</strong> in the green box.</li></ul><p><em>Before we go further make sure you have your wallet vk from earlier handy.</em></p><ul><li>Click the <strong>Submit To Network </strong>button and you will get the following form to fill in.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*aJU4qCDWplanLaT4FFRMGg.png" /></figure><ul><li>From the <strong>Send Transaction From </strong>drop down select your wallet. This wallet will be the <strong>transaction</strong> <strong>sender </strong>(ctx.sender in our smart contract code)<strong>.</strong></li><li><strong>Stamp Limit </strong>signifies how many stamps the system can use before the transaction aborts. On the current TestNet our submission transaction should cost about 200 stamps, which is about 10 dTau. There is no harm in leaving it higher, so we can set it at about 1000 to ensure the transaction doesn’t prematurely abort.</li><li><strong>Contract Name</strong> is already filled in for us with <strong>submission</strong></li><li><strong>Function</strong> (another name for method) is already filled in and is the correct <strong>submit_contract</strong> method as we saw from the submission contract code above</li></ul><p>These next 4 boxes are are the arguments we will supply to <strong>submit_contract</strong></p><ul><li><strong>Name</strong>: We have been calling this contract <strong>my_token </strong>but there are two issues with using that name here. One is that <strong><em>all smart contracts need to be prefixed with con_</em> </strong>and <strong>con_my_token</strong> would work except for the second thing in which <strong><em>all smart contract names need to be unique</em></strong>. Multiple people will take this tutorial and that means everyone can’t use the same name. So here you get to be creative and replace <strong>my</strong> with whatever you want. I will use <strong>con_jeff_token, </strong>you use whatever you like.</li><li><strong>Code</strong>: You can see the code string all packed in the box. Scroll down to marvel at your work.</li><li><strong>Owner</strong>: Leave this blank as we want everyone to be able to transact with our contract.</li><li><strong>Constructor Args</strong>: This is where we’re going to pass in the values to our seed method, just like we setup in or <strong>test_contracts.py</strong> and <strong>contracting_server.py</strong>. Copy and paste this <a href="https://www.w3schools.com/js/js_json.asp">JSON object</a> into the box. Be sure to <strong>replace &lt;your vk&gt; </strong>with the one you copied down earlier. Be sure to not have any spaces in the string, including leading or trailing spaces.</li></ul><pre>{&quot;vk&quot;:&quot;&lt;your vk&gt;&quot;,&quot;amount&quot;:1000000}</pre><p>This is my completed form. Yours should look similar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*2joTMMXMoVwh1M7y7PC8PA.png" /></figure><p>** To continue further you need to have dTau in your wallet. If you don’t the submission transaction will fail with “bad seed size”.</p><ul><li>Click the <strong>Confirm Transaction</strong> button</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*udsL3DDCm4zPyO39trMnEQ.png" /></figure><ul><li>Say <strong>OK </strong>to this prompt and then you should get a successful result like below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*S7a66fTC_WeTb0IBCHIkgw.png" /></figure><ul><li>Click <strong>Close.</strong></li></ul><p>We can validate our contract is on the blockchain by finding it on the Masternode using the API. This is like how our Dev Server worked.</p><p><em>**Substitute </em><strong><em>your contract name</em></strong><em> for </em><strong><em>con_jeff_token</em></strong><em> in these Links.</em></p><p><strong>Your contract’s code:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*GJJYHniPe1ZypxkiJuEp7g.png" /><figcaption><a href="http://167.172.126.5:18080/contracts/con_jeff_token">http://167.172.126.5:18080/contracts/con_jeff_token</a></figcaption></figure><p><strong>Your contract’s exported methods and arguments:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*yMtFJ7WPO1R26nSoeShBGA.png" /><figcaption><a href="http://167.172.126.5:18080/contracts/con_jeff_token/methods">http://167.172.126.5:18080/contracts/con_jeff_token/methods</a></figcaption></figure><p><strong>Verify the initial minting of tokens to your vk:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*kSYhkRPxEMKAJlj356Zq1Q.png" /><figcaption><a href="http://167.172.126.5:18080/contracts/con_jeff_token/S?key=fc95219ed9e9bf31e36c2f70978a89a9e912b160c3daf28194f96d51298445b6">http://167.172.126.5:18080/contracts/con_jeff_token/S?key=fc95219ed9e9bf31e36c2f70978a89a9e912b160c3daf28194f96d51298445b6</a></figcaption></figure><h3>Quick functionality test</h3><p>Looks like our smart contact is up on the network and we have our minted supply assigned to us. So, let’s do some quick testing.</p><p>Click the <strong>blue + button</strong> on the IDE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*SCeU7Sex2o1s1tD4PHNOkg.png" /></figure><p>In the <strong>From Blockchain</strong> box type the name of your contract and then click the <strong>Open </strong>button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*34qDhv88B1n8a3nfGF5gFA.png" /></figure><p>You will now see your contract’s code that is stored on the blockchain. Notice your seed function has been renamed to <strong>____ </strong>so it can never be run again.</p><p>All state variables have been appended with <strong>__ </strong>but you can ignore that when referencing them in code. For example, your State variable __<strong>S </strong>is will just be <strong>S </strong>when we use it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*q5wIEo11qtPD_58PpWL7lQ.png" /></figure><p>Below the code box there is an easy way to query state. Put <strong>S </strong>in the <strong>Variable Name</strong> box, <strong>your vk</strong> in the <strong>keys </strong>box and hit <strong>RUN. </strong>Returned in the box below is the value of your vk in current state, which is the number of tokens we initially minted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*kLdfjsqh2oZDPYJZn4agKw.png" /></figure><p>If you take a look back at the Masternode API URL this is the equivalent of doing:</p><p><a href="http://167.172.126.5:18080/contracts/con_jeff_token/S?key=fc95219ed9e9bf31e36c2f70978a89a9e912b160c3daf28194f96d51298445b6">http://167.172.126.5:18080/contracts/con_jeff_token/<strong>S?key=fc95219ed9e9bf31e36c2f70978a89a9e912b160c3daf28194f96d51298445b6</strong></a></p><p>Below that we have a <strong>Contract Methods</strong> section and you can see our transfer method. This provides a simple way to run the methods in our contract.</p><p>There are two familiar argument boxes, <strong>amount </strong>and <strong>receiver. </strong>Previously we were testing just sending amount to “me” or “you”, and that will work here as well. The issue with that is that those are just string values and not keys so now one can controls the tokens after they are sent. That’s fine for testing but now how we want our app to work.</p><p>So, to test this properly we will need a second keypair, or “wallet” as the Lamden Wallet refers to them.</p><p>Let’s create one:</p><ul><li>Click on the <strong>Holdings </strong>menu item on the left menu</li><li>Click the <strong>Add Wallet </strong>button<strong> </strong>in the bottom of the big purple rectangle.</li><li>Give this new wallet a nickname like <strong>Wallet 2</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*G_HvaWZlexdObr60sj-ZRw.png" /></figure><ul><li>Then click the <strong>Save </strong>button</li></ul><p>Now you have a new wallet, which in turn has its own keypair (vk &amp; sk).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*-hiHxEHcV13V7cMhIIcINA.png" /></figure><ul><li>Click it the new wallet and then copy it’s vk to the clipboard by clicking the <strong>Receive Coin </strong>button and record it for use later.</li><li>Now go back to the IDE by clicking <strong>Smart Contracts</strong> on the left menu.</li><li>Make sure your contract is selected on the IDE tab and scroll back down the the bottom <strong>Contract Methods</strong> section.</li><li>Enter <strong>100</strong> into the <strong>amount</strong> box.</li><li>Paste the <strong>new vk</strong> we just created into the <strong>receiver</strong> box.</li><li>Click the <strong>RUN </strong>button beside the word <strong>transfer.</strong></li><li>You will get another transfer form with the specifics already populated. We just need to select the <strong>sender </strong>for this transaction<strong>. </strong>In this case the sender should be the wallet that was minted all the coins. So, select that wallet from the <strong>Select Wallet to Send From </strong>drop down box.</li><li>Leave <strong>Stamp Limit </strong>the default.</li><li>click the <strong>Send Transaction </strong>button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*kurAK3nl4jNitOE9pg761w.png" /></figure><p>Assuming everything was done correctly you will get this confirmation box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*8bvJkLeanAJUFPPb3qbRzg.png" /></figure><ul><li>Click the <strong>Close </strong>button.</li><li>Head back to the <strong>Get Current State</strong> box and put <strong>S </strong>in the <strong>Variable Name</strong> box and our <strong>new vk</strong> in the <strong>key</strong> box.</li><li>click the <strong>RUN </strong>button to the right of the words <strong>Get Current State.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*j7Z0mfMxUrXbVZK7phHiIg.png" /></figure><p>Our new wallet now has 100 JEFF TOKENS!</p><p>You can also put your original wallet in the keys box to validate that the 100 tokens were deducted from your supply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*W-f95u7dhrLI8DcrLYgOqw.png" /></figure><p><strong>DONE!</strong></p><p>Things you should have a decent grasp of at this point having completed all 4 Parts to this tutorial:</p><ul><li>Parts of a smart contract: state, methods, arguments, constructor method (seed method).</li><li>How to submit a contract to both the Python contracting client and the blockchain; using the IDE.</li><li>How to get the current state from a smart contract using both the Masternode API and the Wallet IDE.</li><li>The information needed to formulate a transaction: sender (ctx.caller), contractName, functionName, arguments (kwargs), stamp Limit.</li><li>How to send a transaction to a smart contract using the wallet IDE.</li></ul><p>If you have got this far and are still struggling with these topics, then please leave a comment below.</p><p>I’m available to chat on <a href="https://twitter.com/JeffWScott">twitter</a>, <a href="https://t.me/lamdenjeff">telegram</a> or <a href="https://www.linkedin.com/in/jeff-scott-69877978">linkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe0178d90df6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/4-uploading-your-smart-contract-to-the-blockchain-fe0178d90df6">4: Uploading your Smart Contract to the Blockchain</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lamden TAU Token Swap FAQ]]></title>
            <link>https://medium.com/lamden/lamden-tau-token-swap-faq-cb68ab59c38d?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb68ab59c38d</guid>
            <category><![CDATA[cryptocurrency-news]]></category>
            <category><![CDATA[announcements]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[lamden]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Thu, 27 Aug 2020 18:08:43 GMT</pubDate>
            <atom:updated>2020-08-27T18:08:43.612Z</atom:updated>
            <content:encoded><![CDATA[<p>The token swap will begin on <a href="https://www.timeanddate.com/worldclock/fixedtime.html?msg=Lamden+Mainnet+Launch&amp;iso=20200916T16&amp;p1=1440">September 16th, 2020 at 4pm UTC</a>, the day of the Lamden Mainnet release.</p><p>You can view a mainnet countdown timer at <a href="https://www.lamden.io">lamden.io</a>.</p><h3>FAQ</h3><p>We have had a lot of questions about the token swap recently so lets address them all.</p><h4>WHAT is a token swap?</h4><p>The current circulation of TAU tokens are Ethereum based tokens called ERC20 tokens. The swap process allows you to turn your Ethereum ERC20 TAU into Lamden TAU.</p><p><strong>Lamden TAU </strong>is used to pay for transactions on the Lamden blockchain.</p><h4>WHEN will the token swap take place?</h4><p>As stated above the token swap will not be active till the official Mainnet release which is <a href="https://www.timeanddate.com/worldclock/fixedtime.html?msg=Lamden+Mainnet+Launch&amp;iso=20200916T16&amp;p1=1440">September 16th, 2020 at 4pm UTC</a>. No tokens will be swapped before the mainnet release.</p><h4>WHERE will the token swap take place?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*daYbkaywTpqkzn4x8VCSeQ.png" /></figure><p>The token swap process is built directly into the Lamden Wallet.</p><p>You can download the Lamden Wallet <a href="https://chrome.google.com/webstore/detail/lamden-wallet-browser-ext/fhfffofbcgbjjojdnpcfompojdjjhdim">here</a>.</p><h4>HOW long will the token swap be available for?</h4><p>The token swap will be available for about 6 months after the Lamden Mainnet goes live. The exact date is not set in stone but will be communicated ahead of time.</p><h4>Is token swap mandatory, or optional?</h4><p>The token swap is <strong>MANDATORY</strong>. If you do not swap your Ethereum ERC20 TAU tokens during the 6 month swap window you will be unable to do so afterwards.</p><h4>Do I need to swap ALL my tokens at once?</h4><p>You can swap any amount of tokens during the swap period but you must eventually swap ALL of your tokens by the end of the swap window.</p><h4>What happens if I miss the 6 month window? Do I lose TAU that was not swapped?</h4><p>Once the swap window ends unswapped TAU will be stuck on the Ethereum Network.</p><h4>Will X exchange support the token swap?</h4><p><strong>NO exchanges</strong> are taking part in the token swap. <strong>All swaps are manual </strong>and completed through the <a href="https://chrome.google.com/webstore/detail/lamden-wallet-browser-ext/fhfffofbcgbjjojdnpcfompojdjjhdim">Lamden Wallet</a>.<br>Your Ethereum ERC20 TAU will have to be moved from where you have it now to Metamask before you start the swap process.</p><p>The swap process cannot be started till <a href="https://www.timeanddate.com/worldclock/fixedtime.html?msg=Lamden+Mainnet+Launch&amp;iso=20200916T16&amp;p1=1440">Sept 16, 2020 at 4pm UTC</a> and will be open for about 6 months.</p><h4>What about my TAU in uniSwap liquidity pool? Do I need to take them out of the pool first?</h4><p>Yes. To start the swap your Ethereum ERC20 TAU will need to be sent to <a href="https://metamask.io/">Metamask</a>.</p><h4>Can I send my ERC20 tokens to the Lamden Wallet?</h4><p><strong>NO!</strong> Ethereum ERC20 tokens are NOT compatible with the Lamden Network. If you send your Ethereum ERC20 tokens to the <a href="https://chrome.google.com/webstore/detail/lamden-wallet-browser-ext/fhfffofbcgbjjojdnpcfompojdjjhdim">Lamden Wallet</a> they will be lost forever.</p><p>The only way to get your Ethereum ERC20 TAU onto the Lamden Network is by following the wallet token swap process.</p><p>The swap process cannot be started till <a href="https://www.timeanddate.com/worldclock/fixedtime.html?msg=Lamden+Mainnet+Launch&amp;iso=20200916T16&amp;p1=1440">Sept 16, 2020 at 4pm UTC </a>and will be open for about 6 months.</p><h4>What is dTAU?</h4><p>dTAU is the name for Lamden’s TESTNET token and is only useable on the Lamden Testnet.</p><h4>Why is the Token Swap active in the wallet right now?</h4><p>The current swap function allows people to TEST the functionality by swapping Ethereum ERC20 <strong>dTAU</strong> to Lamden <strong>dTAU</strong>.</p><p><em>Ethereum ERC20 dTAU has </em><strong><em>NO VALUE</em></strong><em> just like Lamden dTAU.</em></p><h4>Can I TEST the token swap function?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPVNHU0c2XbXz5-lEjY6LA.png" /></figure><p>ERC20 dTAU exists on the Ethereum Kovan Network and you can swap it for Lamden dTAU which runs the Lamden Testnet.</p><ol><li>Obtain some by asking an admin in the <a href="http://t.me/lamdenchat">Lamden Telegram</a> Chat Room for “ERC20 dTAU”. If you just ask for “dTAU” they will most likely try and send you Lamden dTAU; which is not what you want.</li><li>Have the admin send it to your Metamask wallet address; which you should provide to them.</li><li>Set your metamask wallet to the Kovan Network (dropdown at the top of Metamask popup)</li><li>Click the “Token Swap” menu option in the <a href="https://chrome.google.com/webstore/detail/lamden-wallet-browser-ext/fhfffofbcgbjjojdnpcfompojdjjhdim">Lamden Wallet</a> left-side menu.</li><li>Follow process to complete a swap</li></ol><h4>How do I know if I’m sending to an Ethereum address or a Lamden address?</h4><p>Ethereum and Lamden addresses are quite different looking. You should <strong>NEVER</strong> send Ethereum directly to a Lamden address or Lamden to an Ethereum address.</p><p><strong>Ethereum Address: </strong>0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7</p><p><strong>Lamden Address: </strong>0000e9f4137969c4ee2fc047917dacd53aeb220fae0bdc87a82024c0ff3c9e50</p><h4>What will happen to my Ethereum ERC20 tokens after the swap?</h4><p>The Ethereum ERC20 TAU will be burned; never to be recovered again.</p><h4>Where can I trade Lamden TAU after the swap?</h4><p>The official exchange to trade Lamden TAU after you swap will be <a href="https://txbit.io/">txbit.io</a>. More to come on the official txbit.io listing in a later communication.</p><p><strong>For more information, please visit:</strong></p><ul><li><a href="https://lamden.io/">Website</a></li><li><a href="https://twitter.com/LamdenTau">Twitter</a></li><li><a href="https://t.me/lamdenchat">Telegram</a></li><li><a href="https://contracting.lamden.io/">Lamden Contracting</a></li><li><a href="https://github.com/Lamden">Github</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb68ab59c38d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/lamden-tau-token-swap-faq-cb68ab59c38d">Lamden TAU Token Swap FAQ</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTPS for VPS as SubDomain and other Jargon]]></title>
            <link>https://medium.com/@JeffWScott/https-for-vps-as-subdomain-and-other-jargon-18959038af40?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/18959038af40</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[proxy-server]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Wed, 17 Jun 2020 17:20:21 GMT</pubDate>
            <atom:updated>2020-09-14T17:26:40.367Z</atom:updated>
            <content:encoded><![CDATA[<p>I ranted on twitter the other day about HTTPS being annoying</p><h3></h3><p></p><p>I got my answer so why not write about it!</p><h3>Here’s how you do it</h3><p>Basically my assumptions that Netlify would handle the HTTPS for me was incorrect even though their website lead me to believe it would, but that’s besides the point.</p><p>The only Netlify config needed was to point the subdomain to the Digital Ocean Droplet IP address in the DNS settings.</p><h4>Setup A Record</h4><p>Netlify just happens to host my DNS record. You add the same exact record on whoever hosts your DNS. “A Records” are a DNS standard and point a DNS name to an IP address. Which is exactly what I want.</p><ul><li>Go to netlify DNS settings for your domain</li><li>Click <strong>Add new record</strong></li><li>Fill in the information like so, making the <strong>value</strong> field the IP address of your VPS host (your digital ocean droplet or whatever you have).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*md0t3EkBvsrPbSswT8Viyg.png" /></figure><ul><li>Click <strong>Save</strong></li></ul><h4>Install Let’s Encrypt stack on your VPS</h4><ul><li>Add repository and install package</li></ul><pre>sudo add-apt-repository ppa:certbot/certbot<br>sudo apt-get update<br>sudo apt-get install python-certbot-nginx</pre><p>The last command will walk you through some setup to create your certificate. Assuming the A Record was created, everything should go well.</p><h4>Setup Nginx</h4><p>This is really the meat of the whole setup.</p><p>What we want to have happen is nginx handle the HTTPS certificate on port 443 and then pass the request over to our webserver to handle it.</p><p>This is referred to as a proxy server.</p><p>so let’s create that server.</p><ul><li>Remove the default NGINX server</li></ul><pre>rm /etc/nginx/sites-enabled/default</pre><ul><li>Create a new one</li></ul><pre>nano /etc/nginx/sites-available/proxy</pre><ul><li>Copy and Paste this code into it</li></ul><pre>server {<br>    listen 80;<br>    server_name <strong>sub.domain.com</strong>;<br>    location / {<br>        proxy_set_header   X-Forwarded-For $remote_addr;<br>        proxy_set_header   Host $http_host;<br>        proxy_pass         &quot;http://127.0.0.1:<strong>18080</strong>/&quot;;</pre><pre>    }<br>    listen 443 ssl;</pre><pre>    ssl_certificate /etc/letsencrypt/live/<strong>sub.domain.com</strong>/fullchain.pem;<br>    ssl_certificate_key /etc/letsencrypt/live/<strong>sub.domain.com</strong>/privkey.pem;<br>    include /etc/letsencrypt/options-ssl-nginx.conf;<br>    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;<br>}</pre><ul><li>Change all 3 <strong>sub.domain.com </strong>entries to your specific url (no http or https!)</li><li>Change the port under <strong>proxy_pass </strong>to the local port of your web server</li><li>Save and close nano (ctrl-x, y, enter)</li><li>Make our new server live</li></ul><pre>ln -s  /etc/nginx/sites-available/proxy /etc/nginx/sites-enabled/proxy</pre><ul><li>Restart NGINX</li></ul><pre>sudo systemctl reload nginx</pre><h3>DONE!</h3><p>Not so bad!</p><p>You should be able to browse to your DNS subdomain and your website should be served via HTTPS now.</p><p>This setup is particularly useful for serving APIs on HTTPS to avoid CORS errors from websites trying to consume your data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18959038af40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Frontend for your Smart Contract: Part B]]></title>
            <link>https://medium.com/lamden/a-frontend-for-your-smart-contract-part-b-e28a11dbdd8e?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e28a11dbdd8e</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 18:27:08 GMT</pubDate>
            <atom:updated>2020-11-14T15:42:46.070Z</atom:updated>
            <content:encoded><![CDATA[<h3>3b: A Frontend for your Smart Contract</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SC_wOpG0mhc7g1ns.png" /><figcaption>Part B</figcaption></figure><p>…this is a continuation from <a href="https://blog.lamden.io/a-frontend-for-your-smart-contract-29381108a5d5">A Frontend for your Smart Contract : A</a></p><h3>frontend/src/routes/users/[user].svelte continued</h3><p>Our smart contract doesn’t just store balances. It also gives our users the ability to send tokens to other users by calling the “transfer” method.</p><p>In <a href="https://blog.lamden.io/python-smart-contract-dev-server-f81bd605a92c">Part 2</a> we created an API endpoint to be able to call this transfer method and provide the arguments.</p><p>What we need now is a form on our website that lets the user fill in the required arguments (receiver and amount). And then we need to feed that information to the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cMD1RYU8167AZswa54YUIQ.png" /></figure><p>This is the end goal. Let’s start by making the <strong>form section</strong> in the purple box.</p><p>This form contains 4 elements. A message and 3 input elements (two text boxes and a submit button)</p><p>Add the code <strong>in bold</strong> under the existing <strong>Token Balance &lt;h2&gt;</strong> tag.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre><strong>...<br></strong>&lt;h2&gt;Token Balance: {<em>value</em>}&lt;/h2&gt;<strong><br>&lt;form on:submit|preventDefault={transfer}&gt;<br>   &lt;h3&gt;Make a transfer&lt;/h3&gt;<br>   &lt;label for=&quot;to&quot;&gt;To&lt;/label&gt;<br>   &lt;input type=&quot;text&quot; name=&quot;to&quot; bind:value={<em>receiver</em>} required=&quot;true&quot;/&gt;<br>   &lt;label for=&quot;amount&quot;&gt;Token Amount&lt;/label&gt;<br>   &lt;input type=&quot;number&quot; name=&quot;amount&quot; bind:value={<em>amount</em>} required=&quot;true&quot;/&gt;<br>   &lt;input class=&quot;button&quot; type=&quot;submit&quot; value=&quot;send&quot;/&gt;<br>&lt;/form&gt;</strong></pre><pre><strong><br>...</strong></pre><p>Let’s take a look at the code we pasted in. It should look very familiar to the <strong>form</strong> code we created in <a href="https://blog.lamden.io/a-frontend-for-your-smart-contract-29381108a5d5">Part 3A</a>.</p><pre>&lt;form <strong>on:submit|preventDefault={transfer}</strong>&gt;<br>   &lt;h3&gt;Make a transfer&lt;/h3&gt;<br>   &lt;label for=&quot;to&quot;&gt;To&lt;/label&gt;<br>   &lt;input <strong>type=&quot;text&quot;</strong> name=&quot;to&quot; <strong>bind:value={receiver}</strong> required=&quot;true&quot;/&gt;<br>   &lt;label for=&quot;amount&quot;&gt;Token Amount&lt;/label&gt;<br>   &lt;input <strong>type=&quot;number&quot;</strong> name=&quot;amount&quot; <strong>bind:value={<em>amount</em>}</strong> required=&quot;true&quot;/&gt;<br>   &lt;input class=&quot;button&quot; type=&quot;submit&quot; value=&quot;send&quot;/&gt;<br>&lt;/form&gt;</pre><p>Bind the form’s <strong>submit</strong> event to a function we will create later called <strong>transfer</strong>.</p><pre>&lt;input <strong>type=&quot;text&quot;</strong> name=&quot;to&quot; <strong>bind:value={receiver}</strong> required=&quot;true&quot;/&gt;</pre><p>Create a <strong>text </strong>input box and bind its value to a variable we will create later called <strong>receiver.</strong></p><pre>&lt;input <strong>type=&quot;number&quot;</strong> name=&quot;amount&quot; <strong>bind:value={<em>amount</em>}</strong> required=&quot;true&quot;/&gt;</pre><p>Create a <strong>number </strong>input box and bind its value to a variable we will create later called <strong>amount.</strong></p><p>In our JavaScript &lt;script&gt; section we need to create these 3 bindings before our webpage will render again.</p><p>Add the <strong>bold code </strong>below inside your &lt;script&gt; tag <strong>below the export</strong> statements.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre><strong>...</strong><br>&lt;script&gt;<br>   export let <em>value</em>;<br>   export let <em>user</em>;<br><strong><br>   let <em>receiver </em>= &quot;&quot;;<br>   let <em>amount </em>= 0;<br><br>   const transfer = async () =&gt; {<br>      const transaction = {<br>         sender: <em>user</em>,<br>         contract: &#39;my_token&#39;,<br>         method: &#39;transfer&#39;,<br>         args: {<br>            <em>receiver</em>,<br>            <em>amount<br>         </em>}<br>      }<br><br>      const options = {<br>         method: &#39;POST&#39;,<br>         headers: {<br>            &#39;Content-Type&#39;: &#39;application/json&#39;<br>         },<br>         body: <em>JSON</em>.stringify(transaction)<br>      }<br><br>      const res = await fetch(`http://localhost:3737/`, options)<br>      const data = await res.json();<br>      if (data.error) {<br>         alert(data.error);<br>      }else{<br>         alert(&quot;You sent &quot; + <em>amount </em>+ &quot; token(s) to &quot; + <em>receiver </em>+ &quot;!&quot;);<br>      }<br>   }</strong><br>&lt;/script&gt;</pre><pre><strong>...</strong></pre><pre>   <strong>let <em>receiver </em>= &quot;&quot;;<br>   let <em>amount </em>= 0;</strong></pre><p>Here we create our two variables to satisfy the bindings from the input boxes.</p><pre><strong>const transfer = async () =&gt; {</strong></pre><p>Here we define the <strong>async</strong> function that our <strong>form’s submit event</strong> will call.</p><pre><strong>const</strong> <strong>transaction</strong> = {<br>         sender: <strong><em>user</em></strong>,<br>         contract: <strong>&#39;my_token&#39;</strong>,<br>         method: <strong>&#39;transfer&#39;</strong>,<br>         args: {<br>            <strong>receiver</strong>,<br>            <strong><em>amount</em></strong><em><br>         </em>}<br>      }</pre><p>This creates a <strong>transaction</strong> object that we will send to our contracting server API endpoint. This transaction object has all the information the server needs to process the transfer for us. Let’s break down the information.</p><ul><li><strong>sender</strong>: This is the account of the person who is SENDING the transaction. This becomes <strong>ctx.caller</strong> in our smart contract transaction method. If it’s been a while you should open the smart contract code and refresh your memory.</li><li><strong>contract</strong>: The name of our smart contract. We set the API server up to process ANY smart contract. So, we need to tell it specifically which one we are trying to interact with.</li><li><strong>method</strong>: Which method in our smart contract to execute. In this case our smart contract only has one method, but we still need to specify it.</li><li><strong>args</strong>: The arguments to supply to the method being called. Specifically, the transfer method we designed takes two arguments, <strong>amount</strong> and <strong>receiver</strong>. It’s important here that we pass our variables with the correct names and types as to what our smart contract expects.</li></ul><pre>const <strong>options</strong> = {<br>   method: <strong>&#39;POST&#39;</strong>,<br>   headers: {<br>      &#39;Content-Type&#39;: <strong>&#39;application/json&#39;</strong><br>   },<br>   body: <strong><em>JSON</em>.stringify(transaction)</strong><br>}</pre><p>This is a standard object created to send a “POST” request. You can learn more about <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods">HTTP requests</a> here if you’re curious, but it’s outside this tutorial’s scope. All you really need to know is to send data (our transaction object) to the API server we need to create a POST request. All our previous calls to the API server were GET requests which are generally used to GET information and are the default request type.</p><ul><li><strong>method</strong>: We want to tell the server this is a POST request. Our API endpoint is setup to expect this type of request (go back and look at the contracting server, “/” endpoint code to verify.</li><li><strong>headers</strong>: We’re going to send a “Content-Type” header to tell the server what type of data we are sending so it can decode it on the other-side. In this case we are sending a JSON string, so we send <strong>‘application/json’ </strong>as the type.</li><li><strong>body</strong>: This is the main payload of our request in which we will send the <strong>transaction</strong> object we created above. We can’t send just the JavaScript object we have to encode it as a string. To do that we encode it as a JSON string which is a universally understood method of encoding. This ensures the server can decode the information properly on the other end. <a href="https://www.w3schools.com/js/js_json_syntax.asp">You can read up on JSON here</a> if you are unfamiliar.</li></ul><pre>const <strong>res</strong> = <strong>await</strong> <strong>fetch</strong>(`http://localhost:3737/`, <strong>options</strong>)</pre><p>Here we call fetch again and supply it with the URL of our contracting server then we feed the options object as fetch’s second argument.</p><p>Because we created transfer as an <strong>async </strong>function we have the ability to <strong>await </strong>the fetch request result and we store the result in the <strong>res </strong>variable.</p><pre>const <strong>data</strong> = <strong>await</strong> res.<strong>json();</strong></pre><p>Just like we sent our data to the server serialized as a JSON string, the server sent us some data also serialized in JOSN. We can call the <strong>res</strong> object’s <strong>.json()</strong> method to decode that JSON back into a JavaScript object for us and we store it in a variable called <strong>data</strong>. The <strong>.json() </strong>method is <em>asynchronous</em> so we need to <strong>await</strong> the result, or our code will pass right by it before it’s finished decoding.</p><pre><strong>if</strong> (data.<strong>error</strong>) {<br>   <strong>alert</strong>(data.error);<br>}<strong>else</strong>{<br>   <strong>alert</strong>(&quot;You sent &quot; + <strong><em>amount </em></strong>+ &quot; token(s) to &quot; + <strong><em>receiver </em></strong>+ &quot;!&quot;);<br>}</pre><p>Now we can look at the data returned from our API server and decide how we want to handle it.</p><p>This <strong>if</strong> statement looks to see if our data object has a property called <strong>error</strong>. We know that if our API server has an issue with processing the smart contract that it will pass that message back in the <strong>error</strong> property. If the <strong>error</strong> property exists, then we will create a browser <strong>alert</strong> box that will show that error to the user.</p><p>If there is no <strong>error</strong> property, then we can assume our smart contract completed. In a real blockchain situation we would get a success/failure status code back from our hash result to know for sure. But since smart contracts either fail or complete we can assume that if there was no error that our transaction was successful and pass the user a “success” message to let them know their transaction completed.</p><p>Now if you refresh your token site <a href="http://localhost:3000">http://localhost:3000</a>, log in as <strong>me, </strong>you should see this screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgbHWtS5id57EKTN_tvQdw.png" /></figure><p>Well, all of our elements are there, but it’s pretty ugly. We need some styling. Add the following CSS between the <strong>&lt;style&gt;&lt;/style&gt;</strong> tags. Then refresh your page.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>...<br>&lt;/script&gt;</pre><pre>&lt;style&gt;<br>   p{<br>      font-size: 1.2em;<br>   }<br>   .shadowbox{<br>      padding: 0.5rem 20px;<br>   }<br><strong>   form{<br>      padding: 50px;<br>      color: #461BC2;<br>      display:flex;<br>      flex-direction: column;<br>      border: none;<br>      box-sizing: border-box;<br>   }<br>   form &gt; h2{<br>      margin: 0;<br>      font-weight: 600;<br>      line-height: 2.2;<br>      letter-spacing: 1px;<br>   }<br>   form &gt; input{<br>      margin-bottom: 1rem;<br>   }<br>   input[type=&quot;submit&quot;] {<br>      margin-right: 20px;<br>   }</strong><br><strong>   .buttons {<br>      display: flex;<br>      flex-direction: row;<br>      justify-content: flex-end;<br>      margin-top: 1rem;<br>   }</strong><br>&lt;/style&gt;</pre><pre>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LsolDO0R4skX4ItH7ioiw.png" /></figure><p>Much better!</p><p>Let’s test. Type the word <strong><em>you</em></strong> in the <strong>To</strong> box. Type <strong><em>100</em> </strong>in the <strong>Token Amount</strong> box and click the <strong>SEND </strong>button.</p><p>You should get this message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*8w0YFMMz_tfIqu9hU12xPg.png" /></figure><p>That’s great! Everything is working perfectly so far. Let’s try and make a legitimate transfer now.</p><p>Type the word <strong><em>you</em> </strong>in the <strong>To</strong> box. Enter <strong><em>5</em> </strong>in the <strong>Token Amount</strong> box and click <strong>SEND</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*QBtFIOfhhiwKJk39K0xXFg.png" /></figure><p>This is great! We have confirmation that we sent <strong>5</strong> tokens to <strong>you.</strong></p><p>But it’s not all perfect. When we click <strong>OK</strong> to close the popup the user interface still shows us we have 50 tokens. If we refresh the page, we will see the Token Balance is now 45. This is because the webpage updates the value again from the server when we manually refresh it. But it’s not a good design to ask the user to refresh the page every time they send a transaction.</p><p>Additionally, we should reset both input box values to get the user ready for a new transfer.</p><p>What should happen here, is that after the transfer is deemed complete, the webpage should make a request to the API server again to get the user’s new balance and display it.</p><p>We already know how to do this because we did it in the module before the page loads!</p><p>Let’s make a new function in our &lt;script&gt; tag, <strong>under the transfer function</strong>.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;<br>...<br>&lt;script&gt;<br>...<br><br>   const transfer = async () =&gt; {<br>      // code hidden<br>   }<br><br><strong>   const refreshBalance = async () =&gt; {<br>      const res = await fetch(&quot;http://localhost:3737/contracts/my_token/S?key=&quot; + <em>user</em>)<br>      let data = await res.json();<br>      <em>value </em>= data.value;<br>   }</strong><br><br>&lt;/script&gt;<br><strong>...</strong></pre><p>This <strong>async</strong> <strong>refreshBalance</strong> function <strong>awaits</strong> the result of a <strong>fetch</strong> call to our &lt;variables&gt; endpoint just like we did in the module before the page was loaded. We can then update the webpages <strong>value</strong> variable with the value from the data response. Svelte will handle making sure that value gets re-rendered.</p><p>The second function we need to create is one to reset our bound input variables back to the defaults. Create this one <strong>under the refreshBalances </strong>function.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>...<br>   const refreshBalance = async () =&gt; {<br>      const res = await fetch(&quot;http://localhost:3737/contracts/my_token/S?key=&quot; + <em>user</em>)<br>      let data = await res.json();<br>      <em>value</em><strong><em> </em></strong>= data.value;<br>   }<br><br><strong>   const clearInputs = () =&gt; {<br>      <em>receiver </em>= &quot;&quot;<br>      <em>amount </em>= 0<br>   }</strong><br>&lt;/script&gt;</pre><pre><strong>...</strong></pre><p>This <strong>clearInputs </strong>is NOT defined as <strong>async</strong> because we don’t need to <strong>await</strong> the result of anything.</p><ul><li><strong>receiver</strong> is a <a href="https://developer.mozilla.org/en-US/docs/Glossary/String">String type variable</a>, so it’s default value is set to an empty string</li><li><strong>amount</strong> is a <a href="https://developer.mozilla.org/en-US/docs/Glossary/Number">Number type variable</a>, so its default value is set to 0</li></ul><p>Now let’s call these two functions under the success alert at the end of the <strong>transfer</strong> function so they are called on the event of a successful transfer.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>...<br>      if (data.error) {<br>         alert(data.error);<br>      }else{<br>         alert(&quot;You sent &quot; + <em>amount</em><strong><em> </em></strong>+ &quot; token(s) to &quot; + <em>receiver</em><strong><em> </em></strong>+ &quot;!&quot;);<br><strong>         clearInputs();<br>         refreshBalance();</strong><br>      }<br>   }<br><br>   const refreshBalance = async () =&gt; {<br><strong>...</strong></pre><p>Let’s try another transfer of <strong>5 </strong>tokens to <strong>you</strong> and hopefully the page will re-render the token amount to 40 automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2ocVZHLEBm7v8HCiwVJRA.png" /></figure><p>Perfect! Everything is now working good from a UX (user experience) perspective.</p><p>The final thing we will add is a <strong>sign out</strong> button.</p><p>This will be almost identical to the sign in button created in <a href="https://blog.lamden.io/a-frontend-for-your-smart-contract-29381108a5d5">Part A</a>. We will use Sapper’s <strong>goto</strong> function to repoint the browser back to the sign in page.</p><p>Below our form add the following <strong>button</strong> element inside a new <strong>&lt;div&gt;</strong> tag.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>...<br>&lt;form on:submit|preventDefault={transfer}&gt;<br>   &lt;h2&gt;Enter Transfer Details&lt;/h2&gt;<br>   &lt;label for=&quot;to&quot;&gt;To&lt;/label&gt;<br>   &lt;input type=&quot;text&quot; name=&quot;to&quot; bind:value={<strong><em>receiver</em></strong>} required=&quot;true&quot;/&gt;<br>   &lt;label for=&quot;amount&quot;&gt;Token Amount&lt;/label&gt;<br>   &lt;input type=&quot;number&quot; name=&quot;amount&quot; bind:value={<strong><em>amount</em></strong>} required=&quot;true&quot;/&gt;<br><strong>   &lt;div class=&quot;buttons&quot;&gt;</strong><br>      &lt;input class=&quot;button&quot; type=&quot;submit&quot; value=&quot;send&quot;/&gt;<br><strong>      &lt;button class=&quot;button&quot; on:click={logout}&gt;sign out &lt;/button&gt;</strong><br><strong>   &lt;/div&gt;</strong><br>&lt;/form&gt;<strong><br>...</strong></pre><p>This button has a binding on the <strong>click</strong> event to run a new function we will create called <strong>logout.</strong></p><p>Add a statement at the top of the &lt;script&gt; tag (<strong>not</strong> the module script tag) to <strong>import the goto function</strong> from Sapper.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>...<br>&lt;script&gt;<br><strong>   import { goto } from &#39;@sapper/app&#39;;</strong><br><br>   export let <em>value</em>;<br>   export let <em>user</em>;<br><br>   let <em>receiver</em><strong><em> </em></strong>= &quot;&quot;;<br>   let <em>amount</em><strong><em> </em></strong>= 0;<br>...</pre><p>Then create a new function to call goto and point the browser to the root of our project.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>...<br>   const clearInputs = () =&gt; {<br>      <em>receiver</em><strong><em> </em></strong>= &quot;&quot;<br>      <em>amount</em><strong><em> </em></strong>= 0<br>   }<br><br><strong>   const logout = () =&gt; {<br>      goto(`.`);<br>   }</strong><br>&lt;/script&gt;<br>...</pre><ul><li>Refresh the page and click the new <strong>sign out</strong> button</li><li>Sign in as user <strong>you</strong> and check their token balance. 10 whole tokens!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssuZ4c7e1DYdZ1ZNl8CcMw.png" /></figure><h3>Finished!</h3><p>You now have a fully functioning web frontend with a python smart contract backend.</p><p><a href="https://github.com/JeffWScott/my_token_lamden_tutorial/tree/part_3b">You can check out the completed git repo for this part of the tutorial here.</a></p><h3>What’s next?</h3><p>Now that we have a tested and functioning smart contract with a functioning proof of concept frontend the next tutorials will be about adding the public blockchain to mix. This brings with it some new concepts, but I will tackle them one by one to make it understandable.</p><p>This is what to expect in the coming weeks:</p><ul><li>Upload our working smart contract to the blockchain</li><li>Add user authentication via the Lamden Wallet</li><li>Accessing our smart contract variables from the blockchain. This is still going to be API driven but it will require just a slight modification to our code.</li><li>Creating transactions will be very similar to our API server requests except this time we will send them through the Lamden Wallet which will return our transaction results which we can process in largely the same way.</li></ul><p><a href="https://blog.lamden.io/4-uploading-your-smart-contract-to-the-blockchain-fe0178d90df6"><strong>Check out Part 4: Uploading your smart contract to the blockchain</strong></a></p><p>I’m available to chat on <a href="https://twitter.com/JeffWScott">twitter</a>, <a href="https://t.me/lamdenjeff">telegram</a> or <a href="https://www.linkedin.com/in/jeff-scott-69877978">linkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e28a11dbdd8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/a-frontend-for-your-smart-contract-part-b-e28a11dbdd8e">A Frontend for your Smart Contract: Part B</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Frontend for your Smart Contract]]></title>
            <link>https://medium.com/lamden/a-frontend-for-your-smart-contract-29381108a5d5?source=rss-6159d4797ba5------2</link>
            <guid isPermaLink="false">https://medium.com/p/29381108a5d5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Jeff Scott]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 18:17:17 GMT</pubDate>
            <atom:updated>2020-06-24T18:25:44.618Z</atom:updated>
            <content:encoded><![CDATA[<h3>3a: A Frontend for your Smart Contract</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0DGeTo4Znk9F8GaQrbRPA.png" /><figcaption>Part A</figcaption></figure><p>This tutorial is part of a series that demonstrates how to create a working application with Python contracting.</p><p>In previous tutorials we created a Python smart contract as well as an API dev server to interact with it.</p><p>Here are the previous two tutorials in this my_token series</p><ul><li>Part 1: <a href="https://blog.lamden.io/smart-contracting-with-python-2af233620dca">Smart Contracting with Python</a></li><li>Part 2: <a href="https://blog.lamden.io/python-smart-contract-dev-server-f81bd605a92c">Python Smart Contract Dev Server</a></li></ul><p>In this tutorial (Part 3a) we will install a frontend web framework called <a href="https://sapper.svelte.dev/">Sapper</a> to create a user interface for our smart contract.</p><h3>Setup</h3><p>For this test we will use a simple lightweight framework called <a href="https://sapper.svelte.dev/">Sapper</a>.</p><h4>Dependencies</h4><p>You will need the dependencies from the last two tutorials as well as these two new ones.</p><p>Install the latest <a href="https://nodejs.org/">NodeJs</a> follow instructions on the NodeJs site.</p><p><strong>Install Sapper:</strong></p><p>With NodeJs installed; go to your <strong>my_token</strong> project directory and type this command.</p><pre>npx degit &quot;sveltejs/sapper-template#rollup&quot; frontend<br>cd frontend<br>npm install</pre><p>Now let’s test that we can view the Sapper test site.</p><p>Enter the below command from the <strong>frontend</strong> directory</p><pre>npm run dev</pre><p>Open your internet browser and go to<a href="http://localhost:3000"> <strong>http://localhost:3000</strong></a></p><p>If you see this page load, then Sapper is up and running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HPMvza44Yq88U_RxjiVuaA.png" /></figure><p>The Sapper starter template comes with a bunch of files we won’t need for our project and there are some files we need to create and edit.</p><p>Follow these steps to organize our project.</p><ol><li><strong>Overwrite the files in frontend/static/ with these files</strong></li></ol><p>Save then to your computer then copy them to the folder</p><ul><li><a href="https://github.com/JeffWScott/my_token/blob/master/frontend/static/favicon.png">favicon.png</a></li><li><a href="https://github.com/JeffWScott/my_token/blob/master/frontend/static/global.css">global.css</a></li><li><a href="https://github.com/JeffWScott/my_token/blob/master/frontend/static/logo-192.png">logo-192.png</a></li><li><a href="https://github.com/JeffWScott/my_token/blob/master/frontend/static/logo-512.png">logo-512.png</a></li><li><a href="https://github.com/JeffWScott/my_token/blob/master/frontend/static/token.png">token.png</a></li></ul><p><strong>2. Delete this folder (and all files in it)</strong></p><ul><li>frontend/src/routes/blog</li></ul><p><strong>3. Delete these files</strong></p><ul><li>frontend/src/routes/about.svelte</li><li>frontend/static/successkid.jpg</li></ul><p><strong>4. Create this folder</strong></p><ul><li>frontend/src/routes/users</li></ul><p><strong>5. Create this file</strong></p><ul><li>frontend/src/routes/users/[user].svelte</li></ul><p><strong>5. Edit these files</strong></p><ul><li>frontend/package.json</li></ul><pre>&quot;name&quot;: &quot;<strong>my_token</strong>&quot;,<br>&quot;description&quot;: &quot;<strong>A simple smart contract tutorial</strong>&quot;,</pre><ul><li>frontend/static/manifest.json</li></ul><pre>&quot;background_color&quot;: &quot;<strong>#A1A0C926</strong>&quot;,<br>&quot;theme_color&quot;: &quot;<strong>#5F5E9D</strong>&quot;,<br>&quot;name&quot;: &quot;<strong>My Token</strong>&quot;,<br>&quot;short_name&quot;: &quot;<strong>My Token Tutorial Project</strong>&quot;,</pre><p><strong>6. Replace ALL the code in these files with the code provided</strong></p><ul><li>frontend/src/components/Nav.svelte</li></ul><pre>&lt;!-- frontend/src/components/Nav.svelte --&gt;</pre><pre><strong>&lt;style&gt;<br>   nav {<br>      padding: 0 1rem;<br>      display: flex;<br>      flex-direction: row;<br>      align-items: center;<br>   }<br>   h2{<br>      margin: 0;<br>   }<br>&lt;/style&gt;<br><br>&lt;nav&gt;<br>   &lt;img alt=&#39;Token&#39; src=&#39;token.png&#39;&gt;<br>   &lt;h2&gt;My Token&lt;/h2&gt;<br>&lt;/nav&gt;</strong></pre><ul><li>frontend/src/routes/_layout.svelte</li></ul><pre>&lt;!-- frontend/src/routes/_layout.svelte --&gt;</pre><pre><strong>&lt;script&gt;<br>   import Nav from &#39;../components/Nav.svelte&#39;;<br>&lt;/script&gt;<br><br>&lt;style&gt;<br>   main {<br>      position: relative;<br>      max-width: 56em;<br>      padding: 0 28px;<br>      margin: 0 auto;<br>      box-sizing: border-box;<br>   }<br>&lt;/style&gt;<br><br>&lt;Nav /&gt;<br>&lt;main&gt;<br>   &lt;slot&gt;&lt;/slot&gt;<br>&lt;/main&gt;</strong></pre><ul><li>frontend/src/routes/index.svelte</li></ul><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre><strong>&lt;script&gt;&lt;/script&gt;<br><br>&lt;style&gt;<br>   *{<br>      text-align: center;<br>   }<br>&lt;/style&gt;<br><br>&lt;svelte:head&gt;<br>   &lt;title&gt;My Token&lt;/title&gt;<br>&lt;/svelte:head&gt;<br><br>&lt;h1&gt;Welcome to My Token&lt;/h1&gt;</strong></pre><p><strong>7. Restart the Sapper dev server</strong></p><p>From your command prompt do a<strong> control + c </strong>to stop the dev server and then enter this command to start it again.</p><pre>npm run dev</pre><p>Now when you navigate your browser to <a href="http:localhost:3000">http:localhost:3000</a> you should see our starter My Token website!</p><p>**You may need to hold shift and click refresh to get the style sheet to reapply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjkbfHHxsGu1FuwoJTbZCA.png" /></figure><h3>The Svelte framework</h3><p><a href="https://sapper.svelte.dev/">Sapper</a> is a Single Page Application (SPA) implementation of <a href="https://svelte.dev/">Svelte</a>. Svelte is a web framework that makes organizing our programming logic very easy as we can keep all the JavaScript (logic), CSS (styles) and HTML (markup/layout) in one file.</p><p>Svelte allows us to create “responsive” code, which mean our webpage can easily respond and update to user interactions. By using Svelte we can get a surprising amount of functionality out of a website without using boilerplate logic (code that is native to a framework but not native to JS, CSS or HTML) or needing a Virtual DOM.</p><p>I mention this only because the files we will be editing have the extension “.svelte”; which could be different if you have made websites previously. When we build our project Svelte automatically compiles these files into the necessary .html, .js and .css files to make a fast and responsive static website.</p><h3>frontend/src/routes/index.svelte</h3><p>Right now, our site has a Navbar Icon and a nice greeting. What we need now is a login box and a sign-in button.</p><p>We will do this by adding a <a href="https://www.w3schools.com/html/html_forms.asp"><strong>form</strong></a> to our <strong>index.svelte</strong> file.</p><p>Add the following code.</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre><strong>...</strong><br>&lt;/svelte:head&gt;<br><br>&lt;h1&gt;Welcome to My Token&lt;/h1&gt;</pre><pre><strong>&lt;form&gt;<br>   &lt;p&gt;Check your token balance&lt;/p&gt;<br>   &lt;input type=&quot;text&quot; required=&quot;true&quot;/&gt;<br>   &lt;input class=&quot;button&quot; type=&quot;submit&quot; value=&quot;sign in&quot; /&gt;<br>&lt;/form&gt;</strong></pre><p>This will add the necessary HTML to render us</p><ul><li>a message</li><li>an input box that the user can type in</li><li>a sign in button they can click.</li></ul><p>If your refresh the website, it should now look like this now.</p><p><strong>** Sapper will automatically refresh the webpage when you save your changes. But I mention “refreshing” just in case it fails to.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3WFwjZ67Cze2yRJtjBH-0A.png" /></figure><p>It looks great but nothing happens when we click the button! So, let’s add some interactivity.</p><p>We need our website to capture the username typed in the box, so let’s wire it up to a variable. Add the following code <strong>in bold </strong>to the input box.</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre><strong>...</strong><br>&lt;p&gt;Check your token balance&lt;/p&gt;<br>&lt;input type=&quot;text&quot; <strong>bind:value={<em>user</em>}</strong> required=&quot;true&quot;/&gt;<br>&lt;input type=&quot;submit&quot; value=&quot;sign in&quot; /&gt;<br><strong>...</strong></pre><p>This will <strong>BIND</strong> the value of the input box to a variable we called <strong>“user”</strong>.</p><p>We don’t have a <strong>user</strong> variable defined yet, so let’s add that JavaScript between our <strong>&lt;script&gt; </strong>tags above.</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre>&lt;script&gt;<br>   <strong>let <em>user </em>= &quot;&quot;;</strong><br>&lt;/script&gt;</pre><p>Now our webpage can track the user input in the box. To prove it lets output the value of our user variable to the webpage.</p><p>Add this code under the <strong>h1</strong> tag near the bottom of our file.</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre><strong>...</strong><br>&lt;h1&gt;Welcome to My Token&lt;/h1&gt;<br><strong>&lt;p&gt;{<em>user</em>}&lt;/p&gt;</strong><br>&lt;form&gt;<br><strong>...</strong></pre><p>When we use these bracket in our HTML it allows us to render JavaScript on the webpage. It’s a good way to display the value of variables our webpage is keeping track of. <strong>{user} </strong>will output the value of our user variable, which is being updated every time the user types in the box.</p><p>Refresh the webpage and type your name in the box, you should now see the webpage render what you are typing in real-time. Cool!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHl8dsbmmvQwZfO_uEC0Hw.png" /></figure><p>Okay, as cool as that is, we don’t need to display the name there. This was just to illustrate that our variable is being updated (bound) to the value of the input box.</p><p>Go ahead and remove the <strong>&lt;p&gt;{user}&lt;/p&gt;</strong> line from our code we just added.</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre><strong>...</strong><br>&lt;h1&gt;Welcome to My Token&lt;/h1&gt;<br><strong>&lt;!-- Line deleted! --&gt;</strong><br>&lt;form on:submit|preventDefault={login}&gt;<br><strong>...</strong></pre><p>When the user hits <strong>enter </strong>on the keyboard with the cursor in the input box, or clicks the button, the form will attempt a <strong>submit</strong> event. We need to bind the triggering of that event to a function that will login the user.</p><p>Add this event binding inside the <strong>form </strong>tag</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre><strong>...</strong><br>&lt;form <strong>on:submit|preventDefault={login}</strong>&gt;<br>   &lt;p&gt;Check your token balance&lt;/p&gt;<br>   &lt;input type=&quot;text&quot; bind:value={user} required=&quot;true&quot;/&gt;<br><strong>...</strong></pre><p><strong>on:submit</strong> tells Svelte we want to bind to the submit event when it’s triggered.</p><p><strong>|preventDefault </strong>tells the webpage to ignore the default behavior of this event.</p><p><strong>={login} </strong>tells the webpage to instead run our custom function called “login”.</p><p>Let’s now go back to our JavaScript &lt;script&gt; tag and write the login function.</p><p>Sapper has a built-in function that we can call to switch pages called “goto”. We need to import that function from the Sapper package and then call it in our new login function.</p><p>Add the following code <strong>in bold </strong>to our script tag.</p><pre>&lt;!-- frontend/src/routes/index.svelte --&gt;</pre><pre>&lt;script&gt;<br><strong>   import { goto } from &#39;@sapper/app&#39;;</strong><br><br>   let <em>user </em>= &quot;&quot;<br>   <br><strong>    const login = () =&gt; {<br>      goto(&#39;/users/&#39; + <em>user</em>);<br>   }</strong><br>&lt;/script&gt;<br><strong>...</strong></pre><p>This line is our import statement to make the Sapper <strong>goto</strong> function available.</p><pre><strong>import { goto } from &#39;@sapper/app&#39;;</strong></pre><p>This is our login function definition. As you can see, we are calling the <strong>goto</strong> function and passing it the new route we want our webpage to render.</p><pre><strong>const login = () =&gt; {<br>   goto(&#39;/users/&#39; + <em>user</em>);<br>}</strong></pre><p><strong>‘/users/’ + user</strong> will concatenate the string value “/users/” with the <strong>user </strong>variable we made earlier. This will create the dynamic route that Sapper will render for us. So, if the user entered the name “byron” then Sapper would attempt to take us to the route <a href="http://localhost:3000/users/byron.">http://localhost:3000/users/byron.</a></p><p>Save your index.Svelte and refresh the webpage.</p><p>Enter a username and click sign in. Notice the address bar updates with our route, including the username. I’m sure you also see that the page is blank. That is because we haven’t created this route yet, but we will now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4A-vVc2wwoqAZEBNwESWuQ.png" /></figure><h3>frontend/src/routes/users/[user].svelte</h3><p>For a browser to render a route it needs the html file to be served to it from the web server. In this case the browser is asking our web server at <a href="http://localhost:3000"><strong>http://localhost:3000</strong></a> for the html file associated with the route<strong>/users/me</strong>.</p><p>We’re good, but we could never create 1 html file for every possible username. That would take too much time. Luckily Sapper can create these html files dynamically for us and send them to the browser.</p><p>When the browser passes the route into to Sapper it will take the last part of the route and make a variable, we can access in our JavaScript. Then we can use that variable to render information about the user on the webpage.</p><p>Sounds more complicated than it is, because Sapper makes it easy.</p><p>Sapper takes the first part of the route <strong>/users/ </strong>and looks for a folder under frontend/routes that matches. In this case we created this folder during our setup in step 4.</p><p>The <strong>[user] </strong>part of our filename tells Sapper what we want the variable to be called in our file. Sapper then takes the last part of the route, <strong>me</strong>, and passes it into our file. We created this file during our setup in step 5.</p><p>This is again a regular Svelte file, but with one addition, a module declaration.</p><p>Paste this code into frontend/src/routes/users/[user].svelte. Most of it should look familiar to your from the last file, except now we have this extra &lt;script&gt; tag at the top that has a <strong>context=”module”</strong> property.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>&lt;script <strong>context=&quot;module&quot;</strong>&gt;<br>   export async function preload({ params, query }) {<br>      return { user: params.user };<br>   }<br>&lt;/script&gt;<br><br>&lt;script&gt;<br>   export let <em>user</em>;<br>&lt;/script&gt;<br><br>&lt;style&gt;<br>&lt;/style&gt;<br><br>&lt;svelte:head&gt;<br>   &lt;title&gt;{<em>user </em>+ &quot;&#39;s Tokens&quot;}&lt;/title&gt;<br>&lt;/svelte:head&gt;<br><br>&lt;h1&gt;{&quot;Hello &quot; + <em>user </em>+ &quot;!&quot;}&lt;/h1&gt;</pre><p>Refresh your page and you should now see this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3CF78R_rdEeBSs7AwRL3Kg.png" /></figure><p>This is looking great. We changed the tab name to include the username we also included a personalized greeting.</p><p>How does this work? Well our module runs first, and the Sapper <strong>preload</strong> function within it gets passed the <strong>params </strong>object. One of the properties of this object is our “user” value. So, <strong>params.user</strong>, in the picture above would have equaled<strong> “me”</strong>. The return statement from the preload function gets passed to our regular &lt;script&gt; tag.</p><p>In the regular &lt;script&gt; tag we <strong>export</strong> a variable called <strong>user</strong> and Sapper binds that to the user value returned from the module.</p><p>Makes complete sense, right? Well, you don’t have to worry about that right now, just know it does! More importantly we can use this module to get MORE information to display on the page, including information from our Smart Contract (Remember that? the whole reason we are doing this exercise!)</p><p>Replace your current module code with this code instead.</p><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre>&lt;script context=&quot;module&quot;&gt;<br><strong>   export async function preload({ params, query }) {<br>      const res = await this.fetch(`http://localhost:3737/contracts/my_token/S?key=${params.user}`)<br>      const data = await res.json();<br>      if (data.value === &#39;undefined&#39;) this.error(res.status, data.message);<br>      if (data.value === null) data.value = 0;<br>      return { value: data.value, user: params.user };<br>   }</strong><br>&lt;/script&gt;</pre><pre><strong>...</strong></pre><p>There is a lot going on here, depending on your expertise you’ll understand all of it or none if it.</p><pre>export async function preload({ params, query })</pre><p>This line defines the preload function, which we talked about already.</p><pre>const res = await this.fetch(&quot;http://localhost:3737/contracts/my_token/S?key=&quot; + <strong>params.user</strong>)</pre><p>On this line we call <strong>this.fetch</strong> (a wrapper around node’s fetch utility), to get the user’s token balance from our smart contracting server. The value being passed to this.fetch is our &lt;variable&gt; API route, created in the last tutorial; with the user concatenated to the end to become the <strong>“key”</strong>.</p><ul><li><strong>*This is probably a good time for you to check if the contracting server </strong><a href="https://blog.lamden.io/python-smart-contract-dev-server-f81bd605a92c"><strong>we created last tutorial</strong></a><strong> is started.</strong></li><li>You can copy and paste <a href="http://localhost:3737/contracts/my_token/S?key=me">http://localhost:3737/contracts/my_token/S?key=me</a> into your browser to validate your contracting API server is working correctly, you should get <strong>{ “value”: 50 }</strong>.</li></ul><p>The response object from this.fetch will be stored in the <strong>res </strong>variable and the <strong>await </strong>command makes the code wait here for the response before continuing<strong>.</strong></p><pre>const data = await res.json();</pre><p>This line gets our JSON data from the body of the response object and stores it in a variable called <strong>data</strong> so we can use it.</p><pre>if (data.value !== &#39;undefined&#39;) this.error(res.status, data.message);</pre><p>This is a check to make sure our request was successful. If we didn’t get a “value” passed back in the response, then show the error page because something is wrong.</p><pre>if (data.value === null) data.value = 0;</pre><p>If we did get a value, but that value was “null” then make it zero.</p><p>Our contracting server is setup to return “null” for any value not found in state.</p><p>In this case <strong>null</strong> will be returned for any user that never had tokens. If they had tokens, but transferred them all away, then they would get a value of 0 returned instead of null.</p><pre>return { <strong>value</strong>: data.value, <strong>user</strong>: params.user };</pre><p>Now our module is going to return TWO things,</p><ul><li><strong>user</strong>: the username from the prefetch params object</li><li><strong>value</strong>: number of tokens returned from our API server.</li></ul><p>We can use this new <strong>value</strong> variable in our &lt;script&gt; tag by exporting it like we did with user. We can now use it to render the Token Balance on our webpage.</p><ul><li>Add the <strong>bold code </strong>below to your <strong>[user].svelte</strong> file.</li></ul><pre>&lt;!-- frontend/src/routes/users/[user].svelte --&gt;</pre><pre><strong>...</strong><br>&lt;/script&gt;<br><br>&lt;script&gt;<br>   export let user;<br>   <strong>export let <em>value</em>;</strong><br>&lt;/script&gt;<br><br><strong>&lt;style&gt;<br>   p{<br>      font-size: 1.2em;<br>   }<br>   .shadowbox{<br>      padding: 0.5rem 20px;<br>   }<br>&lt;/style&gt;</strong></pre><pre>&lt;svelte:head&gt;<br>   &lt;title&gt;{<em>user </em>+ &quot;&#39;s Tokens&quot;}&lt;/title&gt;<br>&lt;/svelte:head&gt;<br><br>&lt;h1&gt;{&quot;Hello &quot; + <em>user </em>+ &quot;!&quot;}&lt;/h1&gt;<br><strong>&lt;div class=&quot;shadowbox&quot;&gt;<br>   &lt;p&gt;&lt;strong&gt;Token Balance:&lt;/strong&gt; {<em>value</em>}&lt;/p&gt;<br>&lt;/div&gt;</strong></pre><pre><strong>...</strong></pre><p>Refresh the page and you should now be displaying token values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*usmUZWfWbdO-YllJyEk6AQ.png" /></figure><p>This tutorial has run longer than I expected and ended up being more of a webpage creation tutorial than I wanted to write.</p><p>I think it’s all good information and so instead of editing it down I’m going to make this a two-parter. Part B should be out tomorrow.</p><p><a href="https://github.com/JeffWScott/my_token_lamden_tutorial/tree/part_3a">You can check out the git repo for this part of the tutorial here.</a></p><h4><a href="https://blog.lamden.io/a-frontend-for-your-smart-contract-part-b-e28a11dbdd8e">&gt;&gt; PART 3b-A Frontend for your Smart Contract Cont.</a></h4><h3>Recap</h3><ul><li>Creating a website with Sapper and Svelte is easy</li><li>Displaying information from a smart contract via API is also easy!</li></ul><p>I’m available to chat on <a href="https://twitter.com/JeffWScott">twitter</a>, <a href="https://t.me/lamdenjeff">telegram</a> or <a href="https://www.linkedin.com/in/jeff-scott-69877978">linkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29381108a5d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lamden/a-frontend-for-your-smart-contract-29381108a5d5">A Frontend for your Smart Contract</a> was originally published in <a href="https://medium.com/lamden">Lamden</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>