solc编译器
github网址:https://github.com/ethereum/solc.js
知乎大佬小结:solc编译器分析 - 粒子区块链的文章 - 知乎 https://zhuanlan.zhihu.com/p/164633644
腾讯云大佬总结 https://cloud.tencent.com/developer/article/1355940#undefined
插入命令
npm install -g solc
yarn solcjs --help
yarn solcjs --version //确保使用正确版本
yarn global add solc@0.8.7-fixed
yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol
编译sol生成二进制文件,且指定目录和生成文件目录,跟remix编译生成结果一样
在vscode的package.json加入编译命令
{ "dependencies": { "node-windows": "^1.0.0-beta.7", "solc": "^0.8.7-fixed" }, "script":{ "compile":"yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol" } }
然后终端执行yarn compile,比较快捷
编译xx.sol,其中d:\\xx.sol为编译文件,d:\\为生成目录,默认d:\\F_,需手动建立F_文件夹
solcjs D:\\xx.sol --optimize --bin --abi --output-dir D:\\
编译成功后生成abi文件和bin文件