Skip to content

hjubb/solt

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

solt

Solidity Tool

Build GitHub tag (latest SemVer pre-release)

CLI tool to help you do two things:

  1. Generate (write) a solc --standard-json compatible file deterministically
  2. Automatically verify (verify) a deployed contract on etherscan.

Install

Linux

wget https://github.com/hjubb/solt/releases/download/v0.5.2/solt-linux-x64 -O ~/.local/bin/solt
chmod +x ~/.local/bin/solt

Mac

wget https://github.com/hjubb/solt/releases/download/v0.5.2/solt-mac -O ~/.local/bin/solt
chmod +x ~/.local/bin/solt

API

Write

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.

Verify

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

Usage example

  1. 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
  1. 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'

Why does this exist?

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:

  1. Generate a standard-json file for solc
  2. Be configured without any .config.js file
  3. Programmatically obtain the abi encoded constructor args to ease the etherscan verification process

Sponsor

Did solt save you engineering time? Any donations will be greatly appreciated!

❤️ Sponsor

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages