首页 技术 正文
技术 2022年11月16日
0 收藏 321 点赞 4,120 浏览 1806 个字

ubuntu下载: https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu

sudo apt-get install software-properties-common

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo apt-get update

sudo apt-get install ethereum

geth account new

git clone https://github.com/ethereum/go-ethereum

确保自己go的版本在1.7以上

ubuntu升级go版本(http://www.cnblogs.com/tianlongtc/articles/8856644.html

sudo apt-get install -y build-essential golang

cd go-ethereum

make geth

You can now run build/bin/geth to start your node.

记住你geth现在的路径,以后要用的时候进到这个路径来运行下面的代码。

> 代表在geth里面执行, 不加>表示在terminal执行

创建账户

$ geth account new

> personal.newAccount(“password”)

查看账户

$ geth account list

快速同步模式

$ geth –fast console 2>network_sync.log

浏览日志

> tail -f network_sync.log

查看账户余额

> eth.getBalance(eth.accounts[ ])

解锁账户

> personal.unlockAccount(eth.accounts[], <password>)

挖矿

$ geth –mine –minerthreads=4

> miner.start(8)

结束挖矿

> miner.stop()

查看挖矿速率

> miner.getHashrate()

查看区块高度

> eth.blockNumber

查看挖矿账户

> eth.coinbase

设置挖矿账户

> miner.setEtherbase(eth.accounts[0])

预估手续费

> bytecode = “”

> web3.eth.estimateGas({data: bytecode})

以发起一个 0.01 个 ether 的转账交易为例

> var sender = eth.accounts[0];

> var receiver = eth.accounts[1];

> var amount = web3.toWei(0.01, “ether”)

> eth.sendTransaction({from:sender, to:receiver, value: amount, gas: gasAmount})

在控制台里,使用这些命令检查连接状态

> net.listening:检查是否连接

> net.peerCount:连接到的节点个数

> admin.peers:返回连接到的节点的详细信息

> admin.nodeInfo:返回本地节点的详细信息

账户操作

eth.accounts //查看账户
personal.listAccounts //查看账户
personal.newAccount("***") //新建账户
personal.unlockAccount("**********") //解锁账户
personal.lockAccount("**********") //锁定账户

代币操作

eth.getBalance()   //查看余额
web3.fromWei() //单位换算

节点操作

  • net模块
net.listening             //查看节点状态
net.peerCount // 查看节点链接的数量
  • admin模块
admin.nodeInfo          //查看节点信息
admin.addPeer() //添加节点
admin.peers //查看添加的节点的信息

一些设置命令

miner.setEtherbase(eth.accounts[n]) //etherbase地址并不需要一定是本机上
miner.setExtra("zhou") //写一些额外信息
eth.getBlock(n) //查看区块信息

参考博客:

https://bitshuo.com/topic/5985c4c5876cd8953c30b378

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,108
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,584
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,431
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,202
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,837
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,920