以太坊部署调用合约

以太坊实验
在自己的电脑上安装配置以太坊开发环境,搭建以太坊私有链,编写一个简单的智能合约,通过以太坊JSON RPC	和JavaScript API编程接口将其部署到所创建的以太坊私有链,并可调用合约获得正确的合约执行结果。
本次作业的最终提交物是一个描述上述过程的完整文档,请把整个过程用文字和截图描述清楚。
  • 本机已经安装go
  • 安装以太坊Ethereum
brew update
brew upgrade
brew tap ethereum/ethereum
brew install ethereum
  • 安装solc编译器
npm install solc
  • 创建账户
geth account new
  • 编写创始块文件
{
   
   
    "config": {
   
   
        "chainId": 10, 
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },  
    "nonce": "0x0000000000000042",
    "difficulty": "0x1",
    "alloc": {
   
   
            "14b1d82b1c851ea9a6623a20d9865677ecdac70c":{
   
   
            "balance": "20000009800000000000000000000"
        },  
            "aa25a7b683fe0564fe6b2a2574e10dc886ecb3ce":{
   
   
            "balance": "20000009800000000000000000000"
        }   
    },  
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
    "gasLimit": "0xb2d05e00"
}
  • 配置自动解锁账户的脚本

    在~/Library/Ethereum下创建password文件内容为创建账户的密码
    
  • 编写启动脚本

#!/bin/bash
geth --rpc --rpcaddr="0.0.0.0"  --rpcport "8545" --rpccorsdomain="*" --unlock '0,1' --password ~/Library/Ethereum/password --nodiscover --maxpeers '5' --n    etworkid '123' --datadir '~/Library/Ethereum' console --rpcapi "db,eth,net,web3,personal,admin,miner"
  • 启动网络
./start.sh
  • 通过JRPC与网络交互(均编写在脚
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值