Python wrapper around the solc binary
Project description
# py-solc
[![Build Status](https://travis-ci.org/pipermerriam/py-solc.png)](https://travis-ci.org/pipermerriam/py-solc)
[![PyPi version](https://pypip.in/v/py-solc/badge.png)](https://pypi-hypernode.com/pypi/py-solc)
[![PyPi downloads](https://pypip.in/d/py-solc/badge.png)](https://pypi-hypernode.com/pypi/py-solc)
Python wrapper around the `solc` Solidity compiler.
# Dependency
This library requires the `solc` executable to be present.
Only versions `>=0.4.2` are supported and tested though this library may work
with other versions.
[solc installation instructions](http://solidity.readthedocs.io/en/latest/installing-solidity.html)
# Quickstart
Installation
```sh
pip install py-solc
```
```python
>>> from solc import compile_source, compile_files, link_code
>>> compile_source("contract Foo { function Foo() {} }")
{
'Foo': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
}
>>> compile_files(["/path/to/Foo.sol", "/path/to/Bar.sol"])
{
'Foo': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
'Bar': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
}
>>> unlinked_code = "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273__TestA_________________________________90630c55699c906064906000906004818660325a03f41560025750505056"
>>> link_code(unlinked_code, {'TestA': '0xd3cda913deb6f67967b99d67acdfa1712c293601'})
... "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273d3cda913deb6f67967b99d67acdfa1712c29360190630c55699c906064906000906004818660325a03f41560025750505056"
```
## Setting the path to the `solc` binary
You can use the environment variable `SOLC_BINARY` to set the path to your solc binary.
## Import path remappings
`solc` provides path aliasing allow you to have more reusable project configurations.
You can use this like:
```
from solc import compile_source, compile_files, link_code
compile_files([source_file_path], import_remappings=["zeppeling=/my-zeppelin-checkout-folder"])
```
[More information about solc import aliasing](http://solidity.readthedocs.io/en/develop/layout-of-source-files.html#paths)
[![Build Status](https://travis-ci.org/pipermerriam/py-solc.png)](https://travis-ci.org/pipermerriam/py-solc)
[![PyPi version](https://pypip.in/v/py-solc/badge.png)](https://pypi-hypernode.com/pypi/py-solc)
[![PyPi downloads](https://pypip.in/d/py-solc/badge.png)](https://pypi-hypernode.com/pypi/py-solc)
Python wrapper around the `solc` Solidity compiler.
# Dependency
This library requires the `solc` executable to be present.
Only versions `>=0.4.2` are supported and tested though this library may work
with other versions.
[solc installation instructions](http://solidity.readthedocs.io/en/latest/installing-solidity.html)
# Quickstart
Installation
```sh
pip install py-solc
```
```python
>>> from solc import compile_source, compile_files, link_code
>>> compile_source("contract Foo { function Foo() {} }")
{
'Foo': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
}
>>> compile_files(["/path/to/Foo.sol", "/path/to/Bar.sol"])
{
'Foo': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
'Bar': {
'abi': [{'inputs': [], 'type': 'constructor'}],
'code': '0x60606040525b5b600a8060126000396000f360606040526008565b00',
'code_runtime': '0x60606040526008565b00',
'source': None,
'meta': {
'compilerVersion': '0.3.5-9da08ac3',
'language': 'Solidity',
'languageVersion': '0',
},
},
}
>>> unlinked_code = "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273__TestA_________________________________90630c55699c906064906000906004818660325a03f41560025750505056"
>>> link_code(unlinked_code, {'TestA': '0xd3cda913deb6f67967b99d67acdfa1712c293601'})
... "606060405260768060106000396000f3606060405260e060020a6000350463e7f09e058114601a575b005b60187f0c55699c00000000000000000000000000000000000000000000000000000000606090815273d3cda913deb6f67967b99d67acdfa1712c29360190630c55699c906064906000906004818660325a03f41560025750505056"
```
## Setting the path to the `solc` binary
You can use the environment variable `SOLC_BINARY` to set the path to your solc binary.
## Import path remappings
`solc` provides path aliasing allow you to have more reusable project configurations.
You can use this like:
```
from solc import compile_source, compile_files, link_code
compile_files([source_file_path], import_remappings=["zeppeling=/my-zeppelin-checkout-folder"])
```
[More information about solc import aliasing](http://solidity.readthedocs.io/en/develop/layout-of-source-files.html#paths)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-solc-0.7.0.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file py-solc-0.7.0.tar.gz
.
File metadata
- Download URL: py-solc-0.7.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8f7cc0d6c48eaeaedd36beda392e76833f18c38d073c47b5c4c7115adbfed52 |
|
MD5 | 0411b1d054ef4f97053ae35c0f4098b4 |
|
BLAKE2b-256 | 61ac91e4fc0dd7885b50800de94beedcf1d735e091966e7adceb07b62c6775e2 |
File details
Details for the file py_solc-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: py_solc-0.7.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d7d4557b41a836498ed5a25b87e9800849d50ee456211e41b101b9047ea11b |
|
MD5 | 48483cd0953562bebb9a2aab4c9a637f |
|
BLAKE2b-256 | 258d9750cf85b9ba03952228fe5690ee87930b3fc4b75d4e58db5a83db54d45a |