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-path
string with the path where the .sol source files are residing, relative to the projects root path.:build-path
string 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, iftrue
contracts are compiled into truffle artifacts, that can be required and deployed with truffle.:contracts
vector of files with the Solidity contracts source code, relative to the src-path directory (you can also specify sub-directories), or:all
to 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-count
boolean, iftrue
after succesfull compilation the number of bytes in the compiled.bin
file will be printed to the STDOUT. Only valid if:bin?
is set totrue
.:optimize-runs
(optional) map of contract filenames and parametern
values, where0 <= n < inf
is 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 once
which is equivalent to lein solc
. You can also watch the :contracts
files and re-compile them on changes if you do:
$ lein solc auto