小田'blog

前端小菜鸡(〃∀〃)

0%

Ethereum

Ethereum study notes

学习资料

总结(一)

配置本地的开发环境以及遇到的坑

首先看看这里 https://ethereum.org/

然后开发可以参照这篇文章进行学习和实战 https://www.qikegu.com/docs/4733

truffle init的时候遇到一个connect x.x.x.x:443的错误

官方给出来的答复是 GFW It's all GFW's fault, when i crossed GFW, everything work. issues/2995

我目前的解决方案是直接clone repo然后一些基本的目录都有了,然后在继续参考教程跑流程

总结(二)

本地部署多个项目的合约无法成功

本地执行 truffle compile 显示是成功的

执行 truffle migrate 显示是最新的

但是实际在 truffle console || truffle test 里面调用时错误的

解决方案是 truffle migrate --reset 增加 --reset !!!

看到一篇文章有写到这个问题 https://www.jianshu.com/p/42479ede6730

这个命令会执行所有migrations目录下的js文件。如果之前执行过truffle migrate命令,再次执行,只会部署新的js文件,如果没有新的js文件,不会起任何作用。如果使用–reset参数,则会重新的执行所有脚本的部署。truffle migrate –reset。

总结(二)

简单的计数器合约

初始化项目

因为本地truffle init有问题, 所以我这里采取clone的方式init, 具体步骤参考上文

1
git clone xxxxxx

然后替换名字

1
mv xxx counter

然后喜欢性的npm

1
npm init

新建计数器合约

contracts目录新建

1
touch Counter.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
pragma solidity >=0.4.21 <0.7.0;

// 声明
contract Counter {
// 声明计数器变量
uint256 counter;

// 部署时调用 初始化
constructor() public {
counter = 0;
}

// 增加方法
function increase() public {
counter += 1;
}

// 返回counter uint256是类型
function get() public view returns(uint256) {
return counter;
}

}

编译、部署、测试合约

部署的时候需要在migrations目录新建2_deploy_contracts.js前面需要加上序号

执行需要 具体文档有写 https://www.qikegu.com/docs/4798

1
2
3
4
5
truffle compile

truffle migrate

truffle test

部署过程基本都大同小异(略过 不重复写了), 可以参考上文的资料进行部署

在阅读某段代码的时候,了解到了compose 但是似乎不止redux 很多工具库都用到了这个function

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/

export default function compose(...funcs) {
if (funcs.length === 0) {
return arg => arg
}

if (funcs.length === 1) {
return funcs[0]
}

return funcs.reduce((a, b) => (...args) => a(b(...args)))
}

以前的写法:

1
fn1(fn2(fn3(fn4(fnN(...)))))

现在的写法:

1
compose(fn1, fn2, fn3, fn4, fnN)(...)

相关链接:

redux

Use function composition in JavaScript

redux之compose

redux compose 详解

这是一级标题

这是二级标题

这是三级标题

这是四级标题

这是五级标题
这是六级标题

这是加粗的文字
这是倾斜的文字`
这是斜体加粗的文字
这是加删除线的文字

这是引用的内容

这是引用的内容

这是引用的内容





blockchain


11

简书
百度

  • 列表内容
  • 列表内容
  • 列表内容

注意:- + * 跟内容之间都要有一个空格

1.列表内容
2.列表内容
3.列表内容

注意:序号跟内容之间要有空格

姓名 技能 排行
刘备 大哥
关羽 二哥
张飞 三弟
`代码内容`

() 代码... 代码... 代码... ()

1
2
3
4
5
6
7
8
9
flow
st=>start: 开始
op=>operation: My Operation
cond=>condition: Yes or No?
e=>end
st->op->cond
cond(yes)->e
cond(no)->op
&
1
2
3
4
---

```js
console.log(123)

1.看别人怎么优化的
2.看chrome提示怎么优化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const ImageminPlugin = require('imagemin-webpack-plugin').default
const imageminMozjpeg = require('imagemin-mozjpeg')

// 图片优化
new ImageminPlugin({
test: /\.(jpe?g|png|gif)$/i,
plugins: [
imageminMozjpeg({
disable: process.env.NODE_ENV !== 'production',
quality: '65-80',
progressive: true
})
]
})

提取 CSS 到单个文件-简单的方法

首页

performance 30
Accessibility 78
BestPractices 79
SEO 100

performance

performance 30!

Serve images in next-gen formats

Image formats like JPEG 2000, JPEG XR, and WebP often provide better compression than PNG or JPEG, which means faster downloads and less data consumption. Learn more.

修改了png, 使用webp 利用photoshop插件保存图片

performance 35!

Serve images in next-gen formats(不提示)

但是由于兼容问题, 这里炸了 哈哈哈哈哈哈哈哈😂

… 等待后续