A Leiningen plugin for compiling Solidity smart contracts.
lein-solc is available from Clojars. The latest released version is:
Add it to the :plugins vector of your project.clj.
Plugin assumes solc compiler is installed and on your $PATH.
You can specify the contracts to compile by adding an :solc map to your project.clj.
It takes the following key value pairs:
:src-pathstring with the path where the .sol source files are residing, relative to the projects root path.:build-pathstring with the path where the compiled output is written to, relative to the projects root directory.:abi?(optional) boolean, iftrue(default) output includes contract's abi interfaces.:bin?(optional) boolean, iftrue(default) output includes contract's bytecode.:truffle-artifacts?(optional) boolean, iftruecontracts are compiled into truffle artifacts, that can be required and deployed with truffle.:contractsvector of files with the Solidity contracts source code, relative to the src-path directory (you can also specify sub-directories), or:allto compile all of the contracts in the root of the src-path.:solc-err-only(optional) boolean, iftrue(default value) only compilation errors will be reported to the STDOUT.:verbose(optional) boolean, iffalse(default value) the STDOUT output is limited to the most important information.:byte-countboolean, iftrueafter succesfull compilation the number of bytes in the compiled.binfile will be printed to the STDOUT. Only valid if:bin?is set totrue.:optimize-runs(optional) map of contract filenames and parameternvalues, where0 <= n < infis an estimated number of contract runs for optimizer tuning. It represents a trade-off between a smaller bytecode (low values) and cheaper transaction costs (high values).
Example:
:solc {:src-path "resources/contracts/src"
:build-path "resources/contracts/build/"
:contracts ["MyContract.sol" "sub/MySecondContract.sol"]
:byte-count true
:optimize-runs {"MyContract.sol" 1}}The contracts in :contracts will be compiled when you do:
$ lein solc oncewhich is equivalent to lein solc. You can also watch the :contracts files and re-compile them on changes if you do:
$ lein solc auto