ETH节点命令

更新于:2019-11-07

更多区块链信息可查看:https://blog.csdn.net/ted_sky/article/details/102932065

ETH Config

geth节点启动命令

进入启动程序目录:/本地源码目录/go-ethereum/build/bin

启动节点命令

主网

./geth --identity "eth" --datadir "/本地源码目录/data"  --rpc --rpcapi "db,net,web3,eth,personal,miner" --rpccorsdomain "*"  --rpcaddr 0.0.0.0 --rpcport 8545 --networkid 1 console 2>> eth.log

测试网

./geth --testnet --datadir "/本地源码目录/testdata"  --rpc --rpcapi "db,net,web3,eth,personal,miner" --rpccorsdomain "*"  --rpcaddr 0.0.0.0 --rpcport 8545 --networkid 3 console 2>> eth.log

--testnet表示选择的是ropsten测试网络,如果想要同步rinkeby测试网络,可以更换参数--testnet为--rinkeby

参数名称参数描述
identity区块链的标示,用于标示目前网络的名字
nodiscover私有链地址,不会被网上看到
datadir设置当前区块链网络数据存放的位置
rpc开启rpc通道
rpcapi要开放哪些rpc api,默认eth,net,web3
rpccorsdomain允许能连接到你的节点执行rpc api的url,使用逗号分隔。*表示任何url都可以连接
rpcaddrHTTP-RPC服务器接口地址,默认为localhost
rpcportHTTP-RPC服务器端口地址,默认为8545
networkid网络标识,私有链取一个大于4的随意的值
console启动命令行模式,可以在Geth中执行命令
verbosity日志详细度:0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail(default: 3)
2>> eth.log 表示把控制台日志输出到eth.log文件。新开一个命令行终端,运行tail -f geth.log命令来实时显示日志,这样日志信息就不会出现在终端中,让你在终端运行命令的时候可读性较差

Geth uses port 30303 for connections to peers.

以太坊常用networkid

IDNAME
1main network
3Ropsten
4Rinkeby
42Kovan
其它数字为个人自定义私有网络

0: Olympic, Ethereum public pre-release PoW testnet
1: Frontier, Homestead, Metropolis, the Ethereum public PoW main network
1: Classic, the (un)forked public Ethereum Classic PoW main network, chain ID 61
1: Expanse, an alternative Ethereum implementation, chain ID 2
2: Morden Classic, the public Ethereum Classic PoW testnet(deprecated)
3: Ropsten, the public cross-client Ethereum PoW testnet
4: Rinkeby, the public Geth-only PoA testnet
5: Goerli, the public cross-client PoA testnet
6: Kotti Classic, the public cross-client PoA testnet for Classic
8: Ubiq, the public Gubiq main network with flux difficulty chain ID 8
42: Kovan, the public Parity-only PoA testnet
60: GoChain, the GoChain networks mainnet
77: Sokol, the public POA Network testnet
99: Core, the public POA Network main network
100: xDai, the public MakerDAO/POA Network main network
31337: GoChain testnet, the GoChain networks public testnet
401697: Tobalaba, the public Energy Web Foundation testnet
7762959: Musicoin, the music blockchain
61717561: Aquachain, ASIC resistant chain
[Other]: Could indicate that your connected to a local development test network.

进入控制台

./geth attach ipc:/本地数据目录/geth.ipc

erc20 智能合约各方法对应的签名编码

  • 常见例如:transfer(address,uint256)
    编码为:web3.sha3(“transfer(address,uint256)”).substring(0,10) -> “0xa9059cbb”
  • balanceOf(address)
    编码为:web3.sha3(“balanceOf(address)”).substring(0,10) -> “0x70a08231”
方法编码
transfer(address,uint256)0xa9059cbb
balanceOf(address)0x70a08231
decimals()0x313ce567
allowance(address,address)0xdd62ed3e
symbol()0x95d89b41
totalSupply()0x18160ddd
name()0x06fdde03
approve(address,uint256)0x095ea7b3
transferFrom(address,address,uint256)0x23b872dd

erc20 交易

传输数据:

Function: transfer(address _to, uint256 _value)

0xa9059cbb0000000000000000000000000797350000000000000000000000000000000000000000000005150ac4c39a6f3f0000

将数据分解为适当的块:

0x                                                     // Hex prefix
a9059cbb                                               // web3.sha3("transfer(address,uint256)").substring(0,10) => "0xa9059cbb"
0000000000000000000000000797350000000000               // address - 40 characters
000000000000000000000000000000000005150ac4c39a6f3f0000 // value - 54 characters - should be 64 characters
 
// Ruler below 
1234567890123456789012345678901234567890123456789012345678901234

值字段将用零填充以组成64个字符:

// Intended transfer amount
// new BigNumber("5150ac4c39a6f3f0000",16).div(1e18)
// 23999.99
000000000000000000000000000000000005150ac4c39a6f3f0000
 
// Actual transfer instruction
// new BigNumber("5150ac4c39a6f3f00000000000000",16).div(1e18)
26388268071507722.24
000000000000000000000000000000000005150ac4c39a6f3f00000000000000
 
// Ruler below 
1234567890123456789012345678901234567890123456789012345678901234
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值