以太坊合约配置步骤大体如下:
. The
一.安装Mist浏览器(已经集成以太坊钱包)
I.
二.安装配置基于Go语言的geth命令 II. /span style="font-family: Calibri'getspan style="font-family: Song body" command
三.在本地搭建私有链
III. Build private chains locally
四.在私有链上完成挖矿工作
IV.
五.使用Mist在私有链上配置投票合约
V. > set up a voting contract on the private chain >
具体步骤如下:
Concrete steps are as follows:
一.安装Mist浏览器(已经集成以太坊钱包)
Mist
1登陆https://github.com/ethereum/mist/releases/根据需求下载最新版本的客户端:
1 https://github.com/othereum/mist/releases/
下载完成解压压缩文件后找到可运行文件运行安装即可 Runable file running installation will be found after downloading the decompressable file 安装过程中要同步区块数据,下载过程需要耐心等待,成功后会出现如下界面的客户端,这里我们进入的是以太坊的主网络,当然我们此后的实验操作都是在自己搭建的私有链网络中,并非在此。 The installation process involves synchronizing block data, the downloading process requires patience, and the following interfaces will emerge after success, where we enter the main network of Tai Jin, and where, of course, our experimental operations have since been built in our own private chain network, not here. 这里是已经添加好三个账户的界面,初次安装成功不会有账户需要我们去手动添加,我们可以通过Mist中图形交互界面添加也可以在geth命令行中通过命令添加。 This is an interface that has been added to three accounts. The initial installation will not require us to manually add an account. We can also add a graphical interactive interface to the command line in Mist. 在geth命令行中我们可以通过命令 (当然这是你在配置好geth后才能完成的操作) geth
geth accounts new 来建立新账户 Now, get new . 如图则建立新账户成功,新账户地址为 Created a new account with a new account address if chart is successful Address: {e64a1c6c5eb3e9638296f2d67d911d1e1b16b863} 在建立新账户时需注意记住账户密码,及时备份,Mist客户端中便提供备份,以太坊账户并没有账户密码找回的功能。 Remember the account password when creating the new account and back it up in time. Mist 二.安装配置基于Go语言的geth命令 ii. Installation configuration based on Go /span style= "font-falibly: Calibri" >geeth geth是以太坊的官方客户端,它是一个命令行工具,提供很多命令和选项,可以运行以太坊节点、创建和管理账户、发送交易、挖矿、部署智能合约等 Geth
下载运行安装文件 Download run installation files 按照提示安装即可。 Just install it with the hint. 在下载安装后可以在输入查看geth的帮助命令: geth 此时geth安装成功可以进行下一步工作 geth successfully installed to proceed. 三.在本地搭建私有链 III. Building private chains locally 在试验和测试时为了更快的进入网络和方便控制,我们大都会选择在私有链上进行这些工作,接下来我们看看如何进行私有链的搭建工作。 In testing and testing, in order to gain faster access to the network and to facilitate control, most of us choose to do this on the private chain, and then we look at how to build the private chain. 1.进入dos命令行 1.
输入:mkdir private-geth & nbsp; & nbsp; mkdir private-geth cd private-geth 其中genesis文件内容如下: & nbsp; & nbsp; genesis > : 输入命令:geth --datadir https://www.cnblogs.com/myblog125/p/data/00 init genesis.jason geth --datadir https://www.cnblogs.com/myblog125/p/data/00 initgenesis.jason> 4.启动节点 4. Start node geth --datadir https://www.cnblogs.com/myblog125/p/data/00 --networkid 15 console 注意在输入networkid时不要使用networkid 1,那是主网的id,而且此处的networkid必须与自己编写的创世区块中的networkid一致!!! Don't use Networkid 1 when entering 至此私有链已经搭建成功,需要有账户建立就能进行挖矿操作了。 By then, the private chain had been successfully built, and the need for an account to be established would allow mining operations to take place. 四.在私有链上完成挖矿工作 IV. Completion of mining on the private chain 此时输入如下命令查看私有链账户时 Enter the following command to view the private chain account at this time eth.accounts 表明还私有链上还没有账户,需要我们创建,输入如下命令: Indicates that there are no accounts in the private chain and that we are required to create them. Enter the following command: personal.newAccount("123456789") 此时创建成功,引号中输入的123456789是我们的账户密码,当然,我们也可以通过Mist客户端来创建。 is created successfully and entered in quotation marks 123456789 is our account password. Of course, we can also create it through the client . 在我们的本地文件中也可以找到创建的用户账号文件,路径如下: Created user account files can also be found in our local files, along the following lines: C:\Users\J\private-geth\data\00\keystore 此时打开Mist客户端会自动连接到我们刚才创建的私有链,并看到相关信息: client will automatically connect to the private chain we just created and see the relevant information: 在命令行输入 miner.start() miner.start() 此时需要耐心等待(约有5分钟左右)开始开始挖矿工作 > 在mist客户端左下角位置也能看到一把铲子标识,表明开始挖矿。 mist
停止挖矿工作需输入如下命令: The following orders shall be entered in order to stop the mining work: miner.stop() 可以在geth命令行中查看刚才挖到的以太币,应用命令如下: geth Eth.getBalance(eth.accounts[0]) 五.使用Mist在私有链上配置投票合约 V. Use 输入solidity合约代码.Mist自带编译功能,编译通过后选择要部署的合约即可。 enter policycontract code . Mist 注意你所输入代码第一行的版本号必须与你下载的版本号一致,否则编译将无法通过! Note that the number of the first line of the code you have entered must match the number of the version you have downloaded, otherwise the compilation will not pass! 选择合约后部署。输入密码后便可成功,注意交易时需要一个较大的gas值,并在部署合约的过程中保持挖矿操作的进行!
运行合约需要有其他的账户,此时我们需要多创建几个账户并由主账户存入以太币。 Operating contracts require other accounts at a time when we need to create several more accounts and deposit the main account in NT. 运行投票合约需要给其他账户授权(给第二个账户授权为例) The operation of voting contracts requires authorization for other accounts (for example, for the second account) 授权后账户便可进行投票 We can vote on the account after authorization. ---恢复内容结束--- ---Recovering content is over -----
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论