<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>scientist</title>
        <link>https://paragraph.com/@scientist</link>
        <description>undefined</description>
        <lastBuildDate>Thu, 09 Apr 2026 11:51:33 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[the Future of Crypto - Multi-chain Interoperability is the Key]]></title>
            <link>https://paragraph.com/@scientist/the-future-of-crypto-multi-chain-interoperability-is-the-key</link>
            <guid>xsD2ZX5FZV9S91JA6C8S</guid>
            <pubDate>Thu, 19 May 2022 02:53:58 GMT</pubDate>
            <description><![CDATA[With the crypto world ever expanding, it’s natural to wonder where the future of crypto is. Well, here it goes—LI.FI, a multi-chain aggregator. As we all know, currently many EVM chains are competing with each other, each having different features. In order to access the unique DeFi protocols only deployed on several chains, people need to transfer their assets from one chain to another frequently. It was based on this fact that Vitalik Buterlin said in the year 2016 that the future would be ...]]></description>
            <content:encoded><![CDATA[<p>With the crypto world ever expanding, it’s natural to wonder where the future of crypto is. Well, here it goes—LI.FI, a multi-chain aggregator.</p><br><p>As we all know, currently many EVM chains are competing with each other, each having different features. In order to access the unique DeFi protocols only deployed on several chains, people need to transfer their assets from one chain to another frequently. </p><br><p>It was based on this fact that Vitalik Buterlin said in the year 2016 that the future would be multi-chain. (Check his full argument here: <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/VitalikButerin/status/1479501366192132099">https://twitter.com/VitalikButerin/status/1479501366192132099</a>)</p><br><p>He believed that the future of crypto would be driven by the chain interoperability. According to him, we can go far beyond the approach most common in centralized systems of simply having an API from one chain to another, and in some cases even go so far as to have smart contract code on one chain to verify the consensus finality of events on other chains directly, requiring no trust in intermediaries at all (<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.r3.com/wp-content/uploads/2017/06/chain_interoperability_r3.pdf">https://www.r3.com/wp-content/uploads/2017/06/chain_interoperability_r3.pdf</a>).</p><br><p>That vision has become a reality today. A multi-chain aggregator called @lifiprotocol has cooperated with @etherspot, a multi-chain SDK provider. They simplified the process of cross-chain swaps. In the past, users had to change RPC frequently to match the network they wanted to interact with; but now, they can swap their assets between chains without changing RPC credit to Etherspot’s SDK.</p><br><p>This breakthrough creates massive value for users. I used to spend hours transferring assets from Gnosis chain to another chain in order to interact with dApps, which was unbearably boring and mistakes were common. However, the update of LI.FI handles this problem beautifully. For instance, @KlimaDAO is a protocol native to @0xPolygon, and users need to buy $KLIMA token to stake it in the vault to join the green revolution. What’s exciting now is that, what used to take users 9 interactions now becomes just 4, thanks to the updated version of LI.FI. Suffice it to say, the cross-chain swap makes a greener world.</p><br><p>In fact, the tech works in 4 steps.</p><p>1.Etherspot creates a smart contract wallet for the user on Polygon</p><p>2.The User sends their funds to this smart contract wallet</p><p>3.The User signs a message to swap to USDC and bridge using LI.FI</p><p>4.After bridging, the user again signs a message which swaps to Klima and stakes in a single batched transaction.</p><br><p>Moreover, with LI.FI and Etherspot’s joint SDK, we can donate for Ukraine more easily. The whole cross-chain swap notion makes users feel like we are using a single blockchain. The protocol will swap the token on other chains to ETH on the Ethereum chain to donate for Ukraine government. And this technology can be expanded to any-to-any cross chain swaps. The swap and bridge processes are arranged automatically.</p><br><p>The benefits of interop between chains are obvious. As Vitalik shows in his thesis, Interoperable chains open up a world where it is easy to move assets from one platform to another, to conduct payment-versus-payment and payment-versus-delivery schemes, and to access information from one chain inside another. These can even be implemented by third parties without any additional effort from the operators of the base blockchain protocols. We can imagine that the cooperation between LI.FI and Etherspot will bring the interop future to us. Here are some of its uses:</p><br><p>1.Yield aggregators can build cross-chain strategies</p><p>2.NFT Marketplaces can go cross-chain</p><p>3.Any protocol with pools/vaults can attract liquidity from any chain seamlessly.</p><br><p>In conclusion, I believe that LI.FI is a professional multi-chain swap&amp;bridge aggregator which has incredible interoperability. LI.FI will play an important role in the multi-chain future to come.</p><br><br><br>]]></content:encoded>
            <author>scientist@newsletter.paragraph.com (scientist)</author>
        </item>
        <item>
            <title><![CDATA[discord 自动抽奖机器人(单机稳定版) 部署教学]]></title>
            <link>https://paragraph.com/@scientist/discord-3</link>
            <guid>DdQKHNlTOpb0sGVZOdTk</guid>
            <pubDate>Thu, 10 Feb 2022 05:04:17 GMT</pubDate>
            <description><![CDATA[首先感谢各位朋友对于 discord 自动抽奖机器人 的热烈回响，本篇会教学如何在家部署 discord 自动抽奖机器人单机稳定版 ( 不透过 Google Colab 执行)，顺便回复各位常遇到的问题**。**部署单机版的好处是会让服务更稳定，不会因閒置太久被 Google 中断连线。回到正题，第一个问题是为什麽 discord 抽奖机器人执行好好的要改用单机版呢？原因是上篇所使用的 Google Colab 毕竟也是 Google 的免费版产品，若闲置太久 Google 会无预警中断连线以节省他们的运算资源，所以如不希望被 Google 中断连线，第一个最暴力的做法当然就是乖乖付费囉。( 月付 $49.99 美金的方案甚至还提供背景执行) 换句话说，也顺便回应部分狗友问题: Q: 若程式执行中关闭浏览器分页会继续抽奖吗 ? A: 要希望关闭浏览器分页还能在 Google Colab 上运行的话，只能选择 Golab Pro+ 付费版囉然而本篇存在的目的当然就是要帮大家省钱拉，若家中有桌机平时都没在关机的朋友们就非常适合使用，服务稳定又免费。Step1. 先安裝 Anacond...]]></description>
            <content:encoded><![CDATA[<figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/be1597bdfd33b7e4e96c9e9d7873ff72785b4b2e6b183f6afb32dac5def31402.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>首先感谢各位朋友对于 discord 自动抽奖机器人 的热烈回响，本篇会教学如何在家部署 discord 自动抽奖机器人单机稳定版 ( 不透过 Google Colab 执行)，顺便回复各位常遇到的问题**。**</p><h2 id="h-google" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">部署单机版的好处是会让服务更稳定，不会因閒置太久被 Google 中断连线。</h2><p>回到正题，第一个问题是为什麽 discord 抽奖机器人执行好好的要改用单机版呢？原因是<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/@metasimon/discord-%E8%87%AA%E5%8B%95%E6%8A%BD%E7%8D%8E%E6%A9%9F%E5%99%A8%E4%BA%BA-giveaways-30ddac17c86">上篇所使用的</a> Google Colab 毕竟也是 Google 的免费版产品，若闲置太久 Google 会无预警中断连线以节省他们的运算资源，所以如不希望被 Google 中断连线，第一个最暴力的做法当然就是乖乖付费囉。( 月付 $49.99 美金的方案甚至还提供背景执行)</p><p>换句话说，也顺便回应部分狗友问题:</p><p>Q: 若程式执行中关闭浏览器分页会继续抽奖吗 ?</p><p>A: 要希望关闭浏览器分页还能在 Google Colab 上运行的话，只能选择 Golab Pro+ 付费版囉</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0c52fecdec965676f317fcff84cc9dbd4595d6963c24f75dd14d1a82aac51f35.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><blockquote><p>然而本篇存在的目的当然就是要帮大家省钱拉，若家中有桌机平时都没在关机的朋友们就非常适合使用，服务稳定又免费。</p></blockquote><h2 id="h-step1-anaconda" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Step1. 先安裝 Anaconda</h2><p>( 如已安装者请跳至 Step2 )</p><blockquote><p>**Anaconda 是什么 **: 一个开源的Python和R语言的发行版本，用于计算科学，Anaconda致力于简化软件套件管理系统和部署。 ( — from wiki )**Anaconda 下载连结 : **<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.anaconda.com">https://www.anaconda.com</a> → Get Started → 第四个 Download Anaconda installers</p></blockquote><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4dde812ac26f788a8c14c7d1fa49408fd891f8a0d64898500ea430c08bb47c26.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/23c6724e0c2a9834e21b210761f962ac29320361ca3665c05a9a0033b187ce0c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>安装步骤可参考下方影片</p><div data-type="youtube" videoId="n83J8cBytus">
      <div class="youtube-player" data-id="n83J8cBytus" style="background-image: url('https://i.ytimg.com/vi/n83J8cBytus/hqdefault.jpg'); background-size: cover; background-position: center">
        <a href="https://www.youtube.com/watch?v=n83J8cBytus">
          <img src="{{DOMAIN}}/editor/youtube/play.png" class="play"/>
        </a>
      </div></div><h2 id="h-step-2-anaconda-navigator" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Step 2. 安装完毕后 → 工具列搜寻 Anaconda Navigator → 执行</h2><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2ddf97750a5a26e4efea4530ed5b59c950f0034d38d3f7f68c3127a22b29f091.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-step-3-jupyter-notebook" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Step 3. 启动Jupyter Notebook</h2><blockquote><p>**Jupyter Notebook 是什么：**一个可提供网页形式编写 python 程式，且程式编写完可直接于网页上执行并显示结果的工具，相当方便新手入门 python程式语言。</p></blockquote><p>进入 Anaconda Navigator → launch <strong>Jupyter Notebook</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e90a86d772834ba672ecec14789230b18710066f497e2861de6026c6343f98fb.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>点入后会询问是否开启网页，选择任一浏览器开启，看到这画面就成功了</p><h2 id="h-step-4-and" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Step 4. 新增程式码 &amp; 执行</h2><p>a. New 新档案 → 选择 Python 3</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c214b0f76d7bafed7acced8c032491e64e021934ceb9c5f68302cb2b109549ca.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>b. 将我们在<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/@metasimon/discord-%E8%87%AA%E5%8B%95%E6%8A%BD%E7%8D%8E%E6%A9%9F%E5%99%A8%E4%BA%BA-giveaways-30ddac17c86">前一篇文章</a>内的程式码贴过来，执行 (Run)，就恭喜大功告成了！</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1d7e85f227365487e3679cef308be6d6fcddb2f8a385b2d975ae50735fd406a2.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>另外回应大家有问过的一些问题</p><p>Q: 有发现当同一抽奖频道若同时发布两个抽奖活动时，机器人只会点到最后一个，第一个会漏掉</p><p>A: 由于 Google Colab 是架在 Google Cloud Platform 上，一般会有 rate limit 的限制 ( 限制短时间发送大量 http request ) ← 感谢狗友 BitV 解答 。有个解法是在此处加上* time.sleep(1) *，让程式按完一个表情符号后停顿一秒再按下一个，可以解决这个问题。 ( 我已在程式码加上这段，若是在我更新之前已建立副本的朋友可能再检查一下 )</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5593376f2dfec05832c8e919095fb8c7072b143c513a51460f4a4dac1ace2b22.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>Q: 请问可以监听一个以上的群组吗</p><p>A: 可以，目前架构下只要在输入 channel_list 的位置，如下方格式新增即可</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/84fa6cee4e750f05eb7186f5da70b4680c1691635c55da7898cd39aa4df44d13.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>Q: 同上，若要参加多个抽奖的群组，内容关键字不一样的话，或是参加抽奖需要按的表情符号不同，该如何设定？</p><p>A: 以上功能已与狗友在规划中，会将目前程式码重新整理，到时会拆出设定档给大家方便使用，敬请期待</p><h2 id="h-tips" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">一些 Tips :</h2><h2 id="h-1" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">1. 慎选关键字</h2><p>一般抽奖频道可能会同时有已经抽奖完成的活动及正在抽奖的如下图，若以下图为例 我会建议要监听抽奖中活动的关键字就设定 “<strong>GIVEAWAY</strong>” 而不要设定 “GIVEAWAY”</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/615a74f95141e75ee53076734de39af8e284ac6c0d283ed48d76ad65ff165c91.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>原因是抽奖机器人预设是设定抓最近10笔的讯息查内文是否包含关键字，若单纯输入 GIVEAWAY 会让机器人一併搜寻到 GIVEAWAY ENDED，下方的触发纪录就会很长不便阅读。</p><blockquote><p>PS. GIVEAWAY 前后的星星在 discord 是显示粗体的意思，若关键字设定为 <strong>GIVEAWAY</strong> ，则上方的 <strong>GIVEAWAY ENDED</strong> 因为不满足字串所以就不会被搜寻到，机器人下方画面会干净很多</p></blockquote><h2 id="h-2-10-10-url" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">2. 同上，抽奖机器人比对关键字预设是抓近 10 笔，若觉得 10 笔不够可在 url 这个位置自行修改</h2><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2f59d6ea940e364d2d5b8ad4ddb6511ccf49ff5f6e5504a4620e19d90f3d7ca1.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-3-discord-authorization" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">3.** 务必保管好自己 discord 的 authorization**</h2><p>想像各位的机器人，光拥有 authorization id 就能做以上这麽多事情了，虽然这个 authorization id 理论上会有时效性，时间到会过期，但安全起见，请千万保管好自己 discord 的 authorization id ，不要外流或是不小心 po 到 github 之类的开源平台</p><blockquote><p>Discord authorization id 跟助记词一样重要，千万别分享给别人 !</p></blockquote>]]></content:encoded>
            <author>scientist@newsletter.paragraph.com (scientist)</author>
        </item>
        <item>
            <title><![CDATA[[零基础上手] Discord 自动参加抽奖机器人(云端稳定版)]]></title>
            <link>https://paragraph.com/@scientist/discord-2</link>
            <guid>og6zqX3L4LfX6kHLZI5W</guid>
            <pubDate>Wed, 09 Feb 2022 04:10:44 GMT</pubDate>
            <description><![CDATA[本篇教学会带大家部署一个自动参加Discord 抽奖机器人，会使用云端主机Google Cloud Function，好处是不会面临电脑关机时机器人就休息的情况，然后Google 也有提供一定使用额度内免费，所以基本上是完全零成本免费部署，让大家都可以解放双手和注意力，不会再错过任何Discord 的抽奖项目！ 会有这篇文章的诞生，主要感谢Fomo dog 社群中的meta Simon 和saibalmars 狗友们，不断地改进和修正程式码(如下连结)，才会有今天的Discord 抽奖机器人(云端稳定版本)1. 申请Google Cloud Platform首先我们要申请Google Cloud Platform 的帐号，可以从这里进入，Google 目前有提供3 个月内300 美金的额度使用，而我们这次会使用GCP 里面的Google Cloud Function，以这次部署的程式的每用使用量来说，每月的花费在0 块台币以内。接下来建立第一个专案，专案名称可以依自己喜好命名2. 创建Cloud Function接下来在搜寻栏中搜寻“Cloud Function”，并且选择建立函...]]></description>
            <content:encoded><![CDATA[<p>本篇教学会带大家部署一个自动参加Discord 抽奖机器人，会使用云端主机Google Cloud Function，好处是不会面临电脑关机时机器人就休息的情况，然后Google 也有提供一定使用额度内免费，所以基本上是完全零成本免费部署，让大家都可以解放双手和注意力，不会再错过任何Discord 的抽奖项目！</p><p>会有这篇文章的诞生，主要感谢Fomo dog 社群中的meta Simon 和saibalmars 狗友们，不断地改进和修正程式码(如下连结)，才会有今天的Discord 抽奖机器人(云端稳定版本)</p><h2 id="h-1-google-cloud-platform" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">1. 申请Google Cloud Platform</h2><p>首先我们要申请Google Cloud Platform 的帐号，可以从这里<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://console.cloud.google.com/getting-started">进入</a>，Google 目前有提供3 个月内300 美金的额度使用，而我们这次会使用GCP 里面的Google Cloud Function，以这次部署的程式的每用使用量来说，每月的花费在0 块台币以内。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a1eae51de722fac9d6447b4d4261e26cd84cad466ad7d7b1780185c11ca92758.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>接下来建立第一个专案，专案名称可以依自己喜好命名</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7a296cf7093caa636104f6a138bd11ac34d2f39287a06adc4e95fb416c40c8f8.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-2-cloud-function" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">2. 创建Cloud Function</h2><p>接下来在搜寻栏中搜寻“Cloud Function”，并且选择建立函式</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/193b9ff1f21c6ca074a7b093ff6cbebd2d0ef37b1cba215d7200ee24cfbe4969.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>创建Cloud Function – Step 1</p><ol><li><p>函式名称：可以自由填写</p></li><li><p>选择区域：可以挑选自己喜欢的主机所在地，这边选择asia-east1 台湾</p></li><li><p>触发条件：选择Cloud Pub / Sub</p></li><li><p>建立一个Pub / Sun 主题&gt; 输入主题ID (可随意填) &gt; 选择建立主题</p></li><li><p>选择储存</p></li><li><p>并点选下一步</p></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c40078daf1d0d7afdd344b1561eacfd5cf6e4bb04e9e1ba7842303750639f50c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>创建Cloud Function – Step 2</p><ol><li><p>选择启用API</p></li><li><p>选择执行阶段Python 3.9</p></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/02dc3a7cf2419376a73da427c91e5dda3caf4e2f154ab61da0c66024105fc9f4.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>创建Cloud Function – Step 3</p><ol><li><p>选择main.py</p></li><li><p>输入进入点：getlist</p></li><li><p>输入我们的抽奖机器人程式码</p></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/eb04f1971359cd4c6b3d57b9ceadb1bb9539143d2811293e691c4cb072c46385.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>步骤3 里面的完整程式码如下： (请在bots_setting 中加入自己想要追踪的抽奖频道，关于参数设定可以参考Simon 的<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/@metasimon/discord-%E6%8A%BD%E7%8D%8E%E6%A9%9F%E5%99%A8%E4%BA%BA%E9%80%B2%E9%9A%8E%E7%89%88-%E6%94%AF%E6%8F%B4%E5%B8%B3%E8%99%9F%E5%A4%9A%E9%96%8B-%E5%A4%9A%E9%A0%BB%E9%81%93-%E5%A4%9A%E9%97%9C%E9%8D%B5%E5%AD%97%E9%83%A8%E4%BD%8D%E5%81%B5%E6%B8%AC-9950914a2784">这篇</a>)</p><pre data-type="codeBlock" text="import requests
import json
import random
import time
from datetime import datetime

def getlist(event, context):

    # You can add more than one bot if you have multiple discord accounts.
    bots_setting = [
        {
            &quot;name&quot;: &quot;bot1&quot;,
            &quot;authorizations&quot;: [
                    &quot;xxxxxxx.xxxxxxx&quot;,
                ],  # Please remember to put in your discord message authorization code
                    # spearate by comma if you have more than one token.
            &quot;channel_lists&quot;: [
                {
                    &quot;name&quot;: &quot;Alpha Shark&quot;,  # Nickname for the channel
                    &quot;settings&quot;: {
                        &quot;channel_id&quot;: &quot;927557825486536764&quot;,     # Channel&apos;s discord ID
                        &quot;lottery_keyword&quot;: &quot;React with \\ud83c\\udf89 to enter!&quot;,      # Lottery keyword to detect:  &quot;React with 🎉 to enter!&quot;
                        &quot;emojis_to_click&quot;: [&quot;%F0%9F%8E%89&quot;]     # emoji to click
                    }
                }
            ]
        }
    ]

    limit=10
    
    for bot in bots_setting:
        for auth in bot[&quot;authorizations&quot;]:
            header = {
                &quot;Authorization&quot;: auth,
                &quot;Content-Type&quot;: &quot;application/json&quot;,
                &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36&quot;,
            }
            for channel in bot[&quot;channel_lists&quot;]:
                url = &quot;https://discord.com/api/v9/channels/{}/messages?limit={}&quot;.format(channel[&quot;settings&quot;][&quot;channel_id&quot;], limit)
                try:
                    res = requests.get(url=url, headers=header)
                    messages_json = json.loads(res.text)
                    for message in messages_json:
                        try:
                            if channel[&quot;settings&quot;][&quot;lottery_keyword&quot;] in json.dumps(message):
                                is_lottery_post = True
                            else:
                                is_lottery_post = False

                            if is_lottery_post:
                                print(&quot;-------------Lottery captured!--------------&quot;)
                                print(&quot;Date:&quot;, datetime.now())
                                print(&quot;Channel:&quot;, channel[&quot;name&quot;])
                                print(&quot;Message ID:&quot;, message[&quot;id&quot;])
                                print(&quot;Content:&quot;, message[&quot;content&quot;])
                                print(&quot;embeds:&quot;, message[&quot;embeds&quot;])
                                for emoji in channel[&quot;settings&quot;][&quot;emojis_to_click&quot;]:
                                    url = &quot;https://discord.com/api/v9/channels/{}/messages/{}/reactions/{}/%40me&quot;.format(
                                        channel[&quot;settings&quot;][&quot;channel_id&quot;], message[&quot;id&quot;], emoji)
                                    requests.put(url=url, headers=header)
                                    time.sleep(1)

                        except:
                            print(&quot;Failed to expand messages.&quot;)
                            pass
                except:
                    print(&quot;Failed to get discord message.&quot;)
                    pass
"><code><span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">import</span> time
<span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> datetime

<span class="hljs-keyword">def</span> <span class="hljs-title function_">getlist</span>(<span class="hljs-params">event, context</span>):

    <span class="hljs-comment"># You can add more than one bot if you have multiple discord accounts.</span>
    bots_setting = [
        {
            <span class="hljs-string">"name"</span>: <span class="hljs-string">"bot1"</span>,
            <span class="hljs-string">"authorizations"</span>: [
                    <span class="hljs-string">"xxxxxxx.xxxxxxx"</span>,
                ],  <span class="hljs-comment"># Please remember to put in your discord message authorization code</span>
                    <span class="hljs-comment"># spearate by comma if you have more than one token.</span>
            <span class="hljs-string">"channel_lists"</span>: [
                {
                    <span class="hljs-string">"name"</span>: <span class="hljs-string">"Alpha Shark"</span>,  <span class="hljs-comment"># Nickname for the channel</span>
                    <span class="hljs-string">"settings"</span>: {
                        <span class="hljs-string">"channel_id"</span>: <span class="hljs-string">"927557825486536764"</span>,     <span class="hljs-comment"># Channel's discord ID</span>
                        <span class="hljs-string">"lottery_keyword"</span>: <span class="hljs-string">"React with \\ud83c\\udf89 to enter!"</span>,      <span class="hljs-comment"># Lottery keyword to detect:  "React with 🎉 to enter!"</span>
                        <span class="hljs-string">"emojis_to_click"</span>: [<span class="hljs-string">"%F0%9F%8E%89"</span>]     <span class="hljs-comment"># emoji to click</span>
                    }
                }
            ]
        }
    ]

    limit=<span class="hljs-number">10</span>
    
    <span class="hljs-keyword">for</span> bot <span class="hljs-keyword">in</span> bots_setting:
        <span class="hljs-keyword">for</span> auth <span class="hljs-keyword">in</span> bot[<span class="hljs-string">"authorizations"</span>]:
            header = {
                <span class="hljs-string">"Authorization"</span>: auth,
                <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"application/json"</span>,
                <span class="hljs-string">"User-Agent"</span>: <span class="hljs-string">"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36"</span>,
            }
            <span class="hljs-keyword">for</span> channel <span class="hljs-keyword">in</span> bot[<span class="hljs-string">"channel_lists"</span>]:
                url = <span class="hljs-string">"https://discord.com/api/v9/channels/{}/messages?limit={}"</span>.<span class="hljs-built_in">format</span>(channel[<span class="hljs-string">"settings"</span>][<span class="hljs-string">"channel_id"</span>], limit)
                <span class="hljs-keyword">try</span>:
                    res = requests.get(url=url, headers=header)
                    messages_json = json.loads(res.text)
                    <span class="hljs-keyword">for</span> message <span class="hljs-keyword">in</span> messages_json:
                        <span class="hljs-keyword">try</span>:
                            <span class="hljs-keyword">if</span> channel[<span class="hljs-string">"settings"</span>][<span class="hljs-string">"lottery_keyword"</span>] <span class="hljs-keyword">in</span> json.dumps(message):
                                is_lottery_post = <span class="hljs-literal">True</span>
                            <span class="hljs-keyword">else</span>:
                                is_lottery_post = <span class="hljs-literal">False</span>

                            <span class="hljs-keyword">if</span> is_lottery_post:
                                <span class="hljs-built_in">print</span>(<span class="hljs-string">"-------------Lottery captured!--------------"</span>)
                                <span class="hljs-built_in">print</span>(<span class="hljs-string">"Date:"</span>, datetime.now())
                                <span class="hljs-built_in">print</span>(<span class="hljs-string">"Channel:"</span>, channel[<span class="hljs-string">"name"</span>])
                                <span class="hljs-built_in">print</span>(<span class="hljs-string">"Message ID:"</span>, message[<span class="hljs-string">"id"</span>])
                                <span class="hljs-built_in">print</span>(<span class="hljs-string">"Content:"</span>, message[<span class="hljs-string">"content"</span>])
                                <span class="hljs-built_in">print</span>(<span class="hljs-string">"embeds:"</span>, message[<span class="hljs-string">"embeds"</span>])
                                <span class="hljs-keyword">for</span> emoji <span class="hljs-keyword">in</span> channel[<span class="hljs-string">"settings"</span>][<span class="hljs-string">"emojis_to_click"</span>]:
                                    url = <span class="hljs-string">"https://discord.com/api/v9/channels/{}/messages/{}/reactions/{}/%40me"</span>.<span class="hljs-built_in">format</span>(
                                        channel[<span class="hljs-string">"settings"</span>][<span class="hljs-string">"channel_id"</span>], message[<span class="hljs-string">"id"</span>], emoji)
                                    requests.put(url=url, headers=header)
                                    time.sleep(<span class="hljs-number">1</span>)

                        <span class="hljs-keyword">except</span>:
                            <span class="hljs-built_in">print</span>(<span class="hljs-string">"Failed to expand messages."</span>)
                            <span class="hljs-keyword">pass</span>
                <span class="hljs-keyword">except</span>:
                    <span class="hljs-built_in">print</span>(<span class="hljs-string">"Failed to get discord message."</span>)
                    <span class="hljs-keyword">pass</span>
</code></pre><p>在步骤4 里面的requirements.txt 里面加入requests，完整程式码如下：</p><pre data-type="codeBlock" text="# Function dependencies, for example:
# package&gt;=version
requests
"><code><span class="hljs-comment"># Function dependencies, for example:</span>
<span class="hljs-comment"># package>=version</span>
requests
</code></pre><p>最后点击部署！但程式目前还不会自动执行，我们还要加上触发时间</p><h2 id="h-3" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">3. 设定触发时间</h2><ol><li><p>在搜寻栏中，搜寻cloud scheduler，并建立一个新工作</p></li><li><p>名称：Hourly (这边可以随意填)</p></li><li><p>地区：选择北京</p></li><li><p>频率：30 * * * * (这个意思是每个小时会执行一次)</p></li><li><p>时区：世界标准时间</p></li><li><p>Pub / Sub 主题：选择我们稍早在创立Cloud function 时所创造的hourly 的Pub / Sub</p></li><li><p>讯息内文：这边可以随便填</p></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2227c4e03c2004527901ebc3fba69d875d8ca9efbbeffa9f6ef98fc837d9c490.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>最后选择建立！就完成触发条件设定啰</p><h2 id="h-4-discord" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">4. 如何检查Discord 抽奖机器人</h2><p>如何确定程式有执行？基本上只要没事去看一下Discord 抽奖频道，确认有没有点击抽奖就可以了</p><p>担心的话可以到Cloud Function &gt; 纪录里面，可以看到程式执行过程(如下图)</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4d5fec8b18b65d4c608dac331de5c9e7cc6297019f50a1a268ef8a71535170ab.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>那[零基础上手] Discord 自动参加抽奖机器人(云端稳定版) 就到这边感谢收看，如文章内容有误请不吝指正！</p>]]></content:encoded>
            <author>scientist@newsletter.paragraph.com (scientist)</author>
        </item>
        <item>
            <title><![CDATA[discord 抽獎機器人進階版 [ 支援帳號多開+多頻道+多關鍵字部位偵測 ]]]></title>
            <link>https://paragraph.com/@scientist/discord</link>
            <guid>yrdemGnDgdeL6WRniaqn</guid>
            <pubDate>Wed, 09 Feb 2022 04:03:08 GMT</pubDate>
            <description><![CDATA[超級感謝 科學狗友 saiba 將之前的 discord 抽獎機器人 加以改良成更具彈性且更多功能的進階版，非常感謝科學狗付出！ ( !woof !woof 經過狗友 saiba 的巧手改良後，目前 discord 抽獎機器人已支援以下功能：discord 多帳號抽獎 ( 多個 authorization id ，同時抽獎 )多項目抽獎頻道抽獎 ( 填入 channel id )針對個別抽獎頻道的不同關鍵字及出現的位置做偵測 ( 本次更新，即便關鍵字在內嵌訊息內出現，一樣能偵測出來幫你抽哦— 如下附圖 )針對個別抽獎頻道指定的表情符號做客製 ( 有些抽獎是指定按香蕉 )關於如何取得 authorization id 及 discord channel id 請參考之前文章介紹( 4. 即便標題空白，此例關鍵字設定為 “WL”一樣抽得到 ) 關於 4. 不同抽獎頻道所指定的表情編碼，可至此處查詢Emoji unicode characters for use on the webThis page is historical: For a fuller and more up-to...]]></description>
            <content:encoded><![CDATA[<h1 id="h-" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0"></h1><p>超級感謝 <strong>科學狗友 saiba</strong> 將之前的 discord 抽獎機器人 加以改良成更具彈性且更多功能的進階版，非常感謝科學狗付出！</p><p>( !woof !woof</p><p>經過狗友 saiba 的巧手改良後，目前 discord 抽獎機器人已支援以下功能：</p><ol><li><p>discord 多帳號抽獎 ( 多個 authorization id ，同時抽獎 )</p></li><li><p>多項目抽獎頻道抽獎 ( 填入 channel id )</p></li><li><p>針對個別抽獎頻道的不同關鍵字及出現的位置做偵測 ( 本次更新，即便關鍵字在內嵌訊息內出現，一樣能偵測出來幫你抽哦— 如下附圖 )</p></li><li><p>針對個別抽獎頻道指定的表情符號做客製 ( 有些抽獎是指定按香蕉 )</p></li></ol><blockquote><p><em>關於如何取得 authorization id 及 discord channel id 請參考</em><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/@metasimon/discord-%E8%87%AA%E5%8B%95%E6%8A%BD%E7%8D%8E%E6%A9%9F%E5%99%A8%E4%BA%BA-giveaways-30ddac17c86"><em>之前文章介紹</em></a></p></blockquote><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f3be091f99521af65e04dee662a596173b1a9c9311f64ad815f1d498db136b2d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ae571ba9dd9bf03360ab4624629fa6e938524b747bede85fb7b92e62a83d5826.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>( 4. 即便標題空白，此例關鍵字設定為 “WL”一樣抽得到 )</p><p>關於 4. 不同抽獎頻道所指定的表情編碼，可至此處查詢</p><h2 id="h-emoji-unicode-characters-for-use-on-the-web" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Emoji unicode characters for use on the web</h2><h3 id="h-this-page-is-historical-for-a-fuller-and-more-up-to-date-list-of-emoji-codepoints-see-unicodes-full-emoji-list" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">This page is historical: For a fuller and more up-to-date list of Emoji codepoints, see Unicode&apos;s Full Emoji List…</h3><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://apps.timwhitlock.info/emoji/tables/unicode#emoji-modal">apps.timwhitlock.info</a></p><p>修改範例：</p><ol><li><p>先找到要填的表情符號，以下圖為例</p></li><li><p>將該行右側字串複製下來，如此例為 \xF0\x9F\x8E\x89</p></li><li><p>將字串內的 \x 取代為 %</p></li><li><p>以上例取代後的字串將為 =&gt; “%F0%9F%8E%89”</p></li><li><p>放到程式碼內 emojis_to_click 後面那個欄位即可 (字串前後要加雙引號 )</p></li><li><br></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5a97ab61c2e0359ef77a8be847889c576ad240f5e828ca084455bccdbf02c9bd.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-saiba" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">關於 saiba 大整理好的程式碼，連結在此</h2><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://discord.com/channels/900395375142252584/929939732874543185/935606045705900033">https://discord.com/channels/900395375142252584/929939732874543185/935606045705900033</a></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/12a3379f51eb6790037efcb7403edd2ebcac80fa718e1ce5f1eedde795d4fa61.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>( 程式碼於該頻道內 )</p><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">最後順便廣告一下這個頻道</h2><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/690b84821cf1f3b9453636901ef7a341ad412a3f93b27a8ee416a2e189f22f14.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-discord-a-new-way-to-chat-with-friends-and-communities" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Discord - A New Way to Chat with Friends &amp; Communities</h2><h3 id="h-discord-is-the-easiest-way-to-communicate-over-voice-video-and-text-chat-hang-out-and-stay-close-with-your-friends" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends…</h3><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://discord.com/channels/900395375142252584/927411680315584573">discord.com</a></p><p>這個頻道是收集大家所知道有時常舉辦抽獎的 discord 項目，目前已有 18 項左右，都是狗友接力而來。</p><p>未來我會準備一個表格開放大家編輯，最好可以再自動產出設定檔格式，這樣大家之後複製到抽獎機器人設定檔會更方便，大家一起抽白單爆擊起來 🎉🎉🎉</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/2f6c0a18c0ae52b69e6cdd4722143b845b72db60c833957100a3a52f88f6680c.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">補充</h2><p>科學狗 Max 大最近也發現了有一些頻道開始有機器人誘餌出現，</p><p>大家使用機器人要多小心別中陷阱了哦 😆😆</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d43ff50140c2a642c094358efbeea38722cc3ccbb42696fc59942c7d4680651b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure>]]></content:encoded>
            <author>scientist@newsletter.paragraph.com (scientist)</author>
        </item>
        <item>
            <title><![CDATA[区块链系列课程：VOL1.区块链与以太坊简介]]></title>
            <link>https://paragraph.com/@scientist/vol1</link>
            <guid>eFylGJdji0ASQpLLOchQ</guid>
            <pubDate>Wed, 20 Oct 2021 11:27:53 GMT</pubDate>
            <description><![CDATA[本系列课程从第一章区块链基础介绍开始，第一节是区块链与以太坊简介。****\背景：信息存储的历史发展区块链是信息存储与共识的载体，在了解区块链发展前，我们先了解信息存储的历史发展。 在远古时候，人类为了生存聚在一起生活，一块劳动共同对抗大自然的不确定性和外界的威胁。那个时候，由于最多的活动是打猎，捕到猎物会用绳子一个个地拴起来。当时人们发现，结越多，就代表着猎物越多，结越少，就代表猎物越少。就这样，人类开始使用打结来表示数量上的不同。 在古代北欧地区，牧羊人利用刻痕计数法来记录自己的羊群数量。英语单词score就源自北欧语skor，本意是“刻痕”。由于当地人采用20进制，一条刻痕代表20，所以score也就含有“20”的意思。 夏、商、西周三代时期，数字元号逐渐规范。公元前十四至十一世纪的殷墟甲骨文卜辞中有许多数字。其中有13个记数单字、1-9、10、100、1000、10000。西汉（公元前202年—8年）初期，中国人发明了造纸术（此前靠龟甲、兽骨、金石、竹简、木牍、缣帛等记录文字）。纸的出现让信息的能被记录、传播和继承，带来了革命性的进步，促进了人类文化的传播。纸也为打孔卡奠...]]></description>
            <content:encoded><![CDATA[<p><strong>本系列课程从第一章区块链基础介绍开始，第一节是区块链与以太坊简介。</strong>****\</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>背景：信息存储的历史发展</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>区块链是信息存储与共识的载体，在了解区块链发展前，我们<strong>先了解信息存储的历史发展</strong>。</p><p>在远古时候，人类为了生存聚在一起生活，一块劳动共同对抗大自然的不确定性和外界的威胁。那个时候，由于最多的活动是打猎，捕到猎物会用绳子一个个地拴起来。当时人们发现，结越多，就代表着猎物越多，结越少，就代表猎物越少。就这样，人类开始使用<strong>打结</strong>来表示数量上的不同。</p><p>在古代北欧地区，牧羊人利用<strong>刻痕计数法</strong>来记录自己的羊群数量。英语单词score就源自北欧语skor，本意是“刻痕”。由于当地人采用20进制，一条刻痕代表20，所以score也就含有“20”的意思。</p><p>夏、商、西周三代时期，数字元号逐渐规范。公元前十四至十一世纪的殷墟<strong>甲骨文</strong>卜辞中有许多数字。其中有13个记数单字、1-9、10、100、1000、10000。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>西汉（公元前202年—8年）初期，中国人发明了造纸术（此前靠龟甲、兽骨、金石、竹简、木牍、缣帛等记录文字）。纸的出现让信息的能被记录、传播和继承，带来了革命性的进步，促进了人类文化的传播。<strong>纸也为打孔卡奠定了基础。</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>打孔卡的发展历史</strong></p><p>1725年法国人<strong>Basile Bouchon发明了打孔卡</strong>（穿孔卡），他用在纸上打孔的形式来存储图案，<strong>用于控制纺织机</strong>进行图案织造。</p><p>1801年Joseph Marie Jacquard将打孔卡顺序捆绑在一起用于提花织机，这是打孔纸带（Punched Tape）的雏形。</p><p>1846年Alexander Bain使用打孔纸带<strong>发送电报</strong>。</p><p>1890年，Herman Hollerith发明了<strong>打孔卡制表机</strong>，用于收集并统计人口普查数据，标志着半自动化数据处理系统时代的开始。这种机器不仅统计速度更快，而且能够以新的方式理解信息，很快便应用到了各个行业。</p><p>1896年，Herman Hollerith成立了<strong>制表机公司</strong>，这家公司就是后来大名鼎鼎的IBM的前身。打孔卡和纸带直到80年代还在使用，持续了两个多世纪。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>随着存储设备的逐渐升级，同体积的硬件存储的容量呈指数级增长，出现了<strong>磁带、磁鼓、机械硬盘、固态硬盘等</strong>硬件存储设备。由于区块链需要非常大的存储量，这些硬件存储设备<strong>成为了区块链存储的根基。</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>在计算机领域，存储是极为重要的应用。以数据库为例，上层应用在存储数据时只需要和数据库或其他数据管理系统打交道，而数据的具体存储方式不需要应用和开发者担心。目前的应用很多都依赖单一的数据库，有些则依赖于集群部署和多地部署的数据库。但无论如何，这些<strong>数据库都由公司或机构管理。</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>一个应用场景：在一个食品供应链领域，食品的生产、加工、运输和零售都来自不同的企业。每个企业都管理着自己的数据库，维护着自己关心的数据。比如：生产方关注产品生产的原料消耗、制作时间、制作成本等；加工方关注产品的采购价格、采购时间、加工价格、加工时间等；运输方关注产品的运输时间、预期交付时间、运输位置、温度等；零售方关注产品的销量、进货时间、销售时间等。</p><p>当各方拥有的数据分开，会带来<strong>两个问题</strong>：</p><p>**1.数据造假追责较难。**谁都有可能修改自己的数据库。一旦修改，各方难以达成共识找出足够的证据证明具体是谁改的；</p><p>2. **数据生态难以形成。**由于各方的数据彼此隔离，想要使用这些全方面的数据实现更高的数据价值就非常困难。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>为了克服以上问题，这里提出一个方法：每个业务的参与方都维护同样的数据库，而对于这项业务的每次状态变更都记录在所有方的数据库中。当做到了所有数据库的一致性，那么也实现了数据的共享，能直接核对出数据库的篡改方。</p><p>但是，如果完全开放数据库的增删改查权限给每一方，这无形地成为一个分布式数据库，只做到数据共享但无法保证数据可信，无法确定哪些操作是合法以及谁进行了某些操作。</p><p><strong>智能合约</strong>克服了以上问题。比特币的转账逻辑是一个简易的智能合约。以便了解智能合约。再举食品供应链的例子：生产方说自己生产了一个产品，准备发送给加工方。当他想对数据库里的产品数量进行+1操作时，他必须通过大家公认的智能合约里的create方法来增加产品数量。操作方必须先用自己的<strong>私钥签名</strong>才能进行操作，保证数据可追溯且可信任。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>假设生产方想要作恶，他只生产了一个产品但却写入了2。此时在区块链中，每个参与方都必须执行一遍以下合约。当大家运算结果都是1，并对1达成共识，那么私自改为2的节点自然无法达成共识，导致账本不被认可。再加上所有的操作都必须先由操作方进行签名，因此可以追溯到作恶的操作方。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>区块链的起源——比特币</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>2008年10月，一个自称为<strong>中本聪</strong>的人在一个密码学邮件列表中发布了一篇论文。论文描述了一种称为<strong>比特币</strong>的<strong>数字货币</strong>，但在当时并未得到学术界或者企业界的太多重视。</p><p>2009年1月，中本聪发布了比特币软件0.1版，比特币系统正式开始运行。几天后，<strong>第一笔转账发生</strong>。</p><p>2010年5月，第一笔比特币支付的真实交易产生：一个弗罗里达的程序员花<strong>1万比特币（当时约25美元) 买了两份披萨</strong>。</p><p>2010年7月，<strong>第一个比特币交易所在日本成立</strong>。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>区块链的核心思想其实是一种分布式记账。</p><p>比较中心化与分布式记账。<strong>中心化记账</strong>：</p><p>• 数据的存储和计算都在中心进行</p><p>• 交易依赖于对中心的信任</p><p>• 中心受到攻击后会造成很大的损失</p><p>• 中心本身可能会作恶</p><p><strong>分布式记账</strong>：</p><p>• 不需要可信任第三方</p><p>• 每个人的账本保存所有交易信息</p><p>• 通过类似民主投票的方式保证数据一致</p><p>• 大部分记账人诚实，系统则正常运行</p><p>值得一提的是，目前很多公司使用了集群数据库解决中心化记账的问题。<strong>但这些数据库仍然由一个机构所管理，没有本质上的改变。</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>有了区块链，这里出现了两个重要的问题：<strong>1.节点为什么愿意帮助整个网络维持账本？2.如何防止交易过于频繁导致的网络账本不一致问题？</strong></p><p>第一个问题：为了激励用户参与到区块链中，公链（有别于联盟链）<strong>会采用第一个记账者奖励、交易手续费和MEV激励用户</strong>。以比特币为例，奖励的实现如下：</p><p>我们将这种方法称为工作量证明。这种共识算法的记账规则为：</p><p>• 一段时间内只能有一个人记账成功。</p><p>• 通过竞争解决数学问题来获得记账权。</p><p>• 其它节点复制记账结果。</p><p>计算规则为：</p><p>• 找到随机数Nonce，使得Hash（上一个区块的Hash值，交易记录集，随机数）的值小于目标值。</p><p>• 难度根据全网算力。动态变化：diff_new=diff_old∗(k∗10)/cost(k), k=2016</p><p>• 奖励逐步减半，目前6.25个比特币的奖励。</p><p>• 由于以新发行比特币作奖励，因此被称为“挖矿”。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>对于第二个问题：需要通过某方法<strong>保证账本一致。</strong></p><p>区块由区块头和区块主体构成，区块头负责实现区块链的基本功能，区块主体包含了交易信息。区块间为链式存储，每个区块都包含前一个区块的哈希值，相当于把上一区块的指纹放在下一区块里，彼此串在一起。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>可想而知，一旦有人篡改某个交易信息，所有的区块都需要进行修改，否则哈希验证无法通过，节点数据就出现问题。此外，如果哈希算得很快，那么节点可以推倒重新算一遍。反之如果算哈希需要几十分钟的时间，那么想要修改数据可谓是难比登天。这里的时间就是难度，是后面会讨论的问题。</p><p>区块链系统中节点包含以下几类：</p><p><strong>• 钱包</strong>，存储地址和私钥，允许用户交易。</p><p><strong>• 账本</strong>，记录所有交易历史。</p><p><strong>• 矿工</strong>，通过记录交易和解决数学难题来生成新的区块。</p><p><strong>• 路由</strong>，将其他节点传输的交易数据等信息进行广播。</p><p>对于节点，它们的<strong>行为模式</strong>包括：</p><p>• <strong>监听</strong>， 网络中每个节点都在监听正在发生的交易。</p><p>• <strong>加入交易池</strong>，一旦节点监听到交易并验证为合法，就加入到自己的交易池，准备打包进新的区块。</p><p>• <strong>挖矿</strong>，所有节点都会做数学题 (挖矿) 来争夺记账权并获取收益，先解出者可以向全网广播区块。</p><p>• <strong>验证区块</strong>，当且仅当区块中所有交易均有效且首次出现，其他节点才认同该区块的合法性，并将其加到自己的区块链末尾，一笔新的交易一般需要经过6个区块的确认才算有效。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>区块链的分类</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>并不是所有区块链都和比特币一样。根据节点的准入规则，可以将它们分为公有链、联盟链和私有链：</p><p>•<strong>公有链</strong>对所有人开放，任何人都能参与，如比特币、以太坊、PlatON等。</p><p>•<strong>联盟链</strong>对特定的组织团体开放，如Fabric、BCOS、百度超级链等。</p><p>•<strong>私有链</strong>对单独的个人或实体开放，通常由公司或个人内部使用。</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong>几个著名的公链项目介绍</strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>**比特币（Bitcoin）**是一种基于去中心化，采用点对点网络与共识主动性，开放源代码，以区块链作为底层技术的加密货币。比特币由中本聪（网名）（Satoshi Nakamoto）于2008年10月31日发表论文提出。\</p><p>**以太坊 (Ethereum)</p><p>以太坊是一种通过支付小额费用向任何人发送加密货币的技术。基于它还能创建永不停机、人人可用的各种应用。</p><p><strong>它是 <em>属于全世界的可编程区块链。</em></strong></p><p>以太坊以比特币带来的创新为基础，同时做出了很多改进。</p><p>虽然两者都能让您无需支付服务提供商或银行的支持即可使用数字货币，但是以太坊是可编程的，因此您可以基于它构建其它不同的数字资产 - 甚至是比特币！</p><p>因此以太坊并不仅仅意味着支付。它还是一个聚集了各种金融服务、游戏和应用的自由市场。在这里没有人可以监控或者窃取您的数据。</p><p><strong>PlatON</strong> 是专注于可扩展性和隐私保护的高性能分布式计算网络，通过可验证计算、安全多方计算、零知识证明、同态加密等密码学算法共同组装的下一代计算架构，为全球人工智能、分布式应用开发者、数据提供方及存有计算需求的各类社区、机构、个人，提供开源架构下的公共基础设施软件开发、咨询、运营服务。</p><p><strong>各类区块链对比</strong></p><p><strong>公有链</strong>：</p><p>•任何人都可加入网络访问/写入数据</p><p>•每秒3-20次数据写入</p><p>•需要给挖矿者激励</p><p><strong>联盟链</strong>：</p><p>•授权公司和组织才能加入网络</p><p>•每秒1000次以上数据写入</p><p>•机构间互利共赢，无需激励</p><p><strong>私有链</strong>：</p><p>•单个公司和组织管理的网络</p><p>•每秒1000次以上数据写入</p><p>•无需激励</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p><strong><em>END</em></strong></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="" alt="" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure>]]></content:encoded>
            <author>scientist@newsletter.paragraph.com (scientist)</author>
        </item>
    </channel>
</rss>