一、安装环境
- 安装geth客户端 (默认安装目录 /usr/local/Cellar/ethereum/版本)
brew tap ethereum/ethereum
brew install ethereum
- 进入bin目录创建genesis.json
{
"config":{
"chainId":666,
"homesteadBlock":0,
"eip150Block":0,
"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block":0,
"eip158Block":0,
"byzantiumBlock":0,
"constantinopleBlock":0,
"petersburgBlock":0,
"istanbulBlock":0,
"ethash":{
}
},
"nonce":"0x0",
"timestamp":"0x5ddf8f3e",
"extraData":"0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit":"0x47b760",
"difficulty":"0x00002",
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase":"0x0000000000000000000000000000000000000000",
"alloc":{
"0x1e82968C4624880FD1E8e818421841E6DB8D1Fa4":{
"balance":"30000000000000000000"
}
},
"number":"0x0",
"gasUsed":"0x0",
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000"
}
- 初始化
geth --datadir "/usr/local/Cellar/ethereum/版本/bin/chain" init genesis.json
二、编译智能合约
- 安装solc编译工具(需要有node环境)
npm install -g solc
- 进行编译
solcjs sol文件目录/Person.sol --bin --abi --optimize -o 目标路径
三、安装web3j CLI,打包智能合约
- 安装web3j
wegt curl -L https://get.web3j.io | sh 或 https://github.com/web3j/web3j/releases 直接下载
- 打包编译好的智能合约文件
./web3j solidity generate 目录/.bin 目录/.abi -o 文件夹 -p 目录