<?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 MorrisLin on Medium]]></title>
        <description><![CDATA[Stories by MorrisLin on Medium]]></description>
        <link>https://medium.com/@morrislin1017?source=rss-9874dda4e451------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*K9JKqZgRCcJ_aTRxa9KUJQ.jpeg</url>
            <title>Stories by MorrisLin on Medium</title>
            <link>https://medium.com/@morrislin1017?source=rss-9874dda4e451------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 13:18:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@morrislin1017/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[Using Redis on Ubuntu with Python]]></title>
            <link>https://morrislin1017.medium.com/using-redis-on-ubuntu-with-python-b0ac2d075668?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0ac2d075668</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Wed, 07 Sep 2022 10:33:27 GMT</pubDate>
            <atom:updated>2022-09-07T10:33:27.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*auXv7ZEjAKcgxV6X.png" /></figure><p>最近在開發<a href="https://fastapi.tiangolo.com/">FastAPI</a>時有遇到邏輯上的問題，會有機會遇到重複呼叫的狀況，為了避免重複處理，一開始簡單的使用set儲存於記憶體中去辨識是否有重複情況，但後來為了提高RPS(Request per second)，使用了<a href="https://www.uvicorn.org/">Uvicorn</a>建立四個worker process，這時候出現問題了，由於一開始是設計儲存於記憶體中，但不同的worker無法分享到同一個記憶體位置，所以重複問題又開始發生了， 這時候基本上的解法有</p><ul><li>儲存於DB</li><li>儲存於Memory cache</li><li>儲存於Redis</li></ul><p>由於只是簡單的儲存重複ID而且遇到的情況都是1.2分鐘內出現，所以不需要儲存於DB而是需要可以快速存取並且有時效性的方式，經過考量後就決定使用Redis了，因Server是跑在Ubuntu上，所以分享的方式是以Ubuntu為主</p><ol><li>安裝Redis</li></ol><pre>sudo apt update<br>sudo apt install redis<br>redis-cli --version</pre><p>安裝過程中發生問題</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*znLqRb3OLpnw8BpTi1PG2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQrznNDzPYTD7wclRrTvIQ.png" /></figure><p>檢查了一下發現Server 的Ubuntu 版本是Ubuntu 21.10，在2022年七月已經EOL了(<a href="https://endoflife.software/operating-systems/linux/ubuntu">https://endoflife.software/operating-systems/linux/ubuntu</a>)</p><p>只好去修改/etc/apt/sources.list</p><pre>vim /etc/apt/sources.list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*dwQiU7lCsYVjSSL3Y_oI0Q.png" /></figure><p>將網址都改成old-releases再重新執行一次指令就可以順利安裝了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*sAZHrf2PI6AOlENmSfoyBQ.png" /></figure><p>2. 啟動Redis</p><pre>sudo systemctl start redis-server</pre><p>簡單測試一下可以成功存取Redis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*4HHflbiD5gZMf5fVmg2usw.png" /></figure><p>3. 安裝Python (已安裝的可略過)</p><p><a href="https://www.how2shout.com/linux/install-python-3-9-or-3-8-on-ubuntu-22-04-lts-jammy-jellyfish/">Install Python 3.9 or 3.8 on Ubuntu 22.04 LTS Jammy JellyFish</a></p><p>4. 安裝相依套件</p><pre>pip install aioredis<br>pip install asyncio</pre><p>5. 測試</p><p>新增一個python檔案</p><p>這隻程式主要是在測試連接Redis</p><p>檢查key test是否存在(存在回傳1, 不存在回傳0)</p><p>新增key: “test” , value: “this is a test”</p><p>設定過期時間為2秒</p><p>檢查Key: “test”是否存在</p><p>系統等候兩秒後再次檢查Key: “test”是否存在</p><pre><em>import</em> os</pre><pre><em>import</em> asyncio</pre><pre><em>import</em> aioredis</pre><pre><em>import</em> time</pre><pre>async def main():</pre><pre>redis = aioredis.from_url(https://medium.com/&quot;redis://localhost&quot;)</pre><pre>print(<em>await</em> redis.exists(&quot;test&quot;))</pre><pre>print(<em>await</em> redis.set(&quot;test&quot;, &quot;this is a test&quot;))</pre><pre>print(<em>await</em> redis.expire(&quot;test&quot;, 2))</pre><pre>print(<em>await</em> redis.exists(&quot;test&quot;))</pre><pre>time.sleep(2)</pre><pre>print(<em>await</em> redis.exists(&quot;test&quot;))</pre><pre><em>if</em> __name__ ==  &#39;__main__&#39;:</pre><pre>loop = asyncio.get_event_loop()</pre><pre>loop.run_until_complete(main())</pre><p>執性結果會是</p><pre>0 // 因Redis沒有 Key test<br>True // 成功新增Key test value this is a test<br>True // 成功設定過期時間<br>1 // Redis 有找到Key test<br>0 // Redis 沒有找到Key test 因為已過期</pre><p>以上就是簡單的安裝Redis 以及簡單的使用Python 做設定。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0ac2d075668" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[QuickNote: 快速切換Github帳號]]></title>
            <link>https://morrislin1017.medium.com/quicknote-%E5%BF%AB%E9%80%9F%E5%88%87%E6%8F%9Bgithub%E5%B8%B3%E8%99%9F-56e3c8c465ed?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/56e3c8c465ed</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[ssh-keys]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[multi-account]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 03:54:50 GMT</pubDate>
            <atom:updated>2022-08-29T03:54:50.705Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*unZuLfN2fKhEYLoi.png" /><figcaption><a href="https://www.linuxfordevices.com/tutorials/linux/connect-to-github-with-ssh">https://www.linuxfordevices.com/tutorials/linux/connect-to-github-with-ssh</a></figcaption></figure><p>本來只有一個Github帳號在使用，但最近新增了一個帳號，想要push repo到新帳號上發現無法切換，找了一下資料後將設定步驟給筆記下來。</p><p>首先要新增SSH key，新增文章可以參考<a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh">官方教學</a>，記得新增時不要使用預設名稱，不然會重複。</p><pre>Enter a file in which to save the key (/Users/<em>you</em>/.ssh/id_<em>algorithm</em>): [這邊輸入你取的帳號代號]</pre><pre>Enter a file in which to save the key (/Users/<em>you</em>/.ssh/id_<em>algorithm</em>): user1</pre><pre>Enter a file in which to save the key (/Users/<em>you</em>/.ssh/id_<em>algorithm</em>): user2</pre><p>然後編輯~/.ssh/config 沒有的話可以新增config</p><pre>touch ~/.ssh/config</pre><p>編輯~/.ssh/config</p><pre>Host github-user1<br>  HostName github.com<br>  AddKeysToAgent yes<br>  UseKeychain yes<br>  IdentityFile ~/.ssh/user1</pre><pre>Host github-user2<br>  HostName github.com<br>  AddKeysToAgent yes<br>  UseKeychain yes<br>  IdentityFile ~/.ssh/user2</pre><p>這樣設定就可以了，如果是新的repo要建立git remote的話</p><pre>git remote add origin git@github-user1:[personal_account_name/repo_name.git]</pre><pre>git remote add origin git@github-user2:[personal_account_name/repo_name.git]</pre><p>如果是clone repo 的話</p><pre>git clone git@github-user1:[personal_account_name/repo_name.git]</pre><pre>git clone git@github-user2:[personal_account_name/repo_name.git]</pre><p>這樣就可以快速分開帳號的去對不同帳號的repo操作了。</p><p>參考資料: <a href="https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/">https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56e3c8c465ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hugo 搭建筆記(二)]]></title>
            <link>https://morrislin1017.medium.com/hugo-%E6%90%AD%E5%BB%BA%E7%AD%86%E8%A8%98-%E4%BA%8C-e4986001d8b2?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4986001d8b2</guid>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[hugo]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 02:43:02 GMT</pubDate>
            <atom:updated>2022-08-29T02:43:02.662Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*SW97LzfKInv-CB_0IOlu3w.jpeg" /></figure><p>在上一篇的<strong><em>分享</em></strong>中，我們搭建好了Hugo，現在要讓它可以上傳到<a href="https://pages.github.com/">github pages</a>，讓大家可以看到你所搭建的網誌。</p><p>首先需要有<a href="https://github.com/">Github</a>帳號，然後建立新的repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*smDVPlLcO6lf95WHsMgfOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*ajIljCFNbC55jXkSAVvjQQ.png" /></figure><p>建立完後到自己的hugo目錄將專案建立remote 並push 上去</p><pre>git remote add origin [你的repo]<br>git branch -M main<br>git add .<br>git commit -m &quot;feat: add change&quot;<br>git push -u origin main</pre><p>成功後重新整理建立頁面就會出現專案</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*TlubVDK4ZNJ990-7-5JALw.png" /></figure><p>點擊右上角的setting &gt; pages &gt; 選取Branch &gt; 在點擊save</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*484OJjXVSVLcfDtlVFB7Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*RMK2ymAP8iiQd_MR6PnjSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*0sIs4P43w7551AFWDsmmXw.png" /></figure><p>在實作時遇到一個問題，在Actions的build中出現問題</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*VVC4I_4g8ll23iB8v8zTbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*AESw5nfNGn5HCoD1YOF6lg.png" /></figure><p>這邊可以看到是themes/LoveIt/exampleSite/content/posts/theme-documentation-content/index.en.md 這邊有錯誤導致build失敗。</p><p>根據問題來看是jekyll，但在build hugo是不需要jekyll的，所以我們要換另外一個方式使actions使用hugo 方式部署。</p><p>選擇Github Actions 會發現有出現Hugo的選項，點擊Configure後會產生一個yml，這個是Github Actions build Hugo的設定檔，commit後就會開始自動build，成功後會在Github Pages中看到網址。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*lmxVdLeT9esVzI8Us2ZV2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*z6PqGE0IVovppcd55j8h4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*xgzETObjwGGYrPmOTyIdqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*zAr_SOw34zlPdEBGScEQiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*WYUfpO7PoMXNqVHJpLNGBQ.png" /><figcaption><a href="https://uranuslin.github.io/hugo-demo/">https://uranuslin.github.io/hugo-demo/</a></figcaption></figure><p>這樣就完成我們的首次部署Hugo到Github pages了，之後只要新增文章後commit &gt; push origin main 就會自動部署更新網誌了。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4986001d8b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hugo 搭建筆記(ㄧ)]]></title>
            <link>https://morrislin1017.medium.com/hugo-%E6%90%AD%E5%BB%BA%E7%AD%86%E8%A8%98-%E3%84%A7-d3eba3c2c0a2?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3eba3c2c0a2</guid>
            <category><![CDATA[hugo]]></category>
            <category><![CDATA[markdown]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Thu, 25 Aug 2022 08:21:28 GMT</pubDate>
            <atom:updated>2022-08-25T08:21:28.977Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>最近比較有時間可以做一些有興趣的事情，就趁機記錄一下</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UhAkH2nW02-sRXqEyWCiXg.png" /></figure><p>以前在開始想要寫網誌時，有做了一些survey，像是<a href="https://medium.com/">Medium</a>、<a href="https://hashnode.com/">Hashnode</a>以及使用framework(<a href="https://gohugo.io/">Hugo</a>和<a href="https://hexo.io/zh-tw/">Hexo</a>)加上<a href="https://pages.github.com/">github pages </a>搭建的方式，後面因為很懶得寫MD跟使用很高級的語法來豐富網誌和建置管理，就一直使用Medium和Hashnode了，之前有試著部署Hexo到自己的github page，但沒有繼續的維護，最近想要玩一些東西，所需要的就是一個網誌網站，在Hugo和Hexo兩個中選擇，由於Hugo是由<a href="https://go.dev/">Golang</a>編寫的速度可以保證，就選擇使用Hugo搭建，以下是我個人所搭建的心得紀錄。</p><p>個人環境是使用MacOS</p><p>安裝Hugo</p><pre>brew install hugo</pre><p>建立網誌專案</p><pre>hugo new site demo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*gYtJWBTT3wjvaudyYpojnw.png" /></figure><p>在本機啟動</p><pre>hugo server -D</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8sMHex30Y4APDZWueN-KFA.png" /><figcaption>啟動後的畫面</figcaption></figure><p>可以看到啟動後空空如也，這時候可以去<a href="https://themes.gohugo.io/">Hugo Themes</a>選取喜歡的Theme，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H3LhtS9-0Y6807XjZOEHVg.png" /></figure><p>我自己是選擇<a href="https://themes.gohugo.io/themes/loveit/">LoveIt</a>，有不錯的文件說明還有中文註釋，對於想簡單架設的我來說很適合，作者提供了幾種做法可以安裝theme，</p><p>直接下載zip並在themes/ 資料夾中解壓縮</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJFx_gL96hHRxM3OAr7iPw.png" /></figure><p>或是使用</p><pre>git clone https://github.com/dillonzq/LoveIt.git themes/LoveIt</pre><p>我自己是因為要上傳到github pages所以使用</p><pre>git init<br>git submodule add https://github.com/dillonzq/LoveIt.git themes/LoveIt</pre><p>安裝好Theme後需要在config.toml中指定使用的theme是什麼</p><pre>baseURL = &#39;http://example.org/&#39;</pre><pre>languageCode = &#39;en-us&#39; </pre><pre>title = &#39;My New Hugo Site&#39; </pre><pre>theme = &#39;Loveit&#39;</pre><p>修改好後再重新啟動hugo就可以看到Theme已經好了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPVCnp5mGy15bGLMlFDi9Q.png" /></figure><p>再來就可以開始修改Theme把他改造成自己喜歡的模樣了!</p><p>專案目錄下的config.toml是全局的config，如果要修改局部的就要到themes/LoveIt/config.toml中修改，主要的設定說明config都有註解，我就提一些我自己有做的修改，首先是作者配置</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*WQM80NO9u452vLcrKEapLw.png" /></figure><p>再來是底部的文字，修改themes/LoveIt/config.toml</p><pre><em># Footer config</em></pre><pre><em># 页面底部信息配置</em></pre><pre>[params.footer]</pre><pre>enable = true</pre><pre><em># Custom content (HTML format is supported)</em></pre><pre><em># 自定义内容 (支持 HTML 格式)</em></pre><pre>custom = &quot;Powered by Demo&quot;</pre><pre><em># whether to show Hugo and theme info</em></pre><pre><em># 是否显示 Hugo 和主题信息</em></pre><pre>hugo = false</pre><pre><em># whether to show copyright info</em></pre><pre><em># 是否显示版权信息</em></pre><pre>copyright = true</pre><pre><em># whether to show the author</em></pre><pre><em># 是否显示作者</em></pre><pre>author = true</pre><pre><em># site creation time</em></pre><pre><em># 网站创立年份</em></pre><pre>since = 2022</pre><pre><em># ICP info only in China (HTML format is supported)</em></pre><pre><em># ICP 备案信息，仅在中国使用 (支持 HTML 格式)</em></pre><pre>icp = &quot;&quot;</pre><pre><em># license info (HTML format is supported)</em></pre><pre><em># 许可协议信息 (支持 HTML 格式)</em></pre><pre>license= &quot;&quot;</pre><p>儲存後就會看網站下方已經改變了</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMMDur-eDxnI6EIBlnn_XQ.png" /></figure><p>再來是更新網站title和中間的文字</p><p>全局config.toml</p><pre>title = &#39;This is demo site&#39;</pre><p>themes/LoveIt/config.toml</p><pre><em># Header config</em></pre><pre><em># 页面头部导航栏配置</em></pre><pre>[params.header]</pre><pre><em># title name</em></pre><pre><em># 标题名称</em></pre><pre>name = &quot;My demo site&quot;</pre><pre><em># Home page config</em></pre><pre><em># 主页信息设置</em></pre><pre>[params.home]</pre><pre><em># 主页显示的网站副标题 (允许 HTML 格式)</em></pre><pre>subtitle = &quot;This is my demo site&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mug_Jsxj0lbsHdmCV5eBEA.png" /></figure><p>再來就是如何設置menu，假設要設置三個目錄並支援中英文語系切換</p><p>全局config.toml</p><pre>[languages]</pre><pre>[languages.zh-tw]</pre><pre>weight = 1</pre><pre>title = &quot;展示&quot;</pre><pre>languageCode = &quot;zh-TW&quot;</pre><pre>languageName = &quot;繁體中文&quot;</pre><pre>hasCJKLanguage = true</pre><pre>[[languages.zh-tw.menu.main]]</pre><pre>weight = 1</pre><pre>identifier = &quot;demo1&quot;</pre><pre>pre = &quot;&quot;</pre><pre>post = &quot;&quot;</pre><pre>name = &quot;展示1&quot;</pre><pre>url = &quot;/demo1/&quot;</pre><pre>title = &quot;&quot;</pre><pre>[[languages.zh-tw.menu.main]]</pre><pre>weight = 2</pre><pre>identifier = &quot;demo2&quot;</pre><pre>pre = &quot;&quot;</pre><pre>post = &quot;&quot;</pre><pre>name = &quot;展示2&quot;</pre><pre>url = &quot;/demo2/&quot;</pre><pre>title = &quot;&quot;</pre><pre>[[languages.zh-tw.menu.main]]</pre><pre>weight = 3</pre><pre>identifier = &quot;demo3&quot;</pre><pre>pre = &quot;&quot;</pre><pre>post = &quot;&quot;</pre><pre>name = &quot;展示3&quot;</pre><pre>url = &quot;/demo3/&quot;</pre><pre>title = &quot;&quot;</pre><pre>[languages.en]</pre><pre>weight = 2</pre><pre>title = &quot;Demo&quot;</pre><pre>languageCode = &quot;en&quot;</pre><pre>languageName = &quot;English&quot;</pre><pre>[[languages.en.menu.main]]</pre><pre>weight = 1</pre><pre>identifier = &quot;demo1&quot;</pre><pre>pre = &quot;&quot;</pre><pre>post = &quot;&quot;</pre><pre>name = &quot;Demo1&quot;</pre><pre>url = &quot;/demo1/&quot;</pre><pre>title = &quot;&quot;</pre><pre>[[languages.en.menu.main]]</pre><pre>weight = 2</pre><pre>identifier = &quot;demo2&quot;</pre><pre>pre = &quot;&quot;</pre><pre>post = &quot;&quot;</pre><pre>name = &quot;Demo2&quot;</pre><pre>url = &quot;/demo2/&quot;</pre><pre>title = &quot;&quot;</pre><pre>[[languages.en.menu.main]]</pre><pre>weight = 3</pre><pre>identifier = &quot;demo3&quot;</pre><pre>pre = &quot;&quot;</pre><pre>post = &quot;&quot;</pre><pre>name = &quot;Demo3&quot;</pre><pre>url = &quot;/demo3/&quot;</pre><pre>title = &quot;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uLOQDcSdGKVZt2sfF3R-gQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*utpsSeIdKOi-aWXzIhzm3g.png" /></figure><p>簡單的設置一下就可以開始寫文章了，</p><p>新增文章可以使用hugo 指令也可以自己新增.md</p><p>由於我們有用雙語系，所以同一個文章要產生對應雙語言</p><pre>hugo new demo1/demo1.en.md<br>hugo new demo1/demo1.zh-tw.md<br>hugo new demo2/demo2.en.md<br>hugo new demo2/demo2.zh-tw.md<br>hugo new demo3/demo3.en.md<br>hugo new demo3/demo3.zh-tw.md</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlcABnl5AHbFqqL2cyooYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S8_pA6MMjZsoizni01b2og.png" /></figure><p>到這邊的分享就結束啦，至於Markdown編輯器的話，我自己本身是用IDEA IDE編輯，如果是免費的話推薦<a href="https://github.com/marktext/marktext">Marktext</a>。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4YR3BU1AO8WS-QxDUxi-iA.png" /></figure><p>下一篇會提到如何上傳並建立Gihub pages。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3eba3c2c0a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fix and Refactor Tor Bot repo]]></title>
            <link>https://morrislin1017.medium.com/fix-and-refactor-tor-bot-repo-57bd7d21d63c?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/57bd7d21d63c</guid>
            <category><![CDATA[tor]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 08:47:15 GMT</pubDate>
            <atom:updated>2022-08-23T08:47:15.387Z</atom:updated>
            <content:encoded><![CDATA[<p>Orig repo: <a href="https://github.com/jakedent/seo-bot">https://github.com/jakedent/seo-bot</a></p><p>My repo: <a href="https://github.com/UranusLin/seo-bot">https://github.com/UranusLin/seo-bot</a></p><p>最近需要一個機器人來做流量測試，找了一下github repo，找到了<a href="https://github.com/jakedent">Jacob</a>所寫的<a href="https://github.com/jakedent/seo-bot">seo-bot</a>，但實際運行起來是有問題的，畢竟是三年前的repo，於是就開始修復以及重新改造一下專案架構。</p><p>首先遇到的問題是無法開起Tor app，這邊檢查了一下發現是Tor 安裝的路徑改變了，所以很快的修正完成。</p><pre>原始程式<br>os.system(&#39;open /Applications/TorBrowser.app&#39;)</pre><pre>修改成<br>os.system(&#39;open /Applications/Tor\ Browser.app&#39;)</pre><p>再來是sock port 使用<strong><em>9051</em></strong>，在stem.control這邊會出現Connection refused</p><pre>with Controller.from_port(port=9051) as controller: <br>    controller.authenticate()    <br>    controller.signal(Signal.NEWNYM)           <br>    print(&quot;Identity Switched.&quot;)</pre><p>這邊是花滿多時間查資料的，最終在某個repo的issue裡有提到現在用的是<strong>9150/9151 </strong>這兩個port，其實一開始如果執行Tor時並輸入</p><pre>lsof -n -i | grep LISTEN</pre><p>就可以知道LISTEN的port 跟repo中的不一樣了，這也算是一種學習經驗。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*1ROOurK3rSRLbzF_Dl3-6Q.png" /></figure><p>到這邊就把整個流程給修復完成了，再來就是開始修改架構，我自己的習慣架構是</p><pre>main.py (程式執行進入點)<br>requirement.txt (相依套件文件)<br>service.py (服務流程)<br>utils.py (各個功能函式)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*K9RwqHVDns--8Z3rWjCSNA.png" /><figcaption>程式執行</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ni3t0P-oJqJtpikyvTmFjQ.png" /><figcaption>Tor</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*ux8WnB7_fXhXloJfh4_kmw.png" /></figure><p>原先的repo是直接啟動並無限循環，這邊加入了互動式操作，可以進行無限循環或者是次數循環，這是第一次使用別人的repo並且在之上做修改，也是我第一次在github上送出PR，對我來說是一個很好的經驗呢。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57bd7d21d63c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Note: CentOS install Docker and Docker Compose]]></title>
            <link>https://morrislin1017.medium.com/quick-note-centos-install-docker-and-docker-compose-9c47880883c6?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c47880883c6</guid>
            <category><![CDATA[centos]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 03:52:55 GMT</pubDate>
            <atom:updated>2022-06-16T03:52:55.570Z</atom:updated>
            <content:encoded><![CDATA[<p>Quick Note 系列為避免自己日後忘記所記錄的步驟</p><p>Install Docker</p><pre>sudo yum install -y yum-utils<br>sudo yum-config-manager \<br>      --add-repo \<br>       <a href="https://download.docker.com/linux/centos/docker-ce.repo">https://download.docker.com/linux/centos/docker-ce.repo</a></pre><pre>sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin 18</pre><pre>sudo systemctl start docker</pre><p>install docker-compose</p><pre>DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}</pre><pre>mkdir -p $DOCKER_CONFIG/cli-plugins</pre><pre>curl -SL https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose 4</pre><pre>chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose</pre><pre>sudo ln -s $DOCKER_CONFIG/cli-plugins/docker-compose /usr/bin/docker-compose 7</pre><pre>docker-compose version</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c47880883c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tron 如何發行TRC20代幣(Nile testnet)]]></title>
            <link>https://morrislin1017.medium.com/tron-%E5%A6%82%E4%BD%95%E7%99%BC%E8%A1%8Ctrc20%E4%BB%A3%E5%B9%A3-nile-testnet-15be70d7a07a?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/15be70d7a07a</guid>
            <category><![CDATA[tron]]></category>
            <category><![CDATA[trc20-token-generator]]></category>
            <category><![CDATA[trc20]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 01:59:09 GMT</pubDate>
            <atom:updated>2022-06-01T01:59:09.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*FWvBkwwYeKeS_3R_jsQlNA.png" /></figure><p>昨天在Shasta testnet上發行token遇到不知道怎麼解決的狀況(<a href="https://medium.com/@morrislin1017/tron-%E5%A6%82%E4%BD%95%E7%99%BC%E8%A1%8Ctrc20%E4%BB%A3%E5%B9%A3-1d5163c0ae88">文章點我</a>)，後來得知公司測試環境使用的是<a href="https://nile.tronscan.org/">Nile testnet</a>，同樣的步驟在<a href="https://nile.tronscan.org/">Nile testnet</a>成功部署，這邊紀錄一下跟Shasta testnet的差異。</p><ol><li>Faucet</li></ol><p>可以用昨天的方式Twitter @<a href="https://twitter.com/TronTest2">TronTest2</a> 並附上錢包地地址然後註記Nile，或者是可以到<a href="https://nileex.io/join/getJoinPage">這裡</a>，填上錢包地址就可以取得2000 TRX。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUEZbQYtLZfNiJlGaO6J0Q.png" /></figure><p>錢包記得切換網路到Nile Testnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*w8RiqIJyanbJMaC-QiioRw.png" /></figure><p>2. 照前一篇的做法步驟，到Deploy合約後，將部署成功的合約地址加入錢包</p><p>部署成功後的鏈上合約內容</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kapzkAr0Dtr6OzVkrlFjMw.png" /></figure><p>將合約地址加入到錢包中，選擇Custom Token加入地址</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*R_hNmeFp25FF1PEjQovumw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*zkqgN6i8WLbYfbAkb9dyKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*J81-bHHQ38tTvSSoQfN23Q.png" /></figure><p>因為我已加入過，第一次時下面會出現Token的內容按Next即可新增</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*GDMJ9LvC0F4sG6ulV7U2yg.png" /></figure><p>在錢包頁面上就能看到我們新增的Token了。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15be70d7a07a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tron 如何發行TRC20代幣]]></title>
            <link>https://morrislin1017.medium.com/tron-%E5%A6%82%E4%BD%95%E7%99%BC%E8%A1%8Ctrc20%E4%BB%A3%E5%B9%A3-1d5163c0ae88?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d5163c0ae88</guid>
            <category><![CDATA[tron]]></category>
            <category><![CDATA[trc20]]></category>
            <category><![CDATA[create-trc20-token]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Tue, 31 May 2022 10:21:55 GMT</pubDate>
            <atom:updated>2022-05-31T10:22:51.246Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tron 如何發行TRC20代幣(Shasta testnet)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*FWvBkwwYeKeS_3R_jsQlNA.png" /></figure><p>在區塊鏈交易所擔任區塊鏈工程師半年的我，之前listing新的token到測試環境時都只碰過<a href="https://ethereum.org/en/">Ethereum</a>和<a href="https://www.binance.org/en/smartChain">BSC</a>上的token，因為在做測試時我們都需要在<a href="https://academy.bit2me.com/en/que-es-testnet/">testnet</a>上創建一個名稱一樣的Token做驗證，在<a href="https://ethereum.org/en/">Ethereum</a>和<a href="https://www.binance.org/en/smartChain">BSC</a>上皆可使用<a href="https://remix.ethereum.org/">remix</a>來做建立，可以參考我上一篇文章<a href="https://morrislin1017.medium.com/bsc-testnet-create-new-token-eb8c739ef606?source=user_profile---------0----------------------------">BSC testnet create new token</a>，<a href="https://ethereum.org/en/">Ethereum</a>和<a href="https://www.binance.org/en/smartChain">BSC</a>操作方式一樣只是<a href="https://metamask.io/">MetaMask</a>選擇的區塊鏈網路不同。</p><p>這次需要做TRC20的token listing，部署的方式不同，所以順手紀錄一下以便日後忘記，之後還會發一篇<a href="https://solana.com/">Solana</a>的token創建文章。</p><ol><li>建立TRX錢包並創立帳號</li></ol><p>建議使用官方推薦的<a href="https://chrome.google.com/webstore/detail/tronlink%EF%BC%88%E6%B3%A2%E5%AE%9D%E9%92%B1%E5%8C%85%EF%BC%89/ibnejdfjmmkpcnlpebklmnkoeoihofec">TronLink</a>，使用Chrome安裝插件，建立帳號方式和<a href="https://metamask.io/">MetaMask</a>一樣，也可以使用<a href="https://metamask.io/">MetaMask</a>的註記詞匯入<a href="https://chrome.google.com/webstore/detail/tronlink%EF%BC%88%E6%B3%A2%E5%AE%9D%E9%92%B1%E5%8C%85%EF%BC%89/ibnejdfjmmkpcnlpebklmnkoeoihofec">TronLink</a>。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*AHyu65nL_gsFWhkiGGoZ5Q.png" /></figure><p>2. 取得TRX testnet faucet</p><p>剛建立好的錢包裡面是沒有任何token的，官方文件寫說發行token需要超過1000顆TRX，所以我們需要去取得TRX token，我們使用的Testnet是<a href="https://www.trongrid.io/shasta">Shasta</a> testnet，官網寫到需Twitter追蹤並發推文@帳號和自己的Address就可以拿到10,000顆TRX。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ob0jMbSFBTfg-dtYfEURmg.png" /></figure><p>像這樣推文，大概等20分鐘後就會收到TRX的Faecut。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8ss4eG6-5LVjUDkSH2QRg.png" /></figure><p>這邊可以看到交易內容。</p><p><a href="https://shasta.tronscan.org/#/transaction/9cd156a1612fc3af4844065f6893f8ac4d88ae430a393f639e2c4550b67b28f8">TRONSCAN | TRON BlockChain Explorer</a></p><p>3. 準備好Token智能合約</p><p>再來就到Tron developer hub的github中取得<a href="https://github.com/TRON-Developer-Hub/TRC20-Contract-Template/blob/main/Token.sol">合約範本</a> 需checkout<a href="https://github.com/TRON-Developer-Hub/TRC20-Contract-Template">所有檔案</a>，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_JOOTXp9m1IhUobtytacJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYbOgWKBvPFk2XAng9qqCQ.png" /><figcaption>需要所有檔案</figcaption></figure><p>主要修改Token.sol中的四個地方</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAHoqYxTCJXWSIdE73GoqA.png" /></figure><p>4. 上傳合約至<a href="https://www.trongrid.io/shasta">Shasta</a> testnet <a href="https://shasta.tronscan.org/?_ga=2.103571270.719793805.1653983755-1470584187.1653983755#/contracts/contract-compiler">Contract Deployment</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELHSgGksMTjE1_2U8AL8jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ylcB20Rfx_uQOWHSgDDXzA.png" /></figure><p>上傳後先選擇Compile成功後在Deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CpcFcL-HR6j-yLsu-oGzVw.png" /></figure><p>因為我們合約版本是solidity 0.5.0，我們就選擇0.5.10來做compile，出現下面Compiled success 就代表編譯成功了，再來就是選擇Deploy。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bSK4T3pzuZvKyrDfmJqf5Q.png" /></figure><p>Contract Name選擇我們剛剛改的Token.sol 所以是選擇Token剩下的不用修改直接按Confirm。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqWyw_UDhnelf2cmuZYdXQ.png" /></figure><p>出現簽署交易選擇Sign</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*xaP9N1KIq_TiPt-0tjuIug.png" /></figure><p>成功部署後會顯示<a href="https://shasta.tronscan.org/#/transaction/e85766a80c7cfbcfff313994f558c45a4bfc6a9ee56c76614067da6d1d266539">交易內容網址</a> 以及<a href="https://shasta.tronscan.org/#/contract/TVkrGZhGnaM8b9etMr1VksEbbJ25GbSq4G/code">合約地址</a>。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TbYtJIiuJEJNHcoCVY-hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYyDSBvIO6yTPBSNRPNySA.png" /><figcaption>鏈上交易明細</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IW7jHKcQNshQv2nh1-BU_A.png" /><figcaption>鍊上合約內容</figcaption></figure><p>5. Record TRC20 Token</p><p>到<a href="https://www.trongrid.io/shasta">Shasta</a> testnet 的錢包頁面</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*n2-EU1n6-LiUTOZRTKHiOA.png" /></figure><p>進入錢包頁面後選擇Record a Token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CK0A1TNvHqqbMrSJ1njyiw.png" /></figure><p>選擇Update Token Information</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJpmSX3x9eF4zGiXr-I2Pg.png" /></figure><p>填寫必填訊息(介紹、網站和信箱)因為是測試用網址我是填google，填完後點選Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dd5JhJiy4fCcmn9AcVk7Yg.png" /></figure><p>再點選Sumbit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVPUmKApjA2tL0eXhk32_w.png" /></figure><p>簽署交易</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OXZTnSFskIubASY_E4XVXA.png" /></figure><p>然後就出現失敗了，無法record a token，目前還未找到原因…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOqrOu4FQQbBUnFosZ10wQ.png" /></figure><p>實作到這邊的時候發現公司接的Testnet是<a href="https://nile.tronscan.org/?_ga=2.79852369.719793805.1653983755-1470584187.1653983755#/">Nile testnet</a>，在上面創建Token成功並加入到錢包，所以會再出一篇使用<a href="https://nile.tronscan.org/?_ga=2.79852369.719793805.1653983755-1470584187.1653983755#/">Nile testnet</a> 建立Token，但其中只會有如何faecut和創建成功後如何加入錢包。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d5163c0ae88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BSC testnet create new token]]></title>
            <link>https://morrislin1017.medium.com/bsc-testnet-create-new-token-eb8c739ef606?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb8c739ef606</guid>
            <category><![CDATA[new-tokens]]></category>
            <category><![CDATA[bsc-token]]></category>
            <category><![CDATA[bsc]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Mon, 21 Mar 2022 07:20:52 GMT</pubDate>
            <atom:updated>2022-03-21T07:20:52.920Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gdiMMp6MUVThR2_gh-4aJQ.png" /></figure><blockquote><em>虛擬貨幣交易所區塊鏈工程師的心得筆記</em></blockquote><p>在交易所工作的日常就是時常要上線新的Token或是新的公鏈平台幣， 今天主要的心得是如何在測試網路上發行新的Token。</p><blockquote><em>基本上應該沒有那種已上線的專案是沒有所謂的測試環境或是開發環境吧!?(沒有的話塊逃Ｒ</em></blockquote><p>區塊鏈都會有所謂的Mainnet和TestNet，至於要如何找到這些資訊呢，我的話會先找該鏈的區塊瀏覽網頁或是Scan，例如 <a href="https://bscscan.com/">bscscan</a>，通常在右上角會有顯示切換MainNet和TestNet的地方，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZB2OI55BYYgw6pwa" /></figure><p>在測試環境上要測試新上線的Token，這種時候我們就會去測試網路上部署一個同名的代幣合約，並將測試環境的合約地址設定成部署好的合約地址來做測試。</p><p>首先要準備的東西有：</p><p>首先在MetaMask 新增BSC測試網路，到 <a href="https://testnet.bscscan.com/">BSCscan testnet</a>中，移到下面有 add BSC Network 的狐狸icon按鈕，按下去就可以新增測試網路到Metamask中。</p><blockquote><em>因為BSC是Ethereum的側鏈，所以與Ethereum相容，所以部署Token的步驟與Ethereum一致。</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L3_2-0p1QP10uY6d" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*WeJCUR-kjcpijb5M" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*sfcO2Es5iDzMdlvh" /></figure><p>切換網路到BNB Smart Chain Testnet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*O8xrALqTZHl1yi2X" /></figure><p>再來因為在鏈上交易或是部署合約需要手續費，所以我們必須要去faucet取得BNB來讓我們可以在鏈上操作，首先到 <a href="https://testnet.binance.org/faucet-smart">Binance Smart Chain: Faucet</a>網頁，將MetaMask的Account 地址填入網址中，並點選Give me 1 BNB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*24DI7XDE4r9BsQXs" /></figure><p>大概幾秒後就可以看到自己的address中有1BNB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*CwruKO7nytnQjMY1" /></figure><p>再來我們就到 <a href="https://remix.ethereum.org/">remix</a>中去新增合約並部署， 新增一個.sol檔案</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CQnR5Zs71H7u7dt8" /></figure><p>複製 <a href="https://docs.openzeppelin.com/contracts/4.x/erc20">Token smart contract</a> 中的合約程式碼到新增的sol中並修改想要發行的Token名稱和Decimals小數點位數後 點選左邊第二個Icon並點擊Compile XXXXX.sol，確認可以編譯成功</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oAyhhfxKUEjnyS-k" /></figure><p>點選MetaMask 插件會顯示是否與Account連線，選擇連線後</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*Ch9qOVZ3dWKFqt5z" /></figure><p>點選左邊第三個圖示準備部署到測試網路上，選擇Injected Web3 確認你的Account 以及合約類型是ERC20以及選擇自己的.sol檔案確認完畢後就點選Deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4ywJ1SrEn2e4xagF" /></figure><p>點選後會出現交易確認畫面</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*6sYY0WkbdVavNQMG" /></figure><p>在交易紀錄這邊顯示部署已完成，點擊詳細交易可以看到該筆的 <a href="https://testnet.bscscan.com/tx/0x373e84fb1c9d0fa66ff117a81e21dc4a19a2a0a8a25efcf16d8c425bf6b108ab">transaction</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*5KsxR641nNVqXZT6" /></figure><p>複製部署後的合約地址到 <a href="https://testnet.bscscan.com/">BSC scan</a>中查詢，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cm2RlhGY-1R9pPoE" /></figure><p>可以看到合約部署成功，再來就是讓自己的MetaMask中可以看到部署後的Token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wm819UjrAjCO3OuA" /></figure><p>點擊Import Token，貼上剛剛的合約地址</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*wttjXxTsJB0E1tjz" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*42Ubi-e56--TY5J-" /></figure><p>確認後就可以看到自己錢包中剛剛新增的Token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*_g-SazAjItLpWq11" /></figure><p>這樣就完成了在測試網路上發行Token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*5--RyQhwrI0uJccI" /></figure><p><em>Originally published at </em><a href="https://morrislin.hashnode.dev/create-new-token-on-bsc"><em>https://morrislin.hashnode.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb8c739ef606" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dark Forest DAPP 遊玩體驗與充值]]></title>
            <link>https://morrislin1017.medium.com/dark-forest-dapp-%E9%81%8A%E7%8E%A9%E9%AB%94%E9%A9%97%E8%88%87%E5%85%85%E5%80%BC-add05af404f1?source=rss-9874dda4e451------2</link>
            <guid isPermaLink="false">https://medium.com/p/add05af404f1</guid>
            <category><![CDATA[dark-forest]]></category>
            <category><![CDATA[gnosis]]></category>
            <category><![CDATA[dai]]></category>
            <category><![CDATA[xdai]]></category>
            <category><![CDATA[bsc]]></category>
            <dc:creator><![CDATA[MorrisLin]]></dc:creator>
            <pubDate>Mon, 21 Feb 2022 06:47:24 GMT</pubDate>
            <atom:updated>2022-02-21T06:47:24.542Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>今年剛加入區塊鏈交易所的區塊鏈工程師日常</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQ74KmBxNhpuDoo-WILdzw.png" /></figure><p>原本在新加坡公司WFH工作的我，今年到了區塊鏈交易所公司上班，從原本上班時間5分鐘(起床刷牙坐到電腦前)到通勤時間50分鐘，我覺得是各有利弊，在通勤時多了許多與自己對話和學習的時間，通勤的50分鐘是我聽Podcast吸收資訓的時間，因為在區塊鏈交易所上班理所當然地聽了很多有關於區塊鏈的Podcast，其中一集聽到了有關於DAPP遊戲Dark Forest介紹</p><p><a href="https://podcasts.apple.com/tw/podcast/blockchain-software-engineering-daily/id1230807219?i=1000526331224">‎在 Apple Podcasts 上的《Blockchain - Software Engineering Daily》：Dark Forest: Transparency on Blockchains with Zero-Knowledge Proofs with Brian Gu</a></p><p>就對這遊戲充滿好奇，但遊玩這遊戲需要白名單邀請碼，雖然提交了申請但我也是等了一個月才拿到邀請碼，基本的遊戲遊玩可以參考</p><p><a href="https://www.dappchaser.com/dark-forest-guide1/">Dark Forest 完全攻略（入门篇）</a></p><p>一開始沒有注意到信中所寫免費100次移動，導致我玩到一半才發現怎麼每次移動都顯示</p><pre>move transaction () reverted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8bR63LDnNTZILE-cjwEKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gIFKU0wReqMWS12TIE9I5Q.png" /></figure><p>由於Dark Forest是部署在<a href="https://gnosis.io/">Gnosis Chain</a>上的DAPP遊戲，使用的是xDAI Token作為gas fee，所以在我免費移動次數用完後，需要的就是想辦法將台幣轉換為xDAI token。</p><p>再來的一步就是需要申請MetaMask錢包(網路上有很多教學就不說明了)，然後使用跨鏈交易服務將DAI token轉成xDAI token，目前主要的途徑是使用Bridge跨鏈的服務商，一開始先嘗試看看官方介紹的<a href="https://bridge.xdaichain.com/">xDai Bridge</a> 嘗試將DAI token swap 成xDAI，但是他是使用ETH chain做交易，交易一次的手續費需要400多台幣…實在是太貴了，後來使用官方介紹的第二個Bridge <a href="https://omni.xdaichain.com/bridge">OmniBridge</a>，選擇使用<a href="https://docs.binance.org/smart-chain/guides/bsc-intro.html">BSC鏈</a>做交易，但選擇BSC — GC時出現了</p><pre>Bridging of Binance-Peg DAI tokens to the Gnosis Chain is disabled, please use <a href="https://xpollinate.io/">Xpollinate</a> bridge by Connext instead.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xTwmKqwwRn4w-W-cawXVkQ.png" /></figure><p>無法用BSC服務只好使用上面介紹的另外一個跨鏈應用<a href="http://xpollinate.io/">xpollinate.io</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ADaHJASPfop41MVAHOd6A.png" /></figure><p>連結錢包後終於可以將BSC上的DAI token轉成GNO上的xDAI，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a5bpmsYwPqH0vzi-FXQ0qw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PMbVFMS4I-rBQbPvJbt8QA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GaBziqopaxeSor6iQsXe4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vNSzu-zhv-4JAK2Dtstrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cFVp29DLcIfmpk4lXPCzcA.png" /></figure><p>xDAI終於充值完成了，可以繼續探索Dark Forest的世界了。</p><p>實際上第一次做跨鏈交易甚至是MetaMask錢包交易的我來說，也是撞了很多坑，上面的是最終的成果，中間遭遇到很多事後想起來很蠢的事情，自己真正的流程是</p><ol><li>申請MetaMask 錢包</li><li>加入BSC 網路與加入DAI token</li><li>加入Gonsis網路與加入xDAI token</li><li>在有錢的交易所上購買DAI(我是用ByBit)</li><li>從ByBit的帳戶錢包withdraw DIA 到MetaMask上的BSC DAI</li><li>因為<a href="http://xpollinate.io/">xpollinate.io</a>轉帳fee需要BNB，所以在幣安上買了BNB在Withdraw到MetaMask上的BSC BNB</li><li>最後轉帳完成後在從MetaMask上的xDAI 發送到Dark Forest中的錢包地址</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*lt71_5Q9oU65NZxEfYhweQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=add05af404f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>