Skip to main content

A Python wrapper for the Solidity compiler. Switch between versions, compile, and manage artifacts.

Project description

Solcix

Version Release Python Versions Code Style Activity License

Solcix is a Solidity version manager written in Python that allows for seamless switching between versions, easy compilation, and simple management of artifacts.

asciicast

Installation

To install Solcix, you can use pip, the Python package manager:

With pip For Windows

pip install solcix

With pip3 For Linux / Mac

pip3 install solcix

With pipx

pipx installs packages in their own virtual environment, so there's less chance of conflicting dependencies. You can run the following command in your terminal to install:

pipx install solcix

With poetry

Uses the poetry package manager to install solcix in a project-specific virtual environment. poetry manages dependencies for you and allows you to isolate your project from the global environment. You can run the following command in your terminal to add solcix to your poetry project, and use our wrapped solc api in your code:

poetry add solcix

With pipenv

Uses the pipenv package manager to install solcix in a project-specific virtual environment. pipenv also manages dependencies and isolates your project from the global environment, and use our wrapped solc api in your code. You can run the following command in your terminal to install:

pipenv install solcix

With pip for main branch

You can also install solcix from github main branch:

pip install git+https://github.com/Solratic/solcix.git@main

Enable Auto-Completion

Enable auto-completion for solcix by running the following command:

With Bash

_SOLCIX_COMPLETE=bash_source solcix > ~/.solcix-complete.bash
source ~/.solcix-complete.bash

With Zsh

_SOLCIX_COMPLETE=zsh_source solcix > ~/.solcix-complete.zsh
source ~/.solcix-complete.zsh

With Fish

_SOLCIX_COMPLETE=fish_source solcix > ~/.config/fish/completions/solcix.fish

Usage - CLI

Solcix can be used as a library or as a command line tool. Here are the available commands:

Listing available Solidity compilers

The ls command can be used to list all available versions of the Solidity compiler:

Example usage:

solcix ls

Installing Solidity compilers

The install command can be used to install one or more versions of the Solidity compiler:

Example usage:

solcix install 0.8.4 0.7.6 latest

Listing installed Solidity compilers

The installed command can be used to list all available versions of the Solidity compiler:

Example usage:

solcix installed

If global / local version is set, it will be displayed as below:

0.5.0
0.8.0
0.8.16
0.8.17
0.8.18 <- current
0.8.19

Switching between Solidity compilers

The use command can be used to switch between installed versions of the Solidity compiler, either globally or locally.

  • If the specified version is not installed, it will be installed automatically.

  • If you use the local option, it will create a .solcix file in the current directory.

Example usage:

# Setting global version to 0.8.16
solcix use global 0.8.16
# Setting local version to 0.8.16, it will create a .solcix file in the current directory
solcix use local 0.8.16
# You can also use the alias `latest` to use the latest version
solcix use global latest

Simply run the command will see the changes:

solc --version

Show current Solidity compiler version

The current command can be used to show the current version of the Solidity compiler (local version takes precedence over global version):

Example usage:

solcix current

Uninstalling Solidity compilers

The uninstall command can be used to uninstall one or more versions of the Solidity compiler:

solcix uninstall 0.8.4 0.7.6

Uninstall all Solidity compilers

To uninstall all versions of Solidity compiler that have been installed using solcix, you can use the following command:

solcix purge

This will remove all versions of the Solidity compilers that have been installed by solcix, all cached files, and the solcix configuration file (local config takes precedence over global config).

Verify Solidity compilers

The verify command is used to verify the checksums of installed solc binaries and to reinstall any that are malformed.

Example usage:

solcix verify 0.8.0 0.8.1

Clear cache of Solidity compilers

The clear command is used to remove all cached files. The cache is used to store the downloaded file list. The binary will not be deleted.

Example usage:

solcix clear

Compile Solidity files

The compile command is used to compile Solidity files and print the result. If the output is a TTY, the result will be formatted. Otherwise, the result will be printed as a JSON string.

Example usage:

solcix compile <file.sol>

The command also supports the -o or --output option to specify an output directory for the compilation result.

Example usage:

solcix compile <filename>.sol -o <output_dir>

Additional optional arguments can be passed to the command using the kwargs argument, it will be taken by the solc command.

Example usage:

solcix compile <file.sol> --optimize=True --optimize-runs=200 --overwrite=True

Or you can redirect the output to a single json file:

solcix compile <file.sol> > output.json

Resolve compatible versions from solidity file

The resolve command is used to determine the recommended solc version for a Solidity file based on its pragma statement. It can also be used to list all versions that are compatible with the Solidity file.

Example usage:

solcix resolve <file.sol>

By default, the command prints the recommended solc version for the Solidity file.

Solidity Example:

// SPDX-License-Identifier: MIT
// compiler version must be `0.8.5`, `0.8.6` or `0.8.7`
pragma solidity >=0.8.5 <=0.8.7;
contract HelloWorld {
    string public greet = "Hello World!";
}

Example output:

The recommended version is 0.8.5, use `solcix resolve --no-recommand` to see all compatible versions.

If the --no-recommand option is used, the command will print all compatible versions for the Solidity file.

Example output:

These versions are compatible with the pragma.
0.8.5
0.8.6
0.8.7

Upgrade Solcix

The upgrade command is used to upgrade the architecture of the installed solc binaries, it will remove all old binaries and download the new ones.

Example usage:

pip3 install -U

# Migrate to the new architecture and Reinstall all binaries
solcix upgrade

Project Acknowledgements

We would like to thank the original projects solc-select and py-solc-x for providing excellent code base, upon which we have optimized and improved to make the project more robust and user-friendly.

Our project is an improved and optimized version of solc-select and py-solc-x, with more features and excellent performance.

If you enjoyed the original projects, we strongly recommend trying out our project to enjoy a better user experience and more efficient code execution.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solcix-0.1.8.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

solcix-0.1.8-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file solcix-0.1.8.tar.gz.

File metadata

  • Download URL: solcix-0.1.8.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.0 Linux/5.15.0-1035-azure

File hashes

Hashes for solcix-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d6dfdac0ceca219609f90a26d334501ef7ba17a1b2b5cfc0d813320656123dc1
MD5 4b658237a17d97a0c8c44a49360db73c
BLAKE2b-256 d08f4b28ae2431406a03c8c9109204e228f5f576cf9f356951d4d5d04089ddde

See more details on using hashes here.

File details

Details for the file solcix-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: solcix-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.0 Linux/5.15.0-1035-azure

File hashes

Hashes for solcix-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ffe370a30cb029e89d452516f7b16fc0ff5a520f0be0de57d4acdad92cfd0020
MD5 8b7cdf2a0a16720c9153b079c0584ad8
BLAKE2b-256 39fab6e3bfb855e1a81bfb87575e85d5e105c9d2553a3a9a1027b8920e6e551e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page