合约基础环境geremi, by Skyh

skyh: 力求最快最简洁技术表达,code & pics in 10 min,
----- Talk is cheap, show me the code. RTFC

1. Geth 安装

Geth是以太坊协议的具体落地实现,通过Geth,你可以实现以太坊的各种功能,如账户的新建编辑删除,开启挖矿,ether币的转移,智能合约的部署和执行等等

安装命令:

brew tap ethereum/ethereum
brew install ethereum

检测版本


geth

1.1 安装remix

solidity是智能合约开发语言,基于javascript这是不言而喻的
remix 原名Browser-solidity 是一个官方提供的一个基于浏览器的合约编译器。

在线地址:https://remix.ethereum.org
以太坊源码,geth,钱包,remix都是开源软件,其中remix的
github地址:https://github.com/ethereum/remix-ide
在线可能网速慢,所以现在下载安装

根据git上的安装方式 ,好像有npm直接安装,之前用了方法ii
i) Remix-ide has been published as an npm module:

npm install remix-ide -g
remix-ide

ii) Or if you want to clone the github repository (wget need to be installed first) :

# Mac 一开始没有wget
brew install wget
git clone https://github.com/ethereum/remix-ide.git
cd remix-ide
npm install
npm run build && npm run serve

做完以上不走,命令行启动remix:

npm start 

然后在浏览器输入http://127.0.0.1:8080

l

1.3 安装mist

Mist是以太坊的官方钱包,他既可以连接生产网络、测试网络,更加可以通过设置参数的方式,连接我们自己的私有网络

直接上github下载:https://github.com/ethereum/mist/releases
选择最新的mist不用选择wallet,之前好像安装后会有选择public,会有很长时间更新链(而且占磁盘),这里选择私有打开,打开如下:

image.png

2. 尝试geth

新建文件夹运行geth

mkdir geth
cd geth
# 新文件夹运行geth
geth --datadir "./" --nodiscover console 2>>geth.log

然后输入

> web3.fromWei("425000000000000000000", "ether")
"425"

会出现


console

geth中一些类

eth:包含一些跟操作区块链相关的方法;
net:包含一些查看p2p网络状态的方法;
admin:包含一些与管理节点相关的方法;
miner:包含启动&停止挖矿的一些方法;
personal:主要包含一些管理账户的方法;
txpool:包含一些查看交易内存池的方法;
web3:包含了以上对象,还包含一些单位换算的方法。

常见命令:

personal.newAccount():创建账户;
personal.unlockAccount():解锁账户;
eth.accounts:枚举系统中的账户;
eth.getBalance():查看账户余额,返回值的单位是 Wei(Wei 是以太坊中最小货币面额单位,类似比特币中的聪,1 ether = 10^18 Wei);
eth.blockNumber:列出区块总数;
eth.getTransaction():获取交易;
eth.getBlock():获取区块;
miner.start():开始挖矿;
miner.stop():停止挖矿;
txpool.status:交易池中的状态;
admin.addPeer():连接到其他节点;
转换
web3.fromWei():Wei 换算成以太币;
web3.toWei():以太币换算成 Wei;

单位有:

kwei/ada
mwei/babbage
gwei/shannon
szabo
finney
ether

kether/grand/einstein
mether
gether
tether

你可能感兴趣的:(合约基础环境geremi, by Skyh)