思维之海

——在云端,寻找我的星匙。

区块链课程实验

区块链课程实验。

数字货币交易

利⽤以太坊体验数字货币转账功能,在以太坊测试链Ropsten上进⾏操作。可以利⽤Google插件Metamask⽣成以太坊地址和私钥(保存下来)。向⽔龙头领取测试代币https://faucet.metamask.io/,⼀次会发送1ETH,编写脚本(如python),向附件txt⽂件的100个地址每个地址转账⼀些eth(⽐如0.01eth)


创建钱包

Ropstenhttps://ropsten.etherscan.io/

Metamaskhttps://metamask.io/,Conflux钱包界面跟这个差不多

按照步骤创建钱包即可。

切换到测试网。

注水

水管https://faucet.ropsten.be/

在水管上输入自己钱包的地址,开始注水:0x75a669A413Cc3640C52F5E3FBc82836f18497407

没有起到效果

尝试直接从METAMASK水管上注水:https://faucet.metamask.io/

注水成功:0xa9c12ce15386998acd0e29bac842509b1a57793cac13a1320bbb537e05d116ad

但是上述操作完成以后,并没有看到相应的ETH余额增长,点击transaction也是查无所获。

又提交了一个注水交易:0x540c617e4df428f3175189902419f5ef58822c9cb84e3e7584fe90aa8030e1d0

……全部都失败了。。最后找助教给我转了1个ETH~

编写脚本

Web3.js 中文文档

Web3.py:用于以太坊交互的Python库

1
$ pip install web3

一开始安装的时候遇到一个棘手的BUG,是某个安装包找不到特特定版本的依赖。搞了好久,最后大概了解到可能是跟python版本有关,所以直接重装了python3.9。。这回安装web3就顺利多了。

网络交互代理设置

Web3.py教程:如何使用Python转账

如果要跟以太网交互,必须连接到某个节点。(Here

Infura:一个以太网的代理节点服务。需要注册。

注册完成后,创建一个project,并获取项目ID。然后填入以下代码的<infura-project-id>处,即可建立代理。

1
2
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/<infura-project-id>'))

你也可以把项目ID保存到环境变量WEB3_INFURA_PROJECT_ID中,从而避免硬编码。

mainnet代表以太网主网。

基本功能测试

我们试着运行一下接口:

1
2
3
4
print(w3.isConnected())
print(w3.eth.blockNumber)
# True
# 11333063

查看之前钱包账户的余额:0x75a669A413Cc3640C52F5E3FBc82836f18497407

1
2
w3.eth.getBalance('0x75a669A413Cc3640C52F5E3FBc82836f18497407')
# 0

修改连接到的网络

余额为0是因为现在默认在主网上(Infura Mainnet)。我们先切换到Ropsten测试网。

获得相应的链接,修改连接代码:

1
w3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/v3/d3fb182b32bd49fe9eb36693d470ed88'))

再次查看钱包账户的余额:0x75a669A413Cc3640C52F5E3FBc82836f18497407

1
2
w3.eth.getBalance('0x75a669A413Cc3640C52F5E3FBc82836f18497407')
# 1000000000000000000

成功。跟CFX的$10^{18}$单位转换一样,代表1ETH。

转账实验

单次转账测试

Eth.sendTransaction(transaction)

以太坊 web3.py 签名转账

web3.py 脚本转账

chain_id

感觉相当棘手。报了一个错,似乎Infura在Ropsten测试网不支持eth_sendTransaction这些方法。在主网上则是报的余额不足的错。这样就不是很友好了。

1
ValueError: {'code': -32601, 'message': 'The method eth_sendTransaction does not exist/is not available'}

询问助教后发现是参数不匹配的问题,在增加了一些参数以后,成功执行了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from web3 import Web3

sender_address = '0x75a669A413Cc3640C52F5E3FBc82836f18497407'
private_key = open('private_key.txt','r').read()

receiver_address = '0x2a9d0B6fd9fF3C854130Af05529B2e40FBADa38c'

# w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/d3fb182b32bd49fe9eb36693d470ed88'))
w3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/v3/d3fb182b32bd49fe9eb36693d470ed88'))
print("isConnected:", w3.isConnected())

print("sender:", w3.eth.getBalance(sender_address))
print("receiver:", w3.eth.getBalance(receiver_address))

transaction = {
'chainId': 3, # Ropsten的网络标识号
'from': sender_address,
'to': receiver_address,
'value': 2333,
'gas': 90000,
'gasPrice': w3.eth.gasPrice,
'nonce': w3.eth.getTransactionCount(sender_address)
}

signed_txn = w3.eth.account.signTransaction(transaction, private_key=private_key)

txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
print(txn_hash.hex())

import time
time.sleep(25)

print("sender:", w3.eth.getBalance(sender_address))
print("receiver:", w3.eth.getBalance(receiver_address))

输出:

1
2
3
4
5
6
7
isConnected: True
sender: 999658962292322667
receiver: 16331
0x1e7785b8aca445c2e6c9880378ae4cea701c7113b23303c85e0cf76cec8b9e5e
sender: 999616332562233334
receiver: 18664
[Finished in 29.9s]

以太网上查看:0x1e7785b8aca445c2e6c9880378ae4cea701c7113b23303c85e0cf76cec8b9e5e

批量转账

python 读取txt列表到列表中

python读取、写入txt文本内容

解决replacement transaction underpriced以太坊交易异常

简单来说就是以太网交易有时延,高频批量处理的时候,要自定义交易中的nonce标识

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from web3 import Web3

sender_address = '0x75a669A413Cc3640C52F5E3FBc82836f18497407'
private_key = open('private_key.txt','r').read()

receiver_address_list = list(map(lambda x: Web3.toChecksumAddress(x.strip('\n')), open('以太坊100个地址.txt','r').readlines()))
txn_hash_list = []

w3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/v3/d3fb182b32bd49fe9eb36693d470ed88'))
local_nonce = w3.eth.getTransactionCount(sender_address)

for receiver_address in receiver_address_list:
print(receiver_address)
transaction = {
'chainId': 3, # Ropsten的网络标识号
'from': sender_address,
'to': receiver_address,
'value': 2333,
'gas': 90000,
'gasPrice': w3.eth.gasPrice*2,
'nonce': local_nonce
}
signed_txn = w3.eth.account.signTransaction(transaction, private_key=private_key)
txn_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
txn_hash_list.append(txn_hash.hex())

local_nonce = local_nonce + 1

with open("txn_hash_list.txt","w") as f:
f.write("receiver_address,transaction_hash\n")
for idx in range(len(receiver_address_list)):
f.write(receiver_address_list[idx] + ',' + txn_hash_list[idx] + '\n')

运行结果保存到txn_hash_list.txt:(100个转账交易的receiver地址和transaction地址)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
receiver_address,transaction_hash
0xF5038fbAfbC0d08629EF7890D0437Ec135A05338,0xce48d4c7daa046c413b6a13692bb41137f72a557fd3d723938ad868e127e3833
0x2Ad318738C4b35547F60C20E884ed8279d74a1Be,0x76540a97452352745afcd5ad9be9f16967753ddfcb999f5d7b43394f82253d67
0xE63cAE40d63791467cb111DC8eAb32e55c27921C,0x1eb25169dded0f811d5034632357ba7e7c678731c28d831b8f575bf3c3fa74a8
0x7208DC3f8A279f0b3B287a7a253953cCA1A06db9,0x1495b14b1f99f607c576a0aeeab1836454c2f81f0213e149b3a0312770d2307d
0x743e6861AC9E3582DDCc5De3f8B893C9239AFb65,0x916f252e912a8806a21dc152f8a6807419af75887c0549d3b980807b461faee6
0xC6c4a7E78EEbE24EEEA0E306aAc14D0318B573Bf,0xbfac50d11323b7e668b94c0c67c6d235b962d5dc84e26addda0cad1f5c1e57ec
0xf0Ed2D4823617f4fefdcebBCDBe684Ef60556ff2,0x952dfa6b23d7ac0f56e3213dc02600cefd368ecfa93f6129dfdece2a42b0deb7
0x597C52bbe09991e6f39eb0da0393722C32b89536,0x3bf586007fdaaec1334d57c45abea44729d87d2c589a69d46f2c03a4830c614a
0x41aa8Fa01023B3eEf4176899f9Fd27952aEBcB37,0x4b6b8444957549e8d9366e96a95b98d4162323cacf8d53e5e19973931e72c0f2
0xF0A1959236D2A84bF0788deDE9D20c4897ef2082,0x48fd0644e911e00e70812ca6dcef016ad6d04bb5b9f15c86ba3d345d2d580ec1
0x6f4B8c46eB55E01f9076363Ce9A60D2c10D32465,0x34e6f65c47123f501dab0a4be40fad231de11a85a8d01de631a50ee438b5ac0f
0xFA3728689dBe43C1d2707AC486D426d6497C9F47,0x779f3aecad25a480fafe02b67a5c7405e138870b77366ddaff7d1b8607f4b2ec
0x74C112FB8B87586BF1315eD80a79227fF437bc4b,0x0aafa84e36950c495da47e012fcdcaf2159f71e686c4b687a5e808c6d0031f79
0x0be1f2Aa333Cec14AdeAbeBcB7Db22e4D8077b13,0x26741d3a81727f39932dab3d5e75c0feed840d0b82bc6fe6185847b4ce8087e6
0x17F3B9bDbB31FC96baf85Fe89B9f82d216449cA3,0x8fce8d78dbfcbcf666ffa18c9a1595a667fdb6277eb6826ff3dcdf20c03be0d2
0x3C37A1C6C817E9149751c9162Dda2D59Ad2D254e,0x706073665fbb42d9dd4a664af999ee277c057494a864c3d0f5884582fa0157b2
0x49755db1Ac06075E3e66270f05Fe32f02c1F5A2f,0x9ed1dde26f27ec8f521a391674f780cb4130ae9a1fd047066b4d7ac778099020
0x5f3bBfcA0561Aa4A66DCB5314aF1c05a35D9D0B1,0x4eedbf34146a8032cfcf39b5538e471b59abed7b5c17623e6dbe9cd284ba20c0
0x410b2bE29E217c617329627eB789318272f1f294,0xf65c8ea23ff06dc69ce52e27e073e04bb84c920342a905e837aa2e4a1a0807fd
0x6330F9bbe5c29Fa4ad7a786a3B399B5886DA2303,0xe375e45801ecc1102a96e53d8f98e0fcd455bbc7b77612fec5d966e9a09d1658
0xa97f63427599A4C7cE6D61347fAED4196c6B84A3,0x012280a8ec9ac84645704de86785f1297349b55fd2f4ca315c6a164f5cba6062
0x204628AC17c05c0F47FA1Aa991f2CD6aA76eA8Cf,0x9ca958c32613ccff5f7a5c6a39aab3c5a08863e2e77662bd260ed98ddc73ca7e
0x34221e0097e4F512F93FcC960247D95785524BaF,0xd8f051b7f50c9a468a6a2d636693346d2247fe253446ae76dca67d4c087586cb
0x6603680d11B601317A89E1B5c5F932D9066Bda6e,0x13f22aca9be21e2db9e7ee6f8a22a8c0e84429a41e17a687f4bd027ae8b07bbe
0x9956fBB19c3C9EaF2Ff66bE0817Cb1fa5b4E7fDc,0xac83dd89b467d31a9b33b9362916eb8c196b9880e39606ff7aa6d5762f825ba0
0x59533e7Bbe9d68826Ac4AF8a83cc1743637918DF,0x62708dcd41ddf845c2a4121727c8bba18a63e2f453d3ce8691d383bf0b812ca7
0x5A945352a53035546aC341887eB7C9e591E3D3af,0xd4e6b2aa4426b3e14873c245dc0ff724d0c240ca4a7dc94ff6b602c5dbd0fd5d
0xCb5e1Dc921d13B3db04853735477F4bFd730Abea,0xbd5edb4b282587623745050edadd7ba58571235ad9e6b35b876cd86703c3a0ce
0x2852CD4e1AB6924B57D2A073F04E02cC5AfF71E7,0x48395332f448fb84ecd44a15f4a7615414bc489e2660f608c6da04fdbe8b3fbc
0xBb411F489434BF96546DBB274f9fd3f5a1502a92,0x379a4dab65f5ac83e009fa3efe418495e87b9aec29fd77c8ff108b0ad89d545b
0x9d2a1c9217EA36137742FD7EAAEabe3fcB56AEF8,0x3ae9bf355013e3acd939c890efd2061b49b6bb6d66c1c14b332596823315b21e
0x43eB2A45f92558f2Ccce8BCa7717F1C4740FC5fA,0x4a91ce10876f1d9c41fd0ed7f622b152dde339f39ecf429563f204e72c38dd90
0xdf6FbfC8A5CF9B76716483b9f64bF0589931a5A5,0xd5e2c3f2aad77ae6febc61e6299452ca6177287607f3e85fec700616ddb3c4b9
0x906C650973991a08B9E2B2d202F82879Fd79F2Ef,0x7f9fef0f49ba7ad6b3fd9f83f2f4696840a055ce59c45e080d8ad1be0b84dedc
0xE9F3F08ae08FDf92acA5342280Fd133a893eE527,0x972f8be9a8fb7f8ab654eac441dc1cd08f84c23b48e76982f901ab73d3cc7c3c
0x258f82fFc5ebC019a70e6B589E125abF00Cf0C70,0x073a97c76ede43e4defd0dd905e909e30e84e34a94521f067cee09c46ff138cb
0x56c57c57e9d4553E0F69C8b0eb2c9080A29b4617,0x98f1094f7827a84e0c17d7396689d71e94a9de5e7156122daa81d5deae314d8e
0xA50B2ceab00703745d8105383f90537A3f6A6ea9,0x9ea5224e7bf3d2c1137bf31f1d9c03e16dec4b8a08a1a553fe98039b1044d5d7
0x0f5c60e699751B87f2b8e6E5C777A8B823Ed1e32,0xcdadbc8c0a04f32321f744fcba02045fb6db59e9dc0b727d9f6ee470850b020e
0x9AE7F9526D0ba93e8770c3C8F91ABE06E00C3546,0x555b025736dbfac7bd4c5a0b5ccbcf4043465b4f3362a024607986e1cc7642ea
0x33A93f0156BFC2EacfaB72581cC65D1c4aa4134d,0x79f77e769b1bd02184dc76cc3068efb940b86ee30b4ac29bc6f1b1bbd0508887
0x82647DbD911243318A98388274bD01e7722ac196,0xe4e81645c6318fd5b6d88f1fe1139b15e96cf238a8d2c2a3c5885e9eac218016
0xDB42179E665C74FDBDdDd358CaA13Ce2D2cBF8Ca,0x2216b36eaf9c6b9b88f87cdf81f4470142e18fab833ffa5cd81a2556758c5182
0x634F06362109c4c6909daFAeAeC54a7C48fED6b9,0xe0b08c5e34f0fd230549af47d61d70b0907bc322626748f6fe62c4581cac986f
0x18f36BD1ecd5129eEd69E8336A639A958a2c0B6c,0xc96c30e6d2fc15f52a3bd4c6988e0c1a4084389c12dfafe42507358b7a2ba046
0x48991e0107B60e59a10CF6ea4C98413bc8707965,0x417b64ae3109cb805fcbc241702708e0a732fbaffb8d56c27022c5cbe83eb919
0x5acCBB66f98C9dfE970923F4fF6BB78F4684DE5b,0x6ef116bbad22452b39429876f69cc89651195367c3ce7dc8c70e84e4adc14b1e
0x6C32130c0cbCc02D7209d7ddDF75AB686C8CAbD4,0xab123626e8e0c6d240547fbeb73812cc3758e1efd40c102d7c5e4779ad84e263
0xbC5436a2FE868f8156fC0E407889C8357A3786D9,0xfbdc6f4e818b1666672f91d95e2646a2dd1e21e12a40c49c3e38b86ede4b681f
0x0e6009CAD7972b81AB65c7A16051DF35197a440F,0xd53ba8592f02ceaf749f110e531bd4256f719e3bc0806dcc8d464f592691c3fe
0xE1A926A6F13CDfD963fCBE9Edf45A941DdFD029a,0x11b744467f201db0a2537db39618ca192239ecc75cb2f05f8d213d05b7045281
0x783Ef0F1ccbd9f2Db675499aF1695d5952AA8b15,0xe75288128cd120be182c290f463cc3d46eeb0806cda430cd891e9f437b77a2a1
0x0D09B0744b15988F55AC40a03E825E8A7B746305,0x23eb6b82be46284cfa0ffccc8b1a85371fec6b085eaf0af61f61c3209d0d20f4
0xb65a46cBC43D8dd08Cf79eDE6f4888FBF6c80838,0xca80a5defe0e2472dc27ded1ca634e1b91008928d8b1e29878a0d09054771cf7
0xEeDf45908eb260a928e23DcB8E29834bE114A51A,0x21da569dfeded8769a229e7495821e5e3069f274f6a728d52cd996e0c1fc21f1
0x277e20fDd65Cd475d0cCfEc4504e232a5Bb0Ae66,0xc773ddb8217483689bcce8ac20fa58707227373831853995965d17e1067d4301
0xA744729DcF3CABEA6D736C3Bf063603295A1A4A9,0xd2876cd6471ae28a0c3c4294cc3c3554a0a9e06be42b04e7beb90ce47f909076
0x26994067D27e956f37F977eac2fE558183083Eae,0xa3b529a4cd52dec9abe6013bc164c256f60bccddebae8af4797456ae76471583
0x34B1dCa251403C1E8e060E297D60E0b5b56eF2ca,0x3d187a3443ee1523e9ddb99317440759d50a42a9d9bc05aa9143a4749013b22c
0xb32392B690AC08cDFF63E9F825c6aa0085d32980,0x942ab093895c55ac797a371b156a2df9f6221e5259bb7e4a26b0c0d73088b8ae
0xF0248a6Dc89347B83AC538Ad8f9D21C7407526C8,0xa1ff6c93ef65fec2a617bfbd6ded9740fed5b55a8849998c3120c7a12965db48
0x6d1EE1Cc2a5035B7b027d17ae886b2dfd64ca9dF,0xbb66205552e145b555663a02e7cf826d00d06cb246a7292cc362a6dee771714d
0x5200e4896063265e30Cb1F003b0428242750D643,0x90768a96826f36bf97c7db8583806dd31c94b3dae1c7ead617d24ef76d3a7d5d
0xe7c62457fCFe75A162d4d39d75fb65c2bA81CB12,0x78ac189e0dc13b73927750adf3bfdb9965301e4d4b11f80f1b036cd55d259fec
0x854ED15dCB081a0EEbfA5Ec41e5e73b71108798B,0x6d05198e107f9c91bcc95da379fe46ba8b626eac54bf50bc89399379f117b8a3
0xfE3B05538d342dC6689f82f24eCC72eFfC5eb353,0xa4c740b7374e5b624fb5b3866368f30e5d2487d24c380d9689cc07c741098d34
0x81CBBF3e9B6821B9A418E890e6F685aD7F349d18,0x2346d5850fbf5a0a88391ff3393f002590d1b2053a5e4d993fd4ee8c51cba1be
0xEdD6225aF424470730789f9E8f6cB1F6855Bfb6e,0xe1ec3affa7ae2da1a420fc7b6489013772429b038f274627193a11ff63ec505a
0x1418abDdc3d3f323D126988D835367AB8c80fb4A,0xf40021cf3ba6f23d0a308b15ab3eff9c8f0759251085efab493d1e89a3733770
0x4dE0a71Ca317628B5F577da9d4f87517306F64B8,0x2f9eaa0fea8722da5a427d4c8763ff1b8f4620bbe4ed2889647f669e928f01f6
0x1DC21C3C7C953C8479f052BFb6a287a9c0AbDEFa,0xe9bd3a30425b5ae1074ea35d750b6042c1866952c7e8763b5f1495b45361988f
0xf666d19AD3a8E5fD1c1067a4afD64cA17140c49b,0x47201b811198ccd5f0c38e6e9499eb646fe2a0dd515a1bdf258fb7e5a55bbd25
0xA9EA631ebd06Ac20a92dBcbC5f0d9d5067BB6AFa,0xe12dd92bef2282a3dbab63d04b60927bc143f13672ab47fecc0bce16b270bf13
0xD19e1B8215fdfFa2BD14217A0d20484596b1EF3c,0x4eecbc1bc2cac43d86a6aa7dba02c5c8dcba0d23f4242ab504e452db5320e117
0x3036b9f146a7d107B17E506DA19a86bBB6BF4c14,0xa453d0bd4d7adc6195f0568a00b2dc300b97fe2a3a7033db0ea7c4c2a3afffc6
0xbAF0873DB0874717680298EedE4DcAb71829d24b,0xe151cbb6ae808e3f17e584debc8d344a35620f2417e66ccca40d05f1b583b091
0xB2AD5422767e003aE18D1C183Fc1f655c83f47be,0x7a2345fa52828463f66225cbdc4ddd34a1da64b47b04d0f74174e0d34fa81632
0x3875934878c9F3217235F4817a109d558dB86458,0xfeea2993a9beee5f7ebf14831d91565b9ea293a785d60188ec7665f13c05107b
0xb00aB9f855eCfF24f4ac25c8402AaC75affd14e4,0x4154abc948e95f896e7da50addba4e417e27e910dfd25d5088d61990cf93427a
0x832c405a14e364728401953f1A96652d481e4b54,0xd5d6e7936db55bc120a548afc8f69c3fdcf6bd2956d1cc4891cd4401e19bad95
0xD47dAf5047a3931A947762D34794d4D62fA024E3,0xdb7066aa499d922febcbb07979fd8011e4ab9a184a3041560c1add5639b1c6b5
0x14c0C3E5F6F6d8bd1030E161577f3A70563B3F5a,0x18aa76b0e2adf5833514c62e9172adad36e0be9fd8d0cce4e6327f500e92b8a2
0x14B786EfC953336A7DEEe955C0d7FDEBB668233F,0x53fac254fd7f9deccff26aebd37748011af31300697662b000171c50bf180c05
0x4184733688457eB0C06fB33C241d5c2Cabb1F332,0x1d98543e8e36206a35e9e445e851ff4db5f32a5a18d79033aff6de7ea9078e95
0xb5bbAE1742cC280dFB3b77F3Da4b9d5d6De0F206,0x17155346756409e20f93ad9a044f2359ee3ace08bc7c0e73da3dc34d11ba0d4b
0x16fc9087dAb4ABeCB154f1ADE296aDa287F4740e,0x9ebb3bd060e1dc1a7979e1829f3d26979988e33d30a6c2b452cabc9cfffb0326
0x7761A9072bfB49CfA629403AaBe1DD3881D2c37C,0x2003ffd30af70c444cc69eec22f19b7a444bd95e6572404aeea56da368ebf0b4
0x82788f0Ad056Fa7B2D960ed32D451D2F3B49555A,0xa32008a0be2a5536c539faf4a9964e13714f6d5d4ce4ed5af5cb0bc2d0f8fd8f
0x2e30924F89969675E168014FD957a5f5e782619d,0xb212e2a507fbb169fadbf94812c77751e03c79086c6b7c52aae49fbc8e6aff3d
0x921DBBDeb89d0b0aa70F34f94eb0f85FCB8adC42,0x4905a8760571053cf074644919659d0bb0d914b366bc102e489065b23a99c4c5
0x4dd86Ec972e34F0C75437fE7393d530F77054263,0x3db0c74ec54f327e5f6ad70a42ca6ea6ff04c64ea5ef07b4b36ca28d8e0d3894
0x9Af66A51f824FF6f3Bb748DccD85e39C7836d656,0xf9498db48c3cf9cf81c3978c4351bb49e13cad56c0587bb1568b6798aa5b3458
0x216F1562c6B74D90dDe7111BA64ed8C2259328aC,0xf77e6a27e371876292c9ce2f5a391fbc32f889388c94034daaaf4c98b4b4f95c
0x45EAb4237188fcD565882bb1d1995EdfA114F345,0xcb54347277cf8d053ba9d8f84dd45ef1dfb43330d1af62cd93c99615167cc03b
0xfBB451aA60D83C1E7b9606fD3Df774EE4D5d7133,0x171a7e0786f43921b126398868f56193ae81fe10058d97999944c02479fbb294
0xF3528dCbbb2006aDa8de5D094E84a6561aFE5f90,0x86ad24d9104b1884e4a5d439418dbae58732c4746359a00009621881266488ea
0x2898B60ab33F4d6985379B80FadF38FfEE4ec5C9,0x502ea4563931fba029f4ece571085c553a80a480bab047add5a2389e2d42284a
0x3868BCdb212e465936FEb1906C1bA8Ff66d21730,0x2a0f22876c884fb1dd25fb27f188417a1496a2cec32933b2210df61a7dd0c5a5
0x17075CEcA61CcCB1813203A66A8a8260a37A192b,0x15e4372e115c66287cca0648aea7f5af4d359ec10b41ab35dd2d085496c21c1b
0xd3fE6E3E6fA461A56366dF3FBC64f424995A1839,0x1814e22abd31057df40685d34759c28a2c0aad100f5548ad2b521510d9679c8b

在以太网上查看:0x75a669a413cc3640c52f5e3fbc82836f18497407

智能合约实验

编写⼀个简单的以太坊智能合约,⽤Solidity语⾔编写,实现⼀个简单的计算器功能,四个函数,能实现两个变量的加减乘除,并部署到以太坊测试⽹上和调⽤测试。

https://remix.ethereum.org/#optimize=true&version=soljson-v0.4.23+commit.124ca40d.js&evmVersion=null&appVersion=0.7.7 在线智能合约编辑器


编写四则运算器合约

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

pragma solidity ^0.4.23;
import "remix_tests.sol"; // this import is automatically injected by Remix.

contract calculator {

function add (uint256 a, uint256 b) public pure returns (uint256 ret) {
return a + b;
}

function minus (uint256 a, uint256 b) public pure returns (uint256 ret) {
return a - b;
}

function multiply (uint256 a, uint256 b) public pure returns (uint256 ret) {
return a * b;
}

function divide (uint256 a, uint256 b) public pure returns (uint256 ret) {
return a / b;
}
}

合约测试

在虚拟的环境中进行合约测试,效果如常:

部署合约

把环境换成Injected Web3,部署到Ropsten network:

部署完成:0x081a95329b24CEE9661168440551D8bBa10B70Ff

部署后合约测试:

PoW共识体验

⾃⾏选择⼀个PoW币种(BTC、ETH、LTC、ZEC、DASH、Grin等),计算该PoW算法哈希,提交⼯作量证明,可以加⼊矿池。时间不需要太长,⼏分钟即可,体验“挖矿”过程。截图证明。

可以使⽤的参考⼯具:轻松矿⼯、AIminer等
可以加⼊的矿池参考:蚂蚁矿池、F2pool、币印矿池等


轻松矿工http://www.qskg.top/

挖矿界面:

矿池界面:

*PoS节点搭建

⾃⾏选择⼀个PoS项⽬(Eth2.0、Nebulas、Polkadot、Cosmos、Irisnet、Oasis、Nucypher、Algorand、Solana、Near等),运⾏其验证者测试节点。

参考⽂档:


Nebulas(星云)。

测试网:https://github.com/nebulasio/go-nebulas/tree/testnet

下载这个项目比我想象的要大很多。。。

算了暂时没空搞了。

*去中心化交易协议

了解AMM (Automated Market Maker)和闪兑协议,统计⽬前区块链上去中⼼化交易协议上质押的不同交易对的资产总量,⽐如Uniswap和Balancer,分析其对中⼼化交易的冲击和影响。

参考⽂档:


What Is an Automated Market Maker (AMM)?

DeFi 科普|去中心化金融窜起,什么是「自动做市商AMM」?

自动做市商 AMM (Automated Market Maker):去中心化的交易中心。用户登记数字资产,并提供兑换和赚取手续费。

闪兑:闪兑就是快速的货币兑换。这里提到的闪兑协议助教说理解为uniswap就可以了。

最近比较火热的Uniswap协议,听说过吗?

新手指南 | Uniswap 是什么?

Uniswaphttps://info.uniswap.org/pairs

Balancerhttps://balancer.finance/

没有找到Balancer的资产界面。。(只找到了:https://pools.balancer.exchange/#/explore

去中心化交易市场当然会对中心化交易市场造成冲击辣。目前的去中心化市场只是提供了数字资产的交易,实际资产的交易很难保真地数字化,也就很难通过密码学或者区块链的方式来保证去中心化以后的可信度。所以,在实体交易方面,中心化交易市场仍然是无法被取代的。

但是这对于中心化的数字货币交易所来说不是一个好消息,因为去中心化的AMM可以很容易地取代它们并且为用户提供更高的效率和更低的手续费。