CLI tool to help you do two things:
- Generate (
write
) asolc --standard-json
compatible file deterministically - Automatically verify (
verify
) a deployed contract on etherscan.
wget https://github.com/hjubb/solt/releases/download/v0.5.2/solt-linux-x64 -O ~/.local/bin/solt
chmod +x ~/.local/bin/solt
wget https://github.com/hjubb/solt/releases/download/v0.5.2/solt-mac -O ~/.local/bin/solt
chmod +x ~/.local/bin/solt
Creates a standard-json
compatible file.
solt write [directory or solidity file]
Optional flags
--no-optimization
-no-opt
Flag for whether to exclude optimization in the output--runs
-r
[number] Number of optimization runs, only used when optimizing, by default 200--npm
Flag for whether this project uses npm style imports (node_modules)--output
[string] Output file name (defaults to solc-input-[file].json)--help
-h
Usage info
Note that you are expected to run this from the root of your Solidity project. That is, from the same directory where "node_modules" can be found. Otherwise, certain features like the --npm
flag will not work.
Verifies contract on etherscan
solt verify [output.json] [contract address] [contract name in output-file] [--compiler solc-version]
Required flags:
--compiler
-c
[string] the compiler version used, e.g. 'v0.6.12'
Optional flags:
--license
-l
[string] License according to etherscan, valid codes 1-12 where 1=No License .. 12=Apache 2.0, see https://etherscan.io/contract-license-types--network
-n
[string] The network name [rinkeby, kovan etc], defaults to mainnet--infura
[string] Optional infura API key (if the shared one is rate limited)--etherscan
[string] Optional etherscan API Key (if the shared one is rate limited)--help
-h
Usage info
- Generate
standard-json
input format
git clone https://github.com/MainframeHQ/mainframe-lending-protocol.git /tmp/example
cd /tmp/example
yarn install # installs node dependencies
solt write contracts --npm
# solc-input-contracts.json is generated
- Verify on etherscan
solt verify solc-input-contracts.json <deployed address> <contract name>
# You can obtain your contract name using the following command
# $ cat solc-input-contracts.json | jq .sources | jq 'keys'
Flattening your solidity code before verifying them on etherscan is not recommended. Yet it seems to be the most common approach for verification on etherscan.
While this is fine for small projects, you run into weird edge cases where flattening your code will yield different bytecodes from the deployed ones as the complexity of your code grows. This could be due to the usage of experimental features such as ABIEncoderV2
in your source code, and/or the usage of abosolute file paths when compiling your contracts (see here).
One approach that has worked consistently was using the compiler standard-json input method, which is also used by buidler behind the scenes.
solt
was built as we wanted a static-binary that could:
- Generate a
standard-json
file forsolc
- Be configured without any
.config.js
file - Programmatically obtain the abi encoded constructor args to ease the etherscan verification process
Did solt
save you engineering time? Any donations will be greatly appreciated!