macOS 安装solidity编译器

587 阅读1分钟

1.安装geth

安装教程:https://geth.ethereum.org/docs/getting-started/installing-geth

2.安装solidity 编译.sol结尾文件

https://learnblockchain.cn/docs/solidity/installing-solidity.html#macos-packages

3.安装abigen 编译生成.go文件

https://geth.ethereum.org/docs/tools/abigen

4.编译文件 cd到.sol结尾的文件夹

ps:注意带上输出文件夹 -o build

solc --abi Store.sol -o build

5.cd 到build 文件夹 执行: 会生成.go文件

abigen --abi Store.abi --pkg main --type Store --out Store.go

6.为了从Go部署智能合约,我们还需要将solidity智能合约编译为EVM字节码 生成.bin包

solc --bin Store.sol -o build

7.现在我们编译Go合约文件,其中包括deploy方法,因为我们包含了bin文件。

abigen --bin=Store.bin --abi=Store.abi --pkg=store --out=Store.go