-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.json
1 lines (1 loc) · 94.8 KB
/
content.json
1
{"meta":{"title":"Fnkk的个人博客","subtitle":"","description":"","author":"fnkk","url":"http://example.com","root":"/"},"pages":[{"title":"about","date":"2018-12-12T14:14:36.000Z","updated":"2024-01-15T07:36:03.614Z","comments":false,"path":"about/index.html","permalink":"http://example.com/about/index.html","excerpt":"","text":"[さくら荘のhojun] 与 Mashiro ( 真(ま)白(しろ) ) 对话中... bot_ui_ini()"},{"title":"bangumi","date":"2019-02-10T13:32:48.000Z","updated":"2024-01-15T07:36:03.616Z","comments":false,"path":"bangumi/index.html","permalink":"http://example.com/bangumi/index.html","excerpt":"","text":""},{"title":"client","date":"2018-12-20T15:13:35.000Z","updated":"2024-01-15T07:36:03.617Z","comments":false,"path":"client/index.html","permalink":"http://example.com/client/index.html","excerpt":"","text":"直接下载 or 扫码99下载:"},{"title":"comment","date":"2018-12-20T15:13:48.000Z","updated":"2024-01-15T07:36:03.619Z","comments":true,"path":"comment/index.html","permalink":"http://example.com/comment/index.html","excerpt":"","text":"念两句诗 叙别梦、扬州一觉。 【宋代】吴文英《夜游宫·人去西楼雁杳》"},{"title":"donate","date":"2018-12-20T15:13:05.000Z","updated":"2024-01-15T07:36:03.620Z","comments":false,"path":"donate/index.html","permalink":"http://example.com/donate/index.html","excerpt":"","text":""},{"title":"lab","date":"2019-01-05T13:47:59.000Z","updated":"2024-01-15T07:36:03.621Z","comments":false,"path":"lab/index.html","permalink":"http://example.com/lab/index.html","excerpt":"","text":"sakura主题balabala"},{"title":"music","date":"2018-12-20T15:14:28.000Z","updated":"2024-01-15T07:36:03.624Z","comments":false,"path":"music/index.html","permalink":"http://example.com/music/index.html","excerpt":"","text":""},{"title":"links","date":"2018-12-19T15:11:06.000Z","updated":"2024-01-15T07:36:03.623Z","comments":true,"path":"links/index.html","permalink":"http://example.com/links/index.html","excerpt":"","text":""},{"title":"rss","date":"2018-12-20T15:09:03.000Z","updated":"2024-01-15T07:36:03.626Z","comments":true,"path":"rss/index.html","permalink":"http://example.com/rss/index.html","excerpt":"","text":""},{"title":"tags","date":"2018-12-12T14:14:16.000Z","updated":"2024-01-15T07:36:03.627Z","comments":true,"path":"tags/index.html","permalink":"http://example.com/tags/index.html","excerpt":"","text":""},{"title":"music","date":"2018-12-20T15:14:28.000Z","updated":"2024-01-15T07:36:03.629Z","comments":false,"path":"test/index.html","permalink":"http://example.com/test/index.html","excerpt":"","text":""},{"title":"theme-sakura","date":"2019-01-04T14:53:25.000Z","updated":"2024-01-15T07:36:03.631Z","comments":false,"path":"theme-sakura/index.html","permalink":"http://example.com/theme-sakura/index.html","excerpt":"","text":"Hexo主题Sakura修改自WordPress主题Sakura,感谢原作者Mashiro"},{"title":"video","date":"2018-12-20T15:14:38.000Z","updated":"2024-01-15T07:36:03.632Z","comments":false,"path":"video/index.html","permalink":"http://example.com/video/index.html","excerpt":"","text":"var videos = [ { img: 'https://lain.bgm.tv/pic/cover/l/0e/1e/218971_2y351.jpg', title: '朝花夕誓——于离别之朝束起约定之花', status: '已追完', progress: 100, jp: 'さよならの朝に約束の花をかざろう', time: '放送时间: 2018-02-24 SUN.', desc: ' 住在远离尘嚣的土地,一边将每天的事情编织成名为希比欧的布,一边静静生活的伊欧夫人民。在15岁左右外表就停止成长,拥有数百年寿命的他们,被称为“离别的一族”,并被视为活着的传说。没有双亲的伊欧夫少女玛奇亚,过着被伙伴包围的平稳日子,却总感觉“孤身一人”。他们的这种日常,一瞬间就崩溃消失。追求伊欧夫的长寿之血,梅萨蒂军乘坐着名为雷纳特的古代兽发动了进攻。在绝望与混乱之中,伊欧夫的第一美女蕾莉亚被梅萨蒂带走,而玛奇亚暗恋的少年克里姆也失踪了。玛奇亚虽然总算逃脱了,却失去了伙伴和归去之地……。' }, { img : 'https://lain.bgm.tv/pic/cover/l/0e/1e/218971_2y351.jpg', title: '朝花夕誓——于离别之朝束起约定之花', status: '已追完', progress: 100, jp: 'さよならの朝に約束の花をかざろう', time: '2018-02-24 SUN.', desc: ' 住在远离尘嚣的土地,一边将每天的事情编织成名为希比欧的布,一边静静生活的伊欧夫人民。在15岁左右外表就停止成长,拥有数百年寿命的他们,被称为“离别的一族”,并被视为活着的传说。没有双亲的伊欧夫少女玛奇亚,过着被伙伴包围的平稳日子,却总感觉“孤身一人”。他们的这种日常,一瞬间就崩溃消失。追求伊欧夫的长寿之血,梅萨蒂军乘坐着名为雷纳特的古代兽发动了进攻。在绝望与混乱之中,伊欧夫的第一美女蕾莉亚被梅萨蒂带走,而玛奇亚暗恋的少年克里姆也失踪了。玛奇亚虽然总算逃脱了,却失去了伙伴和归去之地……。' } ] .should-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:95%;}.should-ellipsis-full{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;}.should-ellipsis i{position:absolute;right:24px;}.grey-text{color:#9e9e9e !important}.grey-text.text-darken-4{color:#212121 !important}html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}img{border-style:none}progress{display:inline-block;vertical-align:baseline}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}html{-webkit-box-sizing:border-box;box-sizing:border-box}*,*:before,*:after{-webkit-box-sizing:inherit;box-sizing:inherit}ul:not(.browser-default){padding-left:0;list-style-type:none}ul:not(.browser-default)>li{list-style-type:none}.card{-webkit-box-shadow:0 2px 2px 0 rgba(0,0,0,0.14),0 3px 1px -2px rgba(0,0,0,0.12),0 1px 5px 0 rgba(0,0,0,0.2);box-shadow:0 2px 2px 0 rgba(0,0,0,0.14),0 3px 1px -2px rgba(0,0,0,0.12),0 1px 5px 0 rgba(0,0,0,0.2)}.hoverable{-webkit-transition:-webkit-box-shadow .25s;transition:-webkit-box-shadow .25s;transition:box-shadow .25s;transition:box-shadow .25s,-webkit-box-shadow .25s}.hoverable:hover{-webkit-box-shadow:0 8px 17px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);box-shadow:0 8px 17px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19)}i{line-height:inherit}i.right{float:right;margin-left:15px}.bangumi .right{float:right !important}.material-icons{text-rendering:optimizeLegibility;-webkit-font-feature-settings:'liga';-moz-font-feature-settings:'liga';font-feature-settings:'liga'}.row{margin-left:auto;margin-right:auto;margin-bottom:20px}.row:after{content:\"\";display:table;clear:both}.row .col{float:left;-webkit-box-sizing:border-box;box-sizing:border-box;padding:0 .75rem;min-height:1px}.row .col.s12{width:100%;margin-left:auto;left:auto;right:auto}@media only screen and (min-width:601px){.row .col.m6{width:50%;margin-left:auto;left:auto;right:auto}}html{line-height:1.5;font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;font-weight:normal;color:rgba(0,0,0,0.87)}@media only screen and (min-width:0){html{font-size:14px}}@media only screen and (min-width:992px){html{font-size:14.5px}}@media only screen and (min-width:1200px){html{font-size:15px}}.card{position:relative;margin:.5rem 0 1rem 0;background-color:#fff;-webkit-transition:-webkit-box-shadow .25s;transition:-webkit-box-shadow .25s;transition:box-shadow .25s;transition:box-shadow .25s,-webkit-box-shadow .25s;border-radius:2px}.card .card-title{font-size:24px;font-weight:300}.card .card-title.activator{cursor:pointer}.card .card-image{position:relative}.card .card-image img{display:block;border-radius:2px 2px 0 0;position:relative;left:0;right:0;top:0;bottom:0;width:100%}.card .card-content{padding:24px;border-radius:0 0 2px 2px}.card .card-content p{margin:0}.card .card-content .card-title{display:block;line-height:32px;margin-bottom:8px}.card .card-content .card-title i{line-height:32px}.card .card-reveal{padding:24px;position:absolute;background-color:#fff;width:100%;overflow-y:auto;left:0;top:100%;height:100%;z-index:3;display:none}.card .card-reveal .card-title{cursor:pointer;display:block}.waves-effect{position:relative;cursor:pointer;display:inline-block;overflow:hidden;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;vertical-align:middle;z-index:1;-webkit-transition:.3s ease-out;transition:.3s ease-out}.waves-effect img{position:relative;z-index:-1}.waves-block{display:block}::-webkit-input-placeholder{color:#d1d1d1}::-moz-placeholder{color:#d1d1d1}:-ms-input-placeholder{color:#d1d1d1}::-ms-input-placeholder{color:#d1d1d1}[type=\"radio\"]:not(:checked){position:absolute;opacity:0;pointer-events:none}[type=\"radio\"]:not(:checked)+span{position:relative;padding-left:35px;cursor:pointer;display:inline-block;height:25px;line-height:25px;font-size:1rem;-webkit-transition:.28s ease;transition:.28s ease;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}[type=\"radio\"]:not(:checked)+span:before,[type=\"radio\"]:not(:checked)+span:after{border-radius:50%}[type=\"radio\"]:not(:checked)+span:before,[type=\"radio\"]:not(:checked)+span:after{border:2px solid #5a5a5a}[type=\"radio\"]:not(:checked)+span:after{-webkit-transform:scale(0);transform:scale(0)}[type=\"checkbox\"]:not(:checked){position:absolute;opacity:0;pointer-events:none}[type=\"checkbox\"]:not(:checked):disabled+span:not(.lever):before{border:none;background-color:rgba(0,0,0,0.42)}[type=\"checkbox\"].filled-in:not(:checked)+span:not(.lever):before{width:0;height:0;border:3px solid transparent;left:6px;top:10px;-webkit-transform:rotateZ(37deg);transform:rotateZ(37deg);-webkit-transform-origin:100% 100%;transform-origin:100% 100%}[type=\"checkbox\"].filled-in:not(:checked)+span:not(.lever):after{height:20px;width:20px;background-color:transparent;border:2px solid #5a5a5a;top:0px;z-index:0}input[type=checkbox]:not(:disabled) ~ .lever:active:before,input[type=checkbox]:not(:disabled).tabbed:focus ~ .lever::before{-webkit-transform:scale(2.4);transform:scale(2.4);background-color:rgba(0,0,0,0.08)}input[type=range].focused:focus:not(.active)::-webkit-slider-thumb{-webkit-box-shadow:0 0 0 10px rgba(38,166,154,0.26);box-shadow:0 0 0 10px rgba(38,166,154,0.26)}input[type=range].focused:focus:not(.active)::-moz-range-thumb{box-shadow:0 0 0 10px rgba(38,166,154,0.26)}input[type=range].focused:focus:not(.active)::-ms-thumb{box-shadow:0 0 0 10px rgba(38,166,154,0.26)} 番组计划 这里将是永远的回忆 window.onload = function(){ videos.forEach(function(video, i){ $('#rootRow').append(` ${video.title} ${video.jp} ${video.status} ${video.title} ${video.jp} 放送时间: ${video.time} ${video.desc} ${video.status} `) }) }"},{"title":"music","date":"2018-12-20T15:14:28.000Z","updated":"2024-01-15T07:36:03.628Z","comments":false,"path":"tags/图集/index.html","permalink":"http://example.com/tags/%E5%9B%BE%E9%9B%86/index.html","excerpt":"","text":""}],"posts":[{"title":"NextJs-01","slug":"NextJs-01","date":"2024-01-18T08:43:25.000Z","updated":"2024-01-18T10:08:58.553Z","comments":true,"path":"2024/01/18/NextJs-01/","link":"","permalink":"http://example.com/2024/01/18/NextJs-01/","excerpt":"","text":"前言之前学Next都是边用边学,现在打算重新系统的学习一遍,从读NextJs的官方文档开始 CSS stylingGlobal styles1import '@/app/ui/global.css'; 直接引入全局样式,一般应用于顶部组件。 Tailwind一种CSS框架,直接在className里用Tailwind的规则直接写样式,这样写出来的标签好长,可能是没怎么用过,感觉看着好累,不喜欢。 1<h1 className="text-blue-500">I'm blue!</h1> CSS Modules将css文件命名为xxx.module.css的格式,在用如下方式引入使用。 123import styles from '@/app/ui/home.module.css'; <div className={styles.shape}> clsx可以用于切换ClassName来条件渲染样式,平常直接用一些判断语句来做这样的条件渲染,似乎这个功能不是很必须。下面是一个列子: 123456789101112131415import clsx from 'clsx'; export default function InvoiceStatus({ status }: { status: string }) { return ( <span className={clsx( 'inline-flex items-center rounded-full px-2 py-1 text-sm', { 'bg-gray-100 text-gray-500': status === 'pending', 'bg-green-500 text-white': status === 'paid', }, )} > // ...)} Optimizing Fonts and Images next/font next/image","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"Algorithm-02","slug":"Algorithm-02","date":"2024-01-17T01:45:30.000Z","updated":"2024-01-17T02:30:56.032Z","comments":true,"path":"2024/01/17/Algorithm-02/","link":"","permalink":"http://example.com/2024/01/17/Algorithm-02/","excerpt":"","text":"旋转链表题目: 给你一个链表的头节点 head ,旋转链表,将链表每个节点向右移动 k 个位置。 示例 1 输入:head = [1,2,3,4,5], k = 2 输出:[4,5,1,2,3] 示例 2 输入:head = [0,1,2], k = 4 输出:[2,0,1] 思路只要找到旋转后链表头位置记为J,把原来的链表头尾相连,在从J位置断开即可。 代码实现123456789101112131415161718192021222324var rotateRight = function(head, k) { if (!head || k === 0) { return head; } let length = 1; let tail = head; while (tail.next) { tail = tail.next; length++; } k = k % length; if (k === 0) { return head; } let newTail = head; for (let i = 0; i < length - k - 1; i++) { newTail = newTail.next; } let newHead = newTail.next; newTail.next = null; tail.next = head; return newHead;}; 感受中等难度的题目写起来还是比较顺手的,但是算不上得心应手,花费的时间挺多的,要再巩固多几题,再尝试困难的题目。","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"React-01","slug":"React-01","date":"2024-01-16T07:40:03.000Z","updated":"2024-01-16T08:53:04.561Z","comments":true,"path":"2024/01/16/React-01/","link":"","permalink":"http://example.com/2024/01/16/React-01/","excerpt":"","text":"前言之前学React都是边用边学,要做什么功能学习怎么实现的野路子。现在打算重新系统的学习一遍,从读react的官方文档开始## UseState","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"Algorithm_01","slug":"Algorithm-01","date":"2024-01-16T02:17:46.000Z","updated":"2024-01-16T06:47:36.595Z","comments":true,"path":"2024/01/16/Algorithm-01/","link":"","permalink":"http://example.com/2024/01/16/Algorithm-01/","excerpt":"","text":"前言在数字时代,算法的重要性日益凸显。意识到这一点,我计划利用闲暇时间练习算法题目,以提高我的编程技巧和逻辑思维。这不仅是对个人技能的提升,也是对未来职业发展的投资。解决算法问题的过程既富有挑战性又充满乐趣,每次突破都让我获得巨大的成就感。 我将记录我的学习历程和解题思路,希望这些笔记不仅能帮助自己回顾和巩固知识,同时也能为同样对算法感兴趣的朋友提供参考和启发。面对算法的复杂性和多样性,我相信持续的练习和分享是理解和掌握它们的最佳途径。 全排列题目:给定一个不含重复数字的数组 nums,返回其所有可能的全排列。你可以按任意顺序返回答案。 示例 1: 输入:nums = [1,2,3] 输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 示例2: 输入:nums = [0,1] 输出:[[0,1],[1,0]] 示例3: 输入:nums = [1] 输出:[[1]] 提示: 1 <= nums.length <= 6 -10 <= nums[i] <= 10 nums 中的所有整数 互不相同 思路 数组nums不含重复的数字,所以只要每个元素排列的顺序不同,就不会出现重复的结果。因此只需从前往后,把每种可能性遍历出来即可。 使用递归的方式,迭代出所有的可能性。 代码实现1234567891011121314151617var permute = function (nums) { let res = [] dfs(nums,[]) function dfs(nums, arr) { if (nums.length == 0) { res.push(arr) return } for (let i = 0; i < nums.length; i++) { let temp = [...nums.slice(0, i), ...nums.slice(i + 1)] let newArr = arr newArr.push(nums[i]) dfs(temp, newArr) } } return res}; 我最开始是这样写的,但是输出的结果的长度有问题,检查后推测是newArr这里可能引用了同样的地址,导致后面的结果继续push到已经存入res的结果中,于是改为下面的写法,成功通过了测试。 123456789101112131415var permute = function (nums) { let res = [] dfs(nums,[]) function dfs(nums, arr) { if (nums.length == 0) { res.push(arr) return } for (let i = 0; i < nums.length; i++) { let temp = [...nums.slice(0, i), ...nums.slice(i + 1)] dfs(temp, [...arr,nums[i]]) } } return res}; 最后全排列是众多递归题目的基础,许多回溯和剪枝的操作都是在这个基础上的,要好好掌握。","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"杭州黑客松类friend.tech系统的搭建","slug":"hangzhouHackthon","date":"2023-10-14T06:26:01.000Z","updated":"2024-01-15T08:33:11.115Z","comments":true,"path":"2023/10/14/hangzhouHackthon/","link":"","permalink":"http://example.com/2023/10/14/hangzhouHackthon/","excerpt":"","text":"类friend.tech系统设计的思路铸造NFT(nft信息可能还需要铸造时间、作者等信息) 项目地址 简介 首页 所有项目的列表 包括字段:项目地址、简介、长度(发行了多少个NFT)、资金池、项目方总收益 购买相关的项目NFT ?相关的一些图表 个人中心 我购买的所有项目相关信息 我的位次 我的收益(包括回本预期,还需要多少位人入场) 操作(怒退) 怒退按钮(实现怒退功能) 发布项目 发布页面 提交表单:需要项目地址、简介。 开发细节确定项目前端 day0 确定使用的技术栈:react 搭建页面的layout和静态页面的编写 使用etherjs连接钱包 day1 使用etherjs连接部署至Scroll的合约 调用合约的接口(initToken,mint等)完成相应的功能 读取合约信息完善页面 后端","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"WTF study notes","slug":"WTF-study-notes","date":"2023-06-29T06:48:52.000Z","updated":"2024-01-15T07:36:03.598Z","comments":true,"path":"2023/06/29/WTF-study-notes/","link":"","permalink":"http://example.com/2023/06/29/WTF-study-notes/","excerpt":"","text":"Solidity 101引用类型 以下关于数组的说法中,正确的是 c 误选 b a. 固定长度数组 和 bytes拥有 push() 成员,可以在数组最后添加一个0元素。 b. 数组字面常数,例如 [uint(1),2,3],需要声明第一个元素的类型,不然默认用存储空间最大的类型。 c. 内存数组的长度在创建后是固定的。 d. 对于memory可变长度数组,可以用new操作符来创建,并且不用声明长度,例如uint[] memory array = new uint[];。 解析: a. 动态数组和bytes 拥有push() b. 默认用存储空间最小的类型 d. new关键字创建需要声明长度 有如下一段合约代码,执行 initStudent 方法后,student.id 和 student.score 的值分别为 contract StructTypes { struct Student{ uint256 id; uint256 score; } Student student; function initStudent() external{ student.id = 100; student.score = 200; Student storage _student = student; _student.id = 300; _student.score = 400; } } a. 300 400 b. 100 200 c. 300 200 d. 100 400 解析: 正确答案a,创建新的Student _student是引用类型,地址指向不变,会改变指向地址内部的值。 映射类型 Mapping的存储位置可以是? 只能是storage 给映射变量map新增键值对的方法? map[_Key] = _Value; 变量初始化 字节的默认值是 0x00 常数 constant和immutable constant(常量)和immutable(不变量)。状态变量声明这个两个关键字之后,不能在合约后更改数值;并且还可以节省gas。另外,只有数值变量可以声明constant和immutable;string和bytes可以声明为constant,但不能为immutable。 继承多重继承solidity的合约可以继承多个合约。规则: 继承时要按辈分最高到最低的顺序排。比如我们写一个Erzi合约,继承Yeye合约和Baba合约,那么就要写成contract Erzi is Yeye, Baba,而不能写成contract Erzi is Baba, Yeye,不然就会报错。 如果某一个函数在多个继承的合约里都存在,比如例子中的hip()和pop(),在子合约里必须重写,不然会报错。 重写在多个父合约中都重名的函数时,override关键字后面要加上所有父合约名字,例如override(Yeye, Baba)。 例子: 12345678910contract Erzi is Yeye, Baba{ // 继承两个function: hip()和pop(),输出值为Erzi。 function hip() public virtual override(Yeye, Baba){ emit Log("Erzi"); } function pop() public virtual override(Yeye, Baba) { emit Log("Erzi"); }}我们可以看到,Erzi合约里面重写了hip()和pop()两个函数,将输出改为”Erzi”,并且还分别从Yeye和Baba合约继承了yeye()和baba()两个函数。 抽象合约和接口 接口的定义 不能包含状态变量 不能包含构造函数 不能继承除接口外的其他合约 所有函数都必须是external且不能有函数体 继承接口的合约必须实现接口定义的所有功能 接收ETH接收ETH函数receive receive()只用于处理接收ETH。一个合约最多有一个receive()函数,声明方式与一般函数不一样,不需要function关键字:receive() external payable { … }。receive()函数不能有任何的参数,不能返回任何值,必须包含external和payable。 回退函数fallback fallback()函数会在调用合约不存在的函数时被触发。可用于接收ETH,也可以用于代理合约proxy contract。fallback()声明时不需要function关键字,必须由external修饰,一般也会用payable修饰,用于接收ETH:fallback() external payable { … }。 发送ETH transfer 目标地址.transfer(金额) gas限制是2300 转账失败会自动回滚 没有返回值 send 目标地址.send(金额) gas限制2300 转账失败不会revert send()的返回值是一个bool,代表转账成功或失败 call 目标地址.call(value:金额) 没有gas限制 转账失败不会revert call()的返回值是(bool,data),bool代表转账成功或失败","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"ff数字藏品交易系统的搭建","slug":"ff-system","date":"2023-03-31T07:51:01.000Z","updated":"2024-01-15T07:36:03.602Z","comments":true,"path":"2023/03/31/ff-system/","link":"","permalink":"http://example.com/2023/03/31/ff-system/","excerpt":"","text":"毕业设计系统设计的思路铸造NFT(nft信息可能还需要铸造时间、作者等信息) WTF的铸造NFT合约的铸造函数mint() 只需要两个参数,tokenId和生成后NFT的地址。这显然是不符合我的需求的,需要改造。 生成NFT的tokenId自动生成,自增,容量上限为10000个。 生成NFT后的默认地址为使用的用户的地址 生成NFT需要一些额外的参数:图片信息(最重要的信息,应该是一个IPFS的地址哈希值),一些描述(用于展示NFT时描述,如:作者、名称等,不作为生成的条件)。 修改ERC721.sol 思路(已完成) tokenId 数据类型从uint改为string,从_mint函数的入参获得变为 图片地址哈希+nft名称+简介(或者简介存入ipfs的哈希) 通过sha256生成的值,不在设最大token数量(或者添加一个tokenNumber记录当前nft数量,并定义最大数量)。 tokenId 的数据类型只能是uint 所以tokenId改为数字自增, _mint函数入参改变为 用户地址+图片哈希+name+简介 通过computedTokenId()函数获取tokenId的值,后续逻辑不变 定义一个mapping(tokenId => tokenDetail),tokenDetail为一个struct,包含tokenId,picUrl,introduction,name四个字段。 定义一个getTokenDetail函数 输入tokenId获取tokenDetail的内容 追溯NFT 查询交易记录的功能 输入tokenID查询这个NFT的所有被交易信息。 输入一个账号地址,查询该账号的所有交易记录。 需要利用事件存储交易信息到数据库,再在数据库中操作查询交易记录(node.js和mongoDb的操作,数据库如何设计,是否有必要记录其他更多的数据,实现完整的链下生态) planB: 前端直接通过事件拿到所有信息,然后在前端进行数据处理展示,这样可以跳过node和mongo,但是逻辑可能也很复杂。 首页 一个走马灯,一个背景图,然后其他几个页面跳跳算了。 个人中心 查看本人持有的所有NFT(已完成) 本人所有交易记录,功能上隶属于追溯(不一定做,大概率放弃) 每个nft有两个按钮,分别是转赠和拍卖,分别跳转至转赠和新增拍卖页面。 数字博物馆 展示所有NFT作品,无限滚动、懒加载 还是采用分页的方式,简单一点,重写分页的方法即可。 和个人列表一致,采用card的形式展示,点击查看NFT作品详情。多一个该nft所有的交易记录信息,作者,持有人,创建时间 数字藏品拍卖 用户可以提交自己持有的NFT进行拍卖 拍卖所展示被拍卖的NFT 分类分列:待开始、进行中、已结束。 拍卖流程同e-bay 数据库设计 nft表tokenId name introduction picUrl createdTime author owner transferSum查询owner获取个人所有nft查询所有信息获取所有nft 交易记录表tokenId from to transferTime查询tokenId返回所有记录就是追溯的结果。 拍卖表有点多晚点再说 合约事件设计只要一个新增NFT的事件即可,transfer事件既新增交易记录表,又更新nft表 毕业论文大纲 目录 摘要 第一句讲背景,第二局讲做了什么,怎么做了,结果是啥 随着“元宇宙”概念的爆火,与“元宇宙”相关的产业如雨后春笋般涌现出来。最典型的代表就是 NFT,它是表示数字资产的货币令牌,可以在网络上进行买卖,具备一定的货币属性。NFT 传入国内后,经过一定时间的发展,衍生成为了现在的数字藏品。数字藏品作为一种新兴的收藏品,为满足广大数字藏品爱好者的需要,本文尝试通过区块链技术,设计并实现了基于区块链数字藏品交易系统,旨在让人们体验、感受数字藏品的魅力。 需求分析用例。vision 绪论 研究背景及意义 国内外研究现状 区块链现状 数字藏品现状 本文主要工作 相关理论技术介绍 区块链技术概述 node.js和mongodb概述 Node.js是一个基于Chrome V8引擎的开源、跨平台的JavaScript运行时环境。它允许开发者使用JavaScript来编写服务器端代码,以及使用JavaScript语言处理数据和事件。Node.js的出现极大地推动了JavaScript在服务器端的应用,并且成为了现代Web开发中不可或缺的一部分。Node.js提供了一些核心模块和第三方模块,使得开发者可以方便地构建高性能、可扩展的Web应用、网络工具和命令行工具。同时,Node.js还有着丰富的社区和文档资源,为开发者提供了强大的支持。 MongoDB是一种NoSQL数据库,采用了分布式文件存储的方式,以键值对的形式存储数据。它是一个高性能、可扩展、易部署的开源数据库,特别适合大规模的数据存储。相比传统的关系型数据库,MongoDB具有更高的可扩展性和更好的性能,在大数据处理和高并发场景中表现优异。同时,它还提供了灵活的数据模型和查询方式,使得开发者可以更加自由地设计和操作数据。MongoDB广泛应用于Web应用程序、移动应用程序、大数据、物联网等领域。 IPFS概述 react和web3.js概述 数字藏品交易系统的分析与设计 引入区块链的必要性 将数字藏品存储在区块链上,可以使用智能合约确保每个数字藏品的唯一性和不可更改性,避免了数字藏品被复制、篡改等问题,可以增强数字藏品的唯一性和可信度。其次,区块链技术使用密码学和分布式网络的去中心化存储可以保护数据安全,有效防止数字藏品被黑客攻击或中心化服务器故障导致数据丢失。再者,使用使用区块链技术进行数字藏品交易,可以节省传统的中介费用和交易成本,同时通过智能合约和分布式网络实现的去中心化交易,保证每个交易的公平和公正,提供更加透明和公正的数字藏品交易平台。 数字藏品交易系统需求分析 用户能够创建自己的数字藏品,同时能够查看其它用户创建的数字藏品。数字藏品的拥有者可以对它进行转赠和出售两种操作,用户可以购买被出售的数字藏品。数字藏品的所有交易都是公开透明的,可以追溯历史交易记录。 数字藏品交易系统架构设计。 区块链作为一种分布式存储系统,能确保数据永久保存无法篡改,但是图片等大体积数据上链成本高,数据量大时查询效率低,所以本系统分为链上、链下两部分。其中链上部分为区块链存储,将数字藏品的创建、交易等信息通过智能合约接口存储到区块链上,保证数据真实可靠。同时依靠智能合约的事件监听,同步一份数据到传统数据库中,后续对数据的查询可以访问数据库提高查询效率。由于区块链上的数据可以追溯,如果怀疑数据库中的数据被篡改,可以查询区块链的历史数据与数据库进行对比,确保数据的真实可靠。将高清图片存储至IPFS系统,仅把IPFS返回的哈希值存储至区块链中,减少存储成本。最后构建前端界面,与区块链和后端进行交互,实现核心功能,如下图:…。 数字藏品交易系统核心功能设计。 数字藏品创建 用户上传图片至IPFS,填写名称、简介等信息后,即可生成数字藏品。 数字藏品转赠 用户选择要转赠的数字藏品,填写被转赠的用户地址,即可完成转赠。 数字藏品交易 用户选择要出售的数字藏品,填写要出售的价格,即可创建交易单号,在交易完成之前,可以进行价格修改、撤单的操作。用户可以在数字藏品交易中心查看发起交易的数字藏品,并选择是否购买。 数字藏品溯源 用户输入数字藏品的唯一标识tokenId后,可以查找到该数字藏品的历史交易记录。 数字藏品交易系统的实现 区块链环境搭建 区块链按照去中心化程度由高到低分为:公链,联盟链,私链。因为公共网络的区块数量太多,同步耗时太长,为了方便本地开发与合约测试,本文搭建以太坊私链作为区块链的环境,后续如有需要,可以将智能合约部署至公链。 下载geth客户端windows版本,然后需要创建网络的“创世”(genesis)状态,这写在一个JSON文件里(将其命名为genesis.json): { “config”: { “chainId”: 666 }, “difficulty”: “2000”, “gasLimit”: “2100000”, “alloc”: { “7df9a875a174b3bc565e6424a0050ebc1b2d1d82”: { “balance”: “300000” }, “f41c74c9ae680c1aa78f42e5647a62f353b7bdde”: { “balance”: “400000” } } } 其中chainId为区块链Id,需要和主流公链不一样,difficulty为挖矿难度,gasLimit为交易时最大gas限制,alloc为初始账号设置。 在终端运行:geth –datadir init genesis.json命令创建一条id为666的私链。创建完成后运行:geth –datadir –networkid 666 就可以成功运行以太坊节点。至此区块链开发环境搭建完成。 智能合约编写及部署 基于本系统主要功能,拆分成数字藏品铸造和数字藏品交易两个主合约实现相应功能。 ERC721.sol(数字藏品铸造合约):继承IERC721合约。 IERC721是一个标准的智能合约接口,用于在以太坊区块链上定义非同质化代币(NFT)。这个接口规范了创建、转让和销毁NFT的方法,同时定义了一个标准的元数据(metadata)格式,使得不同的应用可以共享和处理这些NFT。 表:IERC721的事件和函数 表:ERC721的事件和函数(这里新增了不少东西) NFTSwap.sol(数字藏品交易合约):主要实现挂单、购买、修改价格和撤单 编写完成合约代码后,运行truffle compile命令编译代码。 编写迁移脚本 运行truffle migration完成智能合约的部署。 IPFS系统实现 本文引入IPFS用于存储数字藏品的高清图片。首先从IPFS官网下载go语言实现版本,在安装、配置环境之后,运行ipfs daemon命令,启动IPFS服务并在5001端口监听。IPFS网络情况如图…所示,图中数据表示本机所处网络已经覆盖了…个节点。其中本机所运行的节点地址为… 本系统与IPFS的交互主要在前端功能上,详情见前端实现部分。 链下功能实现 安装express、mongoose、web3等依赖,分别用于构建后端服务、与mongo 数据库交互、与geth客户端交互的功能。 数据库设计 根据系统的需求分析,设计了如下三张表:nfts、transfers、swaps分别用于记录数字藏品信息、交易记录信息和交易单信息。 三张表具体信息。 创建实体Schema对象。通过Schema对象对数据库进行添加修改操作 获取合约对象 引入合约编译好的json,通过web3.js获取合约对象。监听合约对象的事件,触发不同的事件后对数据库进行相应的操作。 根据需求,编写后端接口,返回需要的数据 前端实现 前端采用React框架+Antd组件库构建前端页面。 介绍+贴图。 数字藏品交易系统的测试 数字藏品上传测试 数字藏品转赠测试 数字藏品交易测试 数字藏品溯源测试 总结与展望","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"Implementation-of-ERC721","slug":"Implementation-of-ERC721","date":"2023-03-07T06:48:52.000Z","updated":"2024-01-15T07:36:03.597Z","comments":true,"path":"2023/03/07/Implementation-of-ERC721/","link":"","permalink":"http://example.com/2023/03/07/Implementation-of-ERC721/","excerpt":"","text":"学习ERC721标准,实现一个能发布NFT的的合约EIP与ERC- 这里有一个点需要理解,本节标题是ERC721,这里又提到了EIP721,这两个是什么关系呢? EIP全称 Ethereum Imporvement Proposals(以太坊改进建议), 是以太坊开发者社区提出的改进建议, 是一系列以编号排定的文件, 类似互联网上IETF的RFC。 EIP可以是 Ethereum 生态中任意领域的改进, 比如新特性、ERC、协议改进、编程工具等等。 ERC全称 Ethereum Request For Comment (以太坊意见征求稿), 用以记录以太坊上应用级的各种开发标准和协议。如典型的Token标准(ERC20, ERC721)、名字注册(ERC26, ERC13), URI范式(ERC67), Library/Package格式(EIP82), 钱包格式(EIP75,EIP85)。 ERC协议标准是影响以太坊发展的重要因素, 像ERC20, ERC223, ERC721, ERC777等, 都是对以太坊生态产生了很大影响。 所以最终结论:EIP包含ERC。 ERC165 通过ERC165标准,智能合约可以声明它支持的接口,供其他合约检查。简单的说,ERC165就是检查一个智能合约是不是支持了ERC721,ERC1155的接口。 IERC165接口合约只声明了一个supportsInterface函数,输入要查询的interfaceId接口id,若合约实现了该接口id,则返回true: 12345678interface IERC165 { /** * @dev 如果合约实现了查询的`interfaceId`,则返回true * 规则详见:https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * */ function supportsInterface(bytes4 interfaceId) external view returns (bool);} 我们可以看下ERC721是如何实现supportsInterface()函数的: 123456function supportsInterface(bytes4 interfaceId) external pure override returns (bool){ return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC165).interfaceId;} 当查询的是IERC721或IERC165的接口id时,返回true;反之返回false。 IERC721 IERC721是ERC721标准的接口合约,规定了ERC721要实现的基本函数。它利用tokenId来表示特定的非同质化代币,授权或转账都要明确tokenId;而ERC20只需要明确转账的数额即可。123456789101112131415161718192021222324252627282930313233343536373839/** * @dev ERC721标准接口. */interface IERC721 is IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; function safeTransferFrom( address from, address to, uint256 tokenId ) external; function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function setApprovalForAll(address operator, bool _approved) external; function getApproved(uint256 tokenId) external view returns (address operator); function isApprovedForAll(address owner, address operator) external view returns (bool);} IERC721Receiver如果一个合约没有实现ERC721的相关函数,转入的NFT就进了黑洞,永远转不出来了。为了防止误转账,ERC721实现了safeTransferFrom()安全转账函数,目标合约必须实现了IERC721Receiver接口才能接收ERC721代币,不然会revert。IERC721Receiver接口只包含一个onERC721Received()函数。 123456789// ERC721接收者接口:合约必须实现这个接口来通过安全转账接收ERC721interface IERC721Receiver { function onERC721Received( address operator, address from, uint tokenId, bytes calldata data ) external returns (bytes4);} 我们看下ERC721利用_checkOnERC721Received来确保目标合约实现了onERC721Received()函数(返回onERC721Received的selector): 123456789101112131415161718function _checkOnERC721Received( address from, address to, uint tokenId, bytes memory _data) private returns (bool) { if (to.isContract()) { return IERC721Receiver(to).onERC721Received( msg.sender, from, tokenId, _data ) == IERC721Receiver.onERC721Received.selector; } else { return true; }}","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"perceptions","slug":"perception","date":"2023-02-07T05:42:31.000Z","updated":"2024-01-15T07:36:03.604Z","comments":true,"path":"2023/02/07/perception/","link":"","permalink":"http://example.com/2023/02/07/perception/","excerpt":"","text":"快乐需要付出代价,要么遭受苦难,要么透支空虚。 男人总是好为人师,人类总是自以为是。 轻易得到的东西,一定没有价值。 遭受苦难获得价值,遭受的更多,稀缺性更强。 逃避和放弃之间缺少了自洽。 尝试定下目标,完成它的60%。 完成度比完美重要的多。 冒进的话之所以冒进,不是因为话冒进,只是因为情绪和氛围不对。 rimraf node_modules 删除node_modules。 有没有可能,你坚持和守护的东西,都是错的。 犹豫不一定是谎言,快速的回应反而可能是提前准备好的谎言。 了解规则、跳出规则、突破规则。 你不喜欢一个人,不代表你不希望她喜欢你。","categories":[{"name":"随笔","slug":"随笔","permalink":"http://example.com/categories/%E9%9A%8F%E7%AC%94/"}],"tags":[],"author":"Fnkk"},{"title":"solidity advanced study notes","slug":"solidity-study-adanced-notes","date":"2023-02-03T05:35:02.000Z","updated":"2024-01-15T07:36:03.609Z","comments":true,"path":"2023/02/03/solidity-study-adanced-notes/","link":"","permalink":"http://example.com/2023/02/03/solidity-study-adanced-notes/","excerpt":"","text":"接收ETH Solidity支持两种特殊的回调函数,receive()和fallback(),他们主要在两种情况下被使用: 接收ETH 处理合约中不存在的函数调用(代理合约proxy contract) 注意:在solidity 0.6.x版本之前,语法上只有 fallback() 函数,用来接收用户发送的ETH时调用以及在被调用函数签名没有匹配到时,来调用。 0.6版本之后,solidity才将 fallback() 函数拆分成 receive() 和 fallback() 两个函数。 接收ETH函数 receive receive()只用于处理接收ETH。一个合约最多有一个receive()函数,声明方式与一般函数不一样,不需要function关键字:receive() external payable { … }。receive()函数不能有任何的参数,不能返回任何值,必须包含external和payable。 当合约接收ETH的时候,receive()会被触发。receive()最好不要执行太多的逻辑因为如果别人用send和transfer方法发送ETH的话,gas会限制在2300,receive()太复杂可能会触发Out of Gas报错;如果用call就可以自定义gas执行更复杂的逻辑(这三种发送ETH的方法我们之后会讲到)。 我们可以在receive()里发送一个event,例如: 123456// 定义事件event Received(address Sender, uint Value);// 接收ETH时释放Received事件receive() external payable { emit Received(msg.sender, msg.value);} 有些恶意合约,会在receive() 函数(老版本的话,就是 fallback() 函数)嵌入恶意消耗gas的内容或者使得执行故意失败的代码,导致一些包含退款和转账逻辑的合约不能正常工作,因此写包含退款等逻辑的合约时候,一定要注意这种情况。 回退函数 fallback fallback()函数会在调用合约不存在的函数时被触发。可用于接收ETH,也可以用于代理合约proxy contract。fallback()声明时不需要function关键字,必须由external修饰,一般也会用payable修饰,用于接收ETH:fallback() external payable { … }。 我们定义一个fallback()函数,被触发时候会释放fallbackCalled事件,并输出msg.sender,msg.value和msg.data: 1234// fallbackfallback() external payable{ emit fallbackCalled(msg.sender, msg.value, msg.data);} 发送ETHtransfer 用法是接收方地址.transfer(发送ETH数额)。 transfer()的gas限制是2300,足够用于转账,但对方合约的fallback()或receive()函数不能实现太复杂的逻辑。 transfer()如果转账失败,会自动revert(回滚交易)。代码样例,注意里面的_to填ReceiveETH合约的地址,amount是ETH转账金额:1234// 用transfer()发送ETHfunction transferETH(address payable _to, uint256 amount) external payable{ _to.transfer(amount);} sender 用法是接收方地址.send(发送ETH数额)。 send()的gas限制是2300,足够用于转账,但对方合约的fallback()或receive()函数不能实现太复杂的逻辑。 send()如果转账失败,不会revert。 send()的返回值是bool,代表着转账成功或失败,需要额外代码处理一下。代码样例:12345678// send()发送ETHfunction sendETH(address payable _to, uint256 amount) external payable{ // 处理下send的返回值,如果失败,revert交易并发送error bool success = _to.send(amount); if(!success){ revert SendFailed(); }} call 用法是接收方地址.call{value: 发送ETH数额}(“”)。 call()没有gas限制,可以支持对方合约fallback()或receive()函数实现复杂逻辑。 call()如果转账失败,不会revert。 call()的返回值是(bool, data),其中bool代表着转账成功或失败,需要额外代码处理一下。代码样例:12345678// call()发送ETHfunction callETH(address payable _to, uint256 amount) external payable{ // 处理下call的返回值,如果失败,revert交易并发送error (bool success,) = _to.call{value: amount}(""); if(!success){ revert CallFailed(); }} 总结 call没有gas限制,最为灵活,是最提倡的方法; transfer有2300 gas限制,但是发送失败会自动revert交易,是次优选择; send有2300 gas限制,而且发送失败不会自动revert交易,几乎没有人用它。","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"block chain introduction","slug":"blockChain-introduction","date":"2023-02-02T01:38:02.000Z","updated":"2024-01-15T07:36:03.599Z","comments":true,"path":"2023/02/02/blockChain-introduction/","link":"","permalink":"http://example.com/2023/02/02/blockChain-introduction/","excerpt":"","text":"web3和web2的区别 介绍传统的web2应用,阐述web2应用的中心化特点,阐述传统中心化应用的痛点(可以引用暴雪的例子)。引出web3的概念,区块链技术是实现web3的主流方案。 介绍区块链的前世今生,从比特币到以太坊。比特币:数字货币 2008年11月1日,中本聪发布比特币《白皮书》 去中心化的点对点的电子记账系统 账单以谁为准 交易需要手续费,矿工有奖励 以谁为准?挖矿的工作量证明。 如何证明交易是本人的(防伪)? 基于密码学的电子签名。非对称加密。 如何对付双重支付? 如何进行余额检查? 如何防止篡改?最长链原则。 为何要记账 以太坊 metaMask gas 挖矿确认交易 geth客户端 Dapp开发及展示 编译、部署合约 网页和geth交互 web3.js获取合约对象,展示功能","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"solidity study notes","slug":"solidity-study-notes","date":"2023-02-01T09:59:02.000Z","updated":"2024-01-15T07:36:03.611Z","comments":true,"path":"2023/02/01/solidity-study-notes/","link":"","permalink":"http://example.com/2023/02/01/solidity-study-notes/","excerpt":"","text":"solidit 入门数值类型Solidity中的变量类型 数值类型(Value Type):包括布尔型,整数型等等,这类变量赋值时候直接传递数值。 引用类型(Reference Type):包括数组和结构体,这类变量占空间大,赋值时候直接传递地址(类似指针)。 映射类型(Mapping Type): Solidity里的哈希表。 函数类型(Function Type):Solidity文档里把函数归到数值类型,但我觉得他跟其他类型差别很大,所以单独分一类。 数值类型 布尔型取值为true和false布尔值的运算符和js相似 整型常用包括// 整型 int public _int = -1; // 整数,包括负数 uint public _uint = 1; // 正整数 uint256 public _number = 20220330; // 256位正整数 地址类型地址类型(address)存储一个 20 字节的值(以太坊地址的大小)。地址类型也有成员变量,并作为所有合约的基础。有普通的地址和可以转账ETH的地址(payable)。其中,payable修饰的地址相对普通地址多了transfer和send两个成员。在payable修饰的地址中,send执行失败不会影响当前合约的执行(但是返回false值,需要开发人员检查send返回值)。balance和transfer(),可以用来查询ETH余额以及安全转账(内置执行失败的处理)。 // 地址 address public _address = 0x7A58c0Be72BE218B41C608b7Fe7C5bB630736C71; address payable public _address1 = payable(_address); // payable address,可以转账、查余额 // 地址类型的成员 uint256 public balance = _address1.balance; // balance of address 定长字节数组字节数组bytes分两种,一种定长(byte, bytes8, bytes32),另一种不定长。定长的属于数值类型,不定长的是引用类型(之后讲)。 定长bytes可以存一些数据,消耗gas比较少。 // 固定长度的字节数组 bytes32 public _byte32 = "MiniSolidity"; bytes1 public _byte = _byte32[0]; MiniSolidity变量以字节的方式存储进变量_byte32,转换成16进制为:0x4d696e69536f6c69646974790000000000000000000000000000000000000000 _byte变量存储_byte32的第一个字节,为0x4d。5. 枚举 enum枚举(enum)是solidity中用户定义的数据类型。它主要用于为uint分配名称,使程序易于阅读和维护。它与C语言中的enum类似,使用名称来代替从0开始的uint: // 用enum将uint 0, 1, 2表示为Buy, Hold, Sell enum ActionSet { Buy, Hold, Sell } // 创建enum变量 action ActionSet action = ActionSet.Buy;它可以显式的和uint相互转换,并会检查转换的正整数是否在枚举的长度内,不然会报错: // enum可以和uint显式的转换 function enumToUint() external view returns(uint){ return uint(action); } 函数类型 function:声明函数时的固定用法,想写函数,就要以function关键字开头。 :函数名。 ():圆括号里写函数的参数,也就是要输入到函数的变量类型和名字。 {internal|external|public|private}:函数可见性说明符,一共4种。没标明函数类型的,默认public。合约之外的函数,即”自由函数”,始终具有隐含internal可见性。 public: 内部外部均可见。 private: 只能从本合约内部访问,继承的合约也不能用。 external: 只能从合约外部访问(但是可以用this.f()来调用,f是函数名)。 internal: 只能从合约内部访问,继承的合约可以用。 Note 1: 没有标明可见性类型的函数,默认为public。 Note 2: public|private|internal 也可用于修饰状态变量。 public变量会自动生成同名的getter函数,用于查询数值。 Note 3: 没有标明可见性类型的状态变量,默认为internal。 [pure|view|payable]:决定函数权限/功能的关键字。payable(可支付的)很好理解,带着它的函数,运行的时候可以给合约转入ETH。pure和view的介绍见下一节。 [returns ()]:函数返回的变量类型和名称。 函数输出变量存储和作用域数据位置 solidity数据存储位置有三类:storage,memory和calldata。不同存储位置的gas成本不同。storage类型的数据存在链上,类似计算机的硬盘,消耗gas多;memory和calldata类型的临时存在内存里,消耗gas少。大致用法: storage:合约里的状态变量默认都是storage,存储在链上。 memory:函数里的参数和临时变量一般用memory,存储在内存中,不上链。 calldata:和memory类似,存储在内存中,不上链。与memory的不同点在于calldata变量不能修改(immutable),一般用于函数的参数。 引用类型数组 Array 数组(Array)是solidity常用的一种变量类型,用来存储一组数据(整数,字节,地址等等)。数组分为固定长度数组和可变长度数组两种: 固定长度数组:在声明时指定数组的长度。用T[k]的格式声明,其中T是元素的类型,k是长度,例如: 1234// 固定长度 Arrayuint[8] array1;bytes1[5] array2;address[100] array3; 可变长度数组(动态数组):在声明时不指定数组的长度。用T[]的格式声明,其中T是元素的类型,例如: 12345// 可变长度 Arrayuint[] array4;bytes1[] array5;address[] array6;bytes array7; 注意: bytes比较特殊,是数组,但是不用加[]。另外,不能用byte[]声明单字节数组,可以使用bytes或bytes1[]。在gas上,bytes比bytes1[]便宜。因为bytes1[]在memory中要增加31个字节进行填充,会产生额外的gas。但是在storage中,由于内存紧密打包,不存在字节填充。 数组创建过程 在solidity里,创建数组有一些规则: 对于memory修饰的动态数组,可以用new操作符来创建,但是必须声明长度,并且声明后长度不能改变。例子:123// memory动态数组uint[] memory array8 = new uint[](5);bytes memory array9 = new bytes(9); 数组字面常数(Array Literals)是写作表达式形式的数组,用方括号包着来初始化array的一种方式,并且里面每一个元素的type是以第一个元素为准的,例如[1,2,3]里面所有的元素都是uint8类型,因为在solidity中如果一个值没有指定type的话,默认就是最小单位的该type,这里int的默认最小单位类型就是uint8。而[uint(1),2,3]里面的元素都是uint类型,因为第一个元素指定了是uint类型了,我们都以第一个元素为准。 下面的合约中,对于f函数里面的调用,如果我们没有显式对第一个元素进行uint强转的话,是会报错的,因为如上所述我们其实是传入了uint8类型的array,可是g函数需要的却是uint类型的array,就会报错了。1234567891011// SPDX-License-Identifier: GPL-3.0pragma solidity >=0.4.16 <0.9.0;contract C { function f() public pure { g([uint(1), 2, 3]); } function g(uint[3] memory) public pure { // ... }} 如果创建的是动态数组,你需要一个一个元素的赋值。1234uint[] memory x = new uint[](3);x[0] = 1;x[1] = 3;x[2] = 4; 数组成员 length: 数组有一个包含元素数量的length成员,memory数组的长度在创建后是固定的。 push(): 动态数组和bytes拥有push()成员,可以在数组最后添加一个0元素。 push(x): 动态数组和bytes拥有push(x)成员,可以在数组最后添加一个x元素。 pop(): 动态数组和bytes拥有pop()成员,可以移除数组最后一个元素。 结构体 Struct Solidity支持通过构造结构体的形式定义新的类型。创建结构体的方法:12345// 结构体struct Student{ uint256 id; uint256 score; } 映射类型常数 constant和immutable","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"writing English","slug":"EnglishLearning","date":"2023-02-01T01:38:02.000Z","updated":"2024-01-15T07:36:03.593Z","comments":true,"path":"2023/02/01/EnglishLearning/","link":"","permalink":"http://example.com/2023/02/01/EnglishLearning/","excerpt":"","text":"Junethird week sexy topic Do you have any resentment towards your fisrt night boy? Julysecond week new words by reading eclectic 不拘一格的 Every magazine I read allowed me to enjoy news, and gain information from an eclectic range of articles. piling up 堆积 Magazines were piling up in the corner of my room. laptop 笔记本电脑 tablet 平板 individual 个性化的 dynamics 动态 Winning someone’s heart is a complex and individual process, as it depends on the person and the dynamics of your relationship. general 普遍性的 However, here are some general tips to help you. genuine 友善的 Authenticity 真实性 Authenticity goes a long way in building a meaningful connection. attentive 细心的 strive 努力 perspective 远景,这里指观点 Express yourself clearly, be attentive, and strive to understand her perspective. aspirations 愿望、志向 passions 激情 trustworthy 值得信赖的 count on you 依靠你 boundaries 边界 affection 感情 compliments 赞扬 gestures 手势 appreciated 欣赏 Express your affection in meaningful ways, such as through compliments, gestures, and acts of kindness. Make her feel appreciated and valued. approach 方法 Remember that each person is unique, so it’s important to get to know her, be attentive to her needs, and adapt your approach accordingly. employ 这里指运用 seduce 勾引 casual 随意的 encounter 遭遇 PUA stands for “Pick-Up Artist.” It refers to individuals who study and employ techniques and strategies to attract and seduce romantic partners, particularly in the context of short-term or casual encounters. manipulation 操控 dynamics 动态 pursuit 消遣、爱好、追求 PUA techniques often focus on psychological manipulation, social dynamics, and self-improvement exercises to increase one’s chances of success in romantic pursuits. promote 促进 manipulative 操控的 tactic 计谋、策略 objectify 物化 mutual 相同的(mutual respect 相互尊重) consent 同意 ethical 道德的 sustainable 可持续的 However, it’s worth noting that the PUA community has faced criticism for promoting manipulative tactics and objectifying individuals. Many argue that building healthy, genuine connections based on mutual respect and consent is a more ethical and sustainable approach to relationships. It’s important to consider the ethics and values behind any approach to dating and personal interactions. new words try a new way Avoid stereotypes or discrimination based on gender and believe that each person has unique contributions and abilities. stereotype 刻板印象 discrimination 歧视 foster camaraderie.foster 培养、培育 camaraderie 友情 Avoid favoritism or excluding anyone.favoritism 偏袒 exclude 排除、排挤 Respect each other’s personal space and privacy. space 空格、空间 privacy 隐私 Avoid excessive interference or asking overly personal questions. excessive 过度的 interference 干涉 While it is not meant to be taken literally, apples are a nutritious fruit that can contribute to a healthy diet. literally 字面意思地 diet 饮食 Having a pleasurable sexual experience with your partner is a collaborative and intimate process. collaborative 合作的 intimate 亲密的 He confessed to the murders of at least 30 young women and girls, although the actual number of his victims is unknown. confess 承认 confessed 公开的 murder 谋杀 victim 受害者 Bundy was known for his charm and good looks, which he used to gain the trust of his victims before abducting and killing them. charm 魅力 cruel 残忍 abduct 拐、绑架 He was eventually captured, convicted, and sentenced to death.eventually 最终 capture 捕捉 convict 定罪 sentence 句子、判处 Bundy’s case and his charismatic personality have made him one of the most infamous serial killers in American history.charismatic 旖旎、神赐的 infamous 臭名昭著的 serial 连续的 However, he had a troubled childhood, with some reports suggesting that he exhibited signs of violence and disturbing behavior from a young age.exhibit 展示 disturbing 烦扰的、令人不安的 He would often approach his victims in public places, pretending to be injured or in need of assistance. pretend 假装 Once he gained their trust, he would overpower them and take them to secluded locations where he would assault and kill them.overpower 压倒 secluded 僻静的 assault 突击 Despite being a suspect in several disappearances, Bundy managed to evade capture for years.suspect 怀疑、可疑的、嫌疑人 several 几个 disappearance 消失,这里指失踪案 evade 逃避 He moved across different states, committing murders in Washington, Oregon, Utah, and Colorado. However, his luck eventually ran out when he was arrested in 1975 for a traffic violation.traffic violation 交通违规 ran out 耗尽 He would sometimes pretend to be a police officer or use his charm to manipulate them.manipulate 操纵 He was known for his ability to blend in and appear non-threatening, which allowed him to continue his crimes for an extended period.to blend in 融入 threatening 威胁性 extended 长期的 While in custody, Bundy was linked to multiple murders through physical evidence and witness testimonies. He was put on trial for the murder of two women in Florida and was found guilty.custody 拘留 testimony 证词 trial 审判 guilty 有罪的 Bundy was sentenced to death and spent years appealing his conviction.appeal 呼吁、上诉 conviction 定罪 He became infamous for his charisma and ability to captivate the public and media.charisma 魅力 captivate 使着迷 media 媒体 His case and the details of his crimes continue to fascinate and horrify people to this day. Bundy’s story has been the subject of numerous books, documentaries, and films, cementing his status as one of the most notorious serial killers in history.horrify 恐惧 cementing 巩固 notorious 臭名昭著的 new words by new way at Thirteenth Census records reveal that several men by the name of John Worthington and Lloyd Marshall lived near Louise when Bundy was conceived. census 人口普查 record 记录 reveal 揭示、泄露 conceive 怀孕、设想、构想 Bundy expressed a lifelong resentment toward his mother for never talking to him about his real father, and for leaving him to discover his true parentage for himself. lifelong 终身的 resentment 怨恨 parentage 亲子关系 leave sb to do sth. 让某人做某事 He also occasionally exhibited disturbing behavior at an early age. occasionally 偶尔 occasion 场合 exhibit 展示 prohibit 禁止 disturbing 令人不安 Louise’s younger sister, Julie Cowell, recalled awakening from a nap to find herself surrounded by knives from the kitchen, and 3-year-old Ted standing by the bed, smiling. recall 回忆起 awakening 睡醒 He liked to inflict pain and suffering and fear. inflict 使遭受打击 suffering 苦楚、痛苦 In some interviews, Bundy spoke warmly of his grandparents and told Rule that he “identified with,” “respected,” and “clung to” his grandfather. identified with 相同于、认同 identified 确认、鉴定、认出 clung to 牢牢抓住、依恋 In 1987, however, he and other family members told attorneys that Samuel was a tyrannical bully who beat his wife and dog, swung neighborhood cats by their tails, and expressed racist and xenophobic attitudes. attorney 律师 tyrannical 残暴的、专横的 bully 恶霸 beat 打 swung swing的过去分词,摇摆、甩 tail 尾巴 racist 种族主义的 xenophobic 排外的 attitude 态度 He would sometimes speak aloud to unseen presences,and at least once flew into a violent rage when the question of Bundy’s paternity was raised. unseen 看不见的 presence 出席、存在、感觉在附近的人 fly into 爆发 rage 愤怒 violent rage 暴怒 paternity 父亲的身份 Bundy described his grandmother as a timid and obedient woman who periodically underwent electroconvulsive therapy for depression and feared to leave their house toward the end of her life. timid 胆怯的 obedient 唯命是从的 periodically 定期地 underwent 经历 electroconvulsive 电惊厥的 therapy 治疗 depression 沮丧、抑郁症 These descriptions of Bundy’s grandparents have been questioned in more recent investigations.question 动词:质疑 investigation 侦察 Some locals remembered Samuel as a “fine man”, if a bit eccentric, and expressed bewilderment at the reports of him being violent.eccentric 古怪的 bewilderment 困惑 being 存在 new words at Fourth week Be confident but not arrogant: Confidence can be attractive, but avoid coming across as overly cocky or boastful. arrogant 傲慢的、自大的 attractive 有吸引力的 attack 攻击 attach 系上、把…附 cocky 自大的 boastful 自夸的 come across as 给人…的印象 “The characterization that Sam was a raging alcoholic and animal abuser was a convenient characterization used to make people justify why Ted was the way he was,” said one of Bundy’s cousins. characterization 刻画、塑造 raging 严重的 alcoholic 酒精的;嗜酒如命者 abuser 施暴者 justify 证明…正确 Septembersecond week To Michaud and Aynesworth, he described roaming his neighborhood, picking through trash barrels in search of pictures of naked women and to attorney and author Polly Nelson he said that he perused detective magazines, and crime novels for stories that involved sexual violence, particularly when the stories were illustrated with pictures of dead or maimed women. roam 漫步、游荡、闲逛 barrel 桶、一桶 naked 裸体的 peruse 精读 persuade 说服 detective 侦探 illustrate 给…插图、说明 maim 使残废 dead 做名词时,表示死人;death是死亡; third week In a letter to Rule, however, he asserted that he “never, ever read fact-detective magazines, and shuddered at the thought that anyone would. assert 声称、宣称 shudder 打颤、发抖 He once told Michaud that he would consume large quantities of alcohol and “canvass the community” late at night in search of undraped windows where he could observe women undressing, or “whatever could be seen.” canvass 拉票、游说 undraped 未用布遮盖的 drape 悬挂、遮住 “He hung one of the stray cats in the neighborhood from one of the clothes lines in the backyard, doused it in lighter fluid and set it on fire and I heard that cat squealing.” stray cat 流浪猫 douse 倒…液体 in lighter 打火机 fluid 液体 squealing 尖叫、告发、告密 One little girl went over the top of one of Ted’s tiger traps and got the whole side of her leg slit open with the sharpened point of the stick that she landed on. trap 陷阱 slit 一道长口 sharp 锐利的 sharpen 锐化 land on 着陆 He told journalists Michaud and Aynesworth that he “chose to be alone” as an adolescent because he was unable to understand interpersonal relationships journalist 记者 adolescent 青少年 interpersonal 人际的 Octoberlast week Blockchain is a decentralized distributed ledger technology that uses encryption algorithms to package transaction records into blocks and link them in chronological order to form an immutable chain structure. In simple terms, it allows everyone to maintain the same ledger, achieving value immutability in an Internet where information can be replicated. decentralized 去中心化的 distribute 分发 ledger 账本 encryption 加密 algorithm 算法 transaction 交易 chronological 按时间顺序的 immutable 不可变的 term 条款、说辞 immutability 不变 replicate 复制、再生 To ensure a low entry barrier for participation, Bitcoin controls the block generation time for the entire network to approximately 10 minutes, resulting in an average Transactions Per Second (TPS) in the single digits. Ethereum has a block generation time of about 12 seconds, with an average TPS of only a few dozen. This falls short compared to the economic activities of traditional Web2. barrier 障碍 digit 个位数、手指、脚趾 dozen 一打、十来个 After understanding the fundamental principles of blockchain, we naturally consider the following two approaches to enhance performance: fundamental 基本的 principle 原理 approach n.方法 v.接近 Increase the size of individual blocks to accommodate more transactions. This approach leads to rapid bloating of the blockchain ledger, requiring increasingly higher performance from participating validating machines, raising the entry barrier, and gradually reducing the decentralization and security of the entire network. Bitcoin Cash (BCH), which forked from Bitcoin, increased the block size from 1MB to 32MB, while Bitcoin Satoshi’s Vision (BSV) even more aggressively removed the block size limit, allowing an unlimited amount of information to be incorporated into a block. accommodate 容纳 rapid 快速的 bloat 膨胀 aggressively 有进攻性地 incorporate 合并 Decrease the block generation time and aim to generate more blocks within a certain period to process more transactions. This approach imposes higher requirements on the network conditions of nodes, increasing the entry barrier. It also affects the stability of data synchronization across the network because node clusters physically far apart are prone to divergent opinions on the latest blocks, leading to forks. Forked chains need to compete to produce a new longest chain, discarding one branch and resulting in the rewriting of many transactions during a certain period, known as “block reorganization”. Polygon experienced 157 block reorganization events in 2023. impose 强制执行 affect 影响 synchronization 同步 cluster 集群 prone 易遭受的 divergent 有分歧的","categories":[{"name":"生活","slug":"生活","permalink":"http://example.com/categories/%E7%94%9F%E6%B4%BB/"}],"tags":[],"author":"Fnkk"},{"title":"writing English","slug":"EnglishPractice","date":"2023-02-01T01:38:02.000Z","updated":"2024-01-15T07:36:03.594Z","comments":true,"path":"2023/02/01/EnglishPractice/","link":"","permalink":"http://example.com/2023/02/01/EnglishPractice/","excerpt":"","text":"SeptemberSecond week 自信但不傲慢:自信可能很有吸引力,但不要给人留下过于自大或自吹自擂的印象。 Be confident but not arrogant: Confidence can be attractive, but avoid coming across as overly cocky and boastful. Be confident but not arrogant: Confidence can be attractive, but avoid coming across as overly cocky and boastful. Be confident but not arrogant: Confidence can be attractive but avoid coming across as overly cocky and boastful. Be confident but not arrogant: Confidence can be attractive, but avoid coming across as overly cocky and boastful. 然而,1987年,他和其他家庭成员告诉律师,塞缪尔是一个暴虐的恶霸,他殴打妻子和狗,用邻居的猫甩尾巴,并表达种族主义和仇外态度。 In 1987, however, he and other family members told attorneys that Samuel was a tyrannical bully who beat his wife and dog, swung neighborhood cats by their tails, and expressed racist and xenophobic attitudes. In 1987, however, he and other family members told atterneys that Samuel was a tyrannical bully who beat his wife and dog, swung neighborhood cats by thier tails, and expressed racist and xenophobic attitudes. In 1987, however, he and other family members told atterneys that Samuel was a tyrannical bully who beat his wife and dog, swung neighborhood cats by thier tails, and expressed racist and xenophobic attitudes. In 1987, however, he and other family members told atterneys that Samuel was a tyrannical bully who beat his wife and dog, swung neighborhood cats by their tails, and expressed racist and xenophobic attitudes. “将Sam描绘成一个狂暴的酗酒者和虐待动物者是一种方便的描述,用来让人们证明泰德为什么会是这样,”Bunndy的一个堂兄弟说。 “The characterization that Sam was a raging alcoholic and animal abuser was a convenient characterization used to make people justify why Ted was the way he was,” said one of Bundy’s cousins. “The characterization that Sam was a raging alcoholic and animal abuser was a convenient characterization used to make people justify why Ted was the way he was,” said one of Bunndy’s consins. “The characterization that Sam was a raging alcoholic and animal abuser was a convenient characterization used to make people justify why Ted was the way he was”, said one of Bunndy’s consins. “The characterization that Sam was a raging alcoholic and animal abuser was a convenient characterization used to make people justify why Ted was the way he was”, said one of Bunndy’s consins. 他向Michaud和Aynesworth描述了自己在附近游荡,在垃圾桶里搜寻裸体女性的照片。他向律师兼作家Polly Nelson描述了自己阅读侦探杂志和犯罪小说,寻找涉及性暴力的故事,尤其是当故事中有死亡或致残女性的照片时。 To Michaud and Aynesworth, he described roaming his neighborhood, picking through trash berrels in search of pictures of naked women and to attorney and author Polly Nelson he said that he peruse detective magazines and crime novels for stories that involved sexual violence, particularly when the stories were illustrated with pictures of dead or maimed women. To Michaud and Aynesworth, he described roaming his neighborhood, picking through trash barrels in search of pictures of naked women and to attorney and author Polly Nelson he said that he perused detective magazines, and crime novels for stories that involved sexual violence, particularly when the stories were illustrated with pictures of dead or maimed women. To Michaud and Aynesworth, he described roaming his neighborhood, picking through trash barrels in search of pictures of naked women and to attorney and author Polly Nelson he said that he perused detective magazines, and crime novels for stories that involved sexual violence, particularly when the stories were illustrated with pictures of dead or maimed women. To Michaud and Aynesworth, he described roaming his neighborhood, picking through trash barrels in search of pictures of naked women and to attorney and author Polly Nelson he said that he perused detective magazines and crime novels for stories that involved sexual violence, particularly when the stories were illustrated with pictures of dead or maimed women. 一个小女孩越过Ted的一个老虎陷阱的顶部,用她落在上面的棍子的尖锐尖端划开了她的整条腿。 One little girl went over the top of one of Ted’s tiger traps and got the whole side of her leg slit open with the sharpened point of the stick that she landed on. 前后缀名词后缀 -ion(前接动词) -ant xx的人(前接词根) -or -er xx者(前接动词) -itude xx度 (前接词根)altitude -us (前接词根) -ule -ence(前接名词) -ess (前接动词)女XX -est 形容词后缀 -ant xx的(前接词根) -org xx的(前接动词) -arg xx的(前接名词) -ed xx的(前接名词) -able 能够xx的(前接名词) -ent (前接名词) -al xx的(前接名词) -ity xx的(状态) activity -less 没有XX的 useless -ous 多XX的 动词后缀 -ate -ize 使xx 动词前缀 im- 进入(后接动词/名词/形容词) immigrate/immigration/immigrant 移居进入(的人) e- 向外 in- 向内、加强、不XX(表示否定)、使… ab- 加强 red- 加强 de- 去除 re- 重新 ex- 使 词根 dur 久 alt 变、高 dol 悲伤 migr 迁徙、移居 holic 喜欢的 tango/tangle 纠缠 fla 呼啦、吹气、风 und 充溢 err 错误 labor 劳动 am 爱慕 jelly 果冻、胶状物 ee 被动方 conq 攻克 bhor 不喜欢 vita 命 haus 耗尽 mon 一、专 vigor 精力","categories":[{"name":"生活","slug":"生活","permalink":"http://example.com/categories/%E7%94%9F%E6%B4%BB/"}],"tags":[],"author":"Fnkk"},{"title":"react hook learning notes","slug":"react-hook","date":"2023-02-01T01:38:02.000Z","updated":"2024-01-15T07:36:03.607Z","comments":true,"path":"2023/02/01/react-hook/","link":"","permalink":"http://example.com/2023/02/01/react-hook/","excerpt":"","text":"react hook学习笔记useState 需要使用变量时,通过解构的方式使用useState(),参数为变量的初始值const [productId, setProductId] = useState(); setProductId(更新数据)的两种方式 直接调用函数传入新值,如setProductId(newVal) 使用函数式更新,如setProductId(()=>{return newVal}) 如果定义的是引用类型变量如const [teacher, setTeacher] = useState({name:'Ryan',sex:'man'}),更新时可以使用函数式更新并借助拓展运算符,如setTeacher(()=>{return {...teacher,name:'Chris'}}),把新的属性合并到新的对象中 useState惰性初始化 惰性state initialState 参数只会在组件的初始渲染中起作用,后续渲染会被忽略 复杂初始state的定义 初始state需要通过复杂计算获得,则可以传入一个函数,在函数中计算并返回初始的 state 如果更新的数据与上次一样,React 将跳过子组件的渲染及 effect 的执行 useContext 把需要父子组件通信的数据使用createContext函数创建 在父组件中使用.Provider包裹子组件,把需要传递的数据通过父组件的value属性传递 在子组件中使用useContext方法获取到value传递的值 useEffect React在完成对DOM的更新后会执行,默认情况下,React会在每次渲染后调用副作用函数,包括第一次渲染的时候 useEffect有两个参数,第一个参数是副作用的处理函数,第二参数是在与该副作用关联的状态或属性依赖数组 第二个参数为空数组时,表示该副作用函数不依赖任何值的变化,只在组件渲染后执行一次 useEffect相当于Vue生命周期中的mouted,在组件渲染后执行,它的return函数相当于destroy在下次渲染前执行 useReducer useReducer接收3个参数,第一个参数是处理状态更新的reducer,第二个参数是状态初始值,第三个参数是状态初始化函数const [state, dispathch] = userReducer(reducer, initialArg, init); 指定初始state 将初始state作为第二个参数传入 1234const [state, dispatch] = useReducer( reducer, {count: initialCount}) 惰性初始化, 将第二个参数作为第三个函数入参传入 1 useCallback useMemo useMemo传入的函数内部需要有返回值 useMemo只能声明在函数式组件内部 react-route","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"every week to do list","slug":"todoList","date":"2023-02-01T01:38:02.000Z","updated":"2024-01-15T07:36:03.612Z","comments":true,"path":"2023/02/01/todoList/","link":"","permalink":"http://example.com/2023/02/01/todoList/","excerpt":"","text":"Junethe third week read Freud’s works no go to Wanli University gym to exercise yes pick up a girl no stop watching game videos yes sort out graduation photos no make a dating wether success or failure no tidy the room no Thursday I haven’t completed even one thing among these seven goals.But I feeling better today because I didn’t use WePoker today. I haven’t completed even a single task among these seven goals. October typescript tailwindcss 10.23打卡学习,基本了解能看得懂 thirdweb styled-components vite github hardhat nextjs","categories":[{"name":"生活","slug":"生活","permalink":"http://example.com/categories/%E7%94%9F%E6%B4%BB/"}],"tags":[],"author":"Fnkk"},{"title":"git common commands","slug":"git-common-commands","date":"2023-01-30T01:38:01.000Z","updated":"2024-01-15T07:36:03.602Z","comments":true,"path":"2023/01/30/git-common-commands/","link":"","permalink":"http://example.com/2023/01/30/git-common-commands/","excerpt":"","text":"","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[],"author":"Fnkk"},{"title":"truffleUseMap","slug":"truffleUseMap","date":"2023-01-30T01:38:01.000Z","updated":"2024-01-15T07:36:03.613Z","comments":true,"path":"2023/01/30/truffleUseMap/","link":"","permalink":"http://example.com/2023/01/30/truffleUseMap/","excerpt":"","text":"Truffle使用笔记geth相关geth常用命令 geth启动命令 geth --datadir data --networkid 666 --http --http.port 8545 --allow-insecure-unlock console 2>output.log console geth启动命令(开启WS服务,默认端口8456) geth --datadir data --networkid 666 --ws --http --http.port 8545 --allow-insecure-unlock console 2>output.log console geth解锁账号 personal.unlockAccount('account') 然后输入密码 1234 定义一定金额 单位Wei这里的数字采用字符串的形式输入,避免精度丢失 amt_1 = web3.utils.toWei('1', 'ether'); geth转账ETH eth.sendTransaction({from:a,to:b,value:web3.toWei(20,"ether")}) wei转ether web3.fromWei(numer,'ether') data 文件夹大小 5.35/5.44MB 5.10/7.62MB 8.76/8.82MB truffle相关truffle部署测试流程 编译好合约后,使用命令truffle migration或者truffle depoly迁移(部署)合约,需要启动geth客户端,同时解锁账户,开始挖矿 部署完成后,使用命令turflle console进入js 控制台,控制台中有migrations里定义的对象,可以调用对象的deploy方法的回调测试合约的函数,如EcommerceStore.deployed().then(function(i) {i.getProduct.call(1).then(function(f) {console.log(f)})}) solidity相关 高版本的solidity中,强制要求所有string类型后面加上memory now关键字已废用,采用block.timestamp代替 需要transfer的地址要加上payable关键字 keccak256用法result = keccak256(abi.encodePacked(value, fake, secret)) truffle-box-react相关 合约交互代码写在ContractBtns组件中 Take a look at client/src/contexts/EthContext. This context maintains a global state and provides web3.js functionalities to the rest of the app. node + mongo 的链下生态 第二个视频 19分 定义mongoose相关 研究方法 基于ERC-721的非同质化货币铸造的研究。数字藏品交易系统中的数字藏品就是一个非同质化货币,ERC721是一种以太坊代币标准,它是一种非同质化代币智能合约标准接口。因此,只要重写该接口的方法,就能初步完成铸造,使数字藏品获得唯一的标识符(token ID),和确权交易等功能,可以在此基础上完成盲盒、空投、拍卖等其他复杂功能。 基于geth客户端的区块链环境。geth是以太坊客户端之一,通过运行geth节点,用户可以访问以太坊网络,并可以进行交易、挖矿、部署智能合约等操作。通过geth客户端在本地生成一条以太坊私链,用于部署智能合约。geth还提供了一些常用的命令行工具,如管理账户、查询交易历史、查看节点同步状态等。 基于IFPS的资源去中心化存储。由于数字藏品交易系统有大量的图片资源,这些占用大量存储空间的资源直接存入区块链的话效率低且消耗大量gas。IFPS是一个点对点的分布式文件系统,它的设计理念和技术架构对于实现分布式的、去中心化的应用程序非常有帮助。我们将这些占用大量存储空间的资源上传到IFPS中,它会返回一个哈希,我们只将这个哈希存到区块链中,在前端页面中通过这个哈希去找到对应的资源。","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"web","slug":"web","permalink":"http://example.com/tags/web/"}],"author":"Fnkk"},{"title":"Hexo-Theme-Sakura","slug":"Hexo-Theme-Sakura","date":"2018-12-12T14:16:01.000Z","updated":"2024-01-16T03:08:58.962Z","comments":true,"path":"2018/12/12/Hexo-Theme-Sakura/","link":"","permalink":"http://example.com/2018/12/12/Hexo-Theme-Sakura/","excerpt":"","text":"hexo-theme-sakura主题 English document 基于WordPress主题Sakura修改成Hexo的主题。 demo预览 正在开发中…… 交流群若你是使用者,加群QQ: 801511924 若你是创作者,加群QQ: 194472590 主题特性 首页大屏视频 首页随机封面 图片懒加载 valine评论 fancy-box相册 pjax支持,音乐不间断 aplayer音乐播放器 多级导航菜单(按现在大部分hexo主题来说,这也算是个特性了) 赞赏作者如果喜欢hexo-theme-sakura主题,可以考虑资助一下哦~非常感激! paypal | Alipay 支付宝 | WeChat Pay 微信支付 未完善的使用教程那啥?老实说我目前也不是很有条理233333333~ 1、主题下载安装hexo-theme-sakura建议下载压缩包格式,因为除了主题内容还有些source的配置对新手来说比较太麻烦,直接下载解压就省去这些麻烦咯。 下载好后解压到博客根目录(不是主题目录哦,重复的选择替换)。接着在命令行(cmd、bash)运行npm i安装依赖。 2、主题配置博客根目录下的_config配置站点 12345678# Sitetitle: 你的站点名subtitle:description: 站点简介keywords:author: 作者名language: zh-cntimezone: 部署 123456deploy: type: git repo: github: 你的github仓库地址 # coding: 你的coding仓库地址 branch: master 备份 (使用hexo b发布备份到远程仓库) 12345678backup: type: git message: backup my blog of https://honjun.github.io/ repository: # 你的github仓库地址,备份分支名 (建议新建backup分支) github: https://github.com/honjun/honjun.github.io.git,backup # coding: https://git.coding.net/hojun/hojun.git,backup 主题目录下的_config配置其中标明【改】的是需要修改部门,标明【选】是可改可不改,标明【非】是不用改的部分 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121# site name# 站点名 【改】prefixName: さくら荘そのsiteName: hojun# favicon and site master avatar# 站点的favicon和头像 输入图片路径(下面的配置是都是cdn的相对路径,没有cdn请填写完整路径,建议使用jsdeliver搭建一个cdn啦,先去下载我的cdn替换下图片就行了,简单方便~)【改】favicon: /images/favicon.icoavatar: /img/custom/avatar.jpg# 站点url 【改】url: https://sakura.hojun.cn# 站点介绍(或者说是个人签名)【改】description: Live your life with passion! With some drive!# 站点cdn,没有就为空 【改】 若是cdn为空,一些图片地址就要填完整地址了,比如之前avatar就要填https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/custom/avatar.jpgcdn: https://cdn.jsdelivr.net/gh/honjun/[email protected]# 开启pjax 【选】pjax: 1# 站点首页的公告信息 【改】notice: hexo-Sakura主题已经开源,目前正在开发中...# 懒加载的加载中图片 【选】lazyloadImg: https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/loader/orange.progress-bar-stripe-loader.svg# 站点菜单配置 【选】menus: 首页: { path: /, fa: fa-fort-awesome faa-shake } 归档: { path: /archives, fa: fa-archive faa-shake, submenus: { 技术: {path: /categories/技术/, fa: fa-code }, 生活: {path: /categories/生活/, fa: fa-file-text-o }, 资源: {path: /categories/资源/, fa: fa-cloud-download }, 随想: {path: /categories/随想/, fa: fa-commenting-o }, 转载: {path: /categories/转载/, fa: fa-book } } } 清单: { path: javascript:;, fa: fa-list-ul faa-vertical, submenus: { 书单: {path: /tags/悦读/, fa: fa-th-list faa-bounce }, 番组: {path: /bangumi/, fa: fa-film faa-vertical }, 歌单: {path: /music/, fa: fa-headphones }, 图集: {path: /tags/图集/, fa: fa-photo } } } 留言板: { path: /comment/, fa: fa-pencil-square-o faa-tada } 友人帐: { path: /links/, fa: fa-link faa-shake } 赞赏: { path: /donate/, fa: fa-heart faa-pulse } 关于: { path: /, fa: fa-leaf faa-wrench , submenus: { 我?: {path: /about/, fa: fa-meetup}, 主题: {path: /theme-sakura/, fa: iconfont icon-sakura }, Lab: {path: /lab/, fa: fa-cogs }, } } 客户端: { path: /client/, fa: fa-android faa-vertical } RSS: { path: /atom.xml, fa: fa-rss faa-pulse }# Home page sort type: -1: newer first,1: older first. 【非】homePageSortType: -1# Home page article shown number) 【非】homeArticleShown: 10# 背景图片 【选】bgn: 8# startdash面板 url, title, desc img 【改】startdash: - {url: /theme-sakura/, title: Sakura, desc: 本站 hexo 主题, img: /img/startdash/sakura.md.png} - {url: http://space.bilibili.com/271849279, title: Bilibili, desc: 博主的b站视频, img: /img/startdash/bilibili.jpg} - {url: /, title: hojun的万事屋, desc: 技术服务, img: /img/startdash/wangshiwu.jpg}# your site build time or founded date# 你的站点建立日期 【改】siteBuildingTime: 07/17/2018# 社交按钮(social) url, img PC端配置 【改】social: github: {url: http://github.com/honjun, img: /img/social/github.png} sina: {url: http://weibo.com/mashirozx?is_all=1, img: /img/social/sina.png} wangyiyun: {url: http://weibo.com/mashirozx?is_all=1, img: /img/social/wangyiyun.png} zhihu: {url: http://weibo.com/mashirozx?is_all=1, img: /img/social/zhihu.png} email: {url: http://weibo.com/mashirozx?is_all=1, img: /img/social/email.svg} wechat: {url: /#, qrcode: /img/custom/wechat.jpg, img: /img/social/wechat.png}# 社交按钮(msocial) url, img 移动端配置 【改】msocial: github: {url: http://github.com/honjun, fa: fa-github, color: 333} weibo: {url: http://weibo.com/mashirozx?is_all=1, fa: fa-weibo, color: dd4b39} qq: {url: https://wpa.qq.com/msgrd?v=3&uin=954655431&site=qq&menu=yes, fa: fa-qq, color: 25c6fe}# 赞赏二维码(其中wechatSQ是赞赏单页面的赞赏码图片)【改】donate: alipay: /img/custom/donate/AliPayQR.jpg wechat: /img/custom/donate/WeChanQR.jpg wechatSQ: /img/custom/donate/WeChanSQ.jpg# 首页视频地址为https://cdn.jsdelivr.net/gh/honjun/[email protected]/Unbroken.mp4,配置如下 【改】movies: url: https://cdn.jsdelivr.net/gh/honjun/[email protected] # 多个视频用逗号隔开,随机获取。支持的格式目前已知MP4,Flv。其他的可以试下,不保证有用 name: Unbroken.mp4# 左下角aplayer播放器配置 主要改id和server这两项,修改详见[aplayer文档] 【改】aplayer: id: 2660651585 server: netease type: playlist fixed: true mini: false autoplay: false loop: all order: random preload: auto volume: 0.7 mutex: true# Valine评论配置【改】valine: truev_appId: GyC3NzMvd0hT9Yyd2hYIC0MN-gzGzoHszv_appKey: mgOpfzbkHYqU92CV4IDlAUHQ 分类页和标签页配置分类页 标签页 配置项在\\themes\\Sakura\\languages\\zh-cn.yml里。新增一个分类或标签最好加下哦,当然嫌麻烦可以直接使用一张默认图片(可以改主题或者直接把404图片替换下,征求下意见要不要给这个在配置文件中加个开关,可以issue或群里提出来),现在是没设置的话会使用那种倒立小狗404哦。 12345678910111213141516171819#category# 按分类名创建技术: #中文标题 zh: 野生技术协会 # 英文标题 en: Geek – Only for Love # 封面图片 img: https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/banner/coding.jpg生活: zh: 生活 en: live img: https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/banner/writing.jpg#tag# 标签名即是标题悦读: # 封面图片 img: https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/banner/reading.jpg 单页面封面配置如留言板页面页面,位于source下的comment下,打开index.md如下: 123456789---title: commentdate: 2018-12-20 23:13:48keywords: 留言板description: comments: true# 在这里配置单页面头部图片,自定义替换哦~photos: https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/banner/comment.jpg--- 单页面配置番组计划页 (请直接在下载后的文件中改,下面的添加了注释可能会有些影响) 123456789101112131415161718192021222324252627282930---layout: bangumititle: bangumicomments: falsedate: 2019-02-10 21:32:48keywords:description:bangumis: # 番组图片 - img: https://lain.bgm.tv/pic/cover/l/0e/1e/218971_2y351.jpg # 番组名 title: 朝花夕誓——于离别之朝束起约定之花 # 追番状态 (追番ing/已追完) status: 已追完 # 追番进度 progress: 100 # 番剧日文名称 jp: さよならの朝に約束の花をかざろう # 放送时间 time: 放送时间: 2018-02-24 SUN. # 番剧介绍 desc: 住在远离尘嚣的土地,一边将每天的事情编织成名为希比欧的布,一边静静生活的伊欧夫人民。在15岁左右外表就停止成长,拥有数百年寿命的他们,被称为“离别的一族”,并被视为活着的传说。没有双亲的伊欧夫少女玛奇亚,过着被伙伴包围的平稳日子,却总感觉“孤身一人”。他们的这种日常,一瞬间就崩溃消失。追求伊欧夫的长寿之血,梅萨蒂军乘坐着名为雷纳特的古代兽发动了进攻。在绝望与混乱之中,伊欧夫的第一美女蕾莉亚被梅萨蒂带走,而玛奇亚暗恋的少年克里姆也失踪了。玛奇亚虽然总算逃脱了,却失去了伙伴和归去之地……。 - img: https://lain.bgm.tv/pic/cover/l/0e/1e/218971_2y351.jpg title: 朝花夕誓——于离别之朝束起约定之花 status: 已追完 progress: 50 jp: さよならの朝に約束の花をかざろう time: 放送时间: 2018-02-24 SUN. desc: 住在远离尘嚣的土地,一边将每天的事情编织成名为希比欧的布,一边静静生活的伊欧夫人民。在15岁左右外表就停止成长,拥有数百年寿命的他们,被称为“离别的一族”,并被视为活着的传说。没有双亲的伊欧夫少女玛奇亚,过着被伙伴包围的平稳日子,却总感觉“孤身一人”。他们的这种日常,一瞬间就崩溃消失。追求伊欧夫的长寿之血,梅萨蒂军乘坐着名为雷纳特的古代兽发动了进攻。在绝望与混乱之中,伊欧夫的第一美女蕾莉亚被梅萨蒂带走,而玛奇亚暗恋的少年克里姆也失踪了。玛奇亚虽然总算逃脱了,却失去了伙伴和归去之地……。--- 友链页 (请直接在下载后的文件中改,下面的添加了注释可能会有些影响) 1234567891011121314151617181920212223242526272829303132333435363738394041424344---layout: linkstitle: links# 创建日期,可以改下date: 2018-12-19 23:11:06 # 图片上的标题,自定义修改keywords: 友人帐 description: # true/false 开启/关闭评论comments: true # 页面头部图片,自定义修改photos: https://cdn.jsdelivr.net/gh/honjun/[email protected]/img/banner/links.jpg # 友链配置links: # 类型分组 - group: 个人项目 # 类型简介 desc: 充分说明这家伙是条咸鱼 < ( ̄︶ ̄)> items: # 友链链接 - url: https://shino.cc/fgvf # 友链头像 img: https://cloud.moezx.cc/Picture/svg/landscape/fields.svg # 友链站点名 name: Google # 友链介绍 下面雷同 desc: Google 镜像 - url: https://shino.cc/fgvf img: https://cloud.moezx.cc/Picture/svg/landscape/fields.svg name: Google desc: Google 镜像 # 类型分组... - group: 小伙伴们 desc: 欢迎交换友链 ꉂ(ˊᗜˋ) items: - url: https://shino.cc/fgvf img: https://cloud.moezx.cc/Picture/svg/landscape/fields.svg name: Google desc: Google 镜像 - url: https://shino.cc/fgvf img: https://cloud.moezx.cc/Picture/svg/landscape/fields.svg name: Google desc: Google 镜像--- 写文章配置主题集成了个人插件hexo-tag-bili和hexo-tag-fancybox_img。其中hexo-tag-bili用来在文章或单页面中插入B站外链视频,使用语法如下: 1{% bili video_id [page] %} 详细使用教程详见hexo-tag-bili。 hexo-tag-fancybox_img用来在文章或单页面中图片,使用语法如下: 1{% fb_img src [caption] %} 详细使用教程详见hexo-tag-fancybox_img 还有啥,一时想不起来……To be continued…","categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"}],"tags":[{"name":"web","slug":"web","permalink":"http://example.com/tags/web/"},{"name":"悦读","slug":"悦读","permalink":"http://example.com/tags/%E6%82%A6%E8%AF%BB/"}],"author":"hojun"}],"categories":[{"name":"技术","slug":"技术","permalink":"http://example.com/categories/%E6%8A%80%E6%9C%AF/"},{"name":"随笔","slug":"随笔","permalink":"http://example.com/categories/%E9%9A%8F%E7%AC%94/"},{"name":"生活","slug":"生活","permalink":"http://example.com/categories/%E7%94%9F%E6%B4%BB/"}],"tags":[{"name":"web","slug":"web","permalink":"http://example.com/tags/web/"},{"name":"悦读","slug":"悦读","permalink":"http://example.com/tags/%E6%82%A6%E8%AF%BB/"}]}