You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
py-solc Version: 2.1.0 (shown when running pip list)
solc Version: 0.4.18+commit.9cf6e910.Emscripten.clang (shown when running solc --version)
Python Version: 3.6.4rc1 (shown when running python --version)
OS: osx - macOS 10.12.6
What was wrong?
I used PyEnv to install and switch to the latest Python version 3.6.4rc1 https://github.com/pyenv/pyenv. I then installed the following Python packages:
In the file I use py-solc to compile Solidity source code from a file using the function compile_files, but I get a full output error in Bash terminal as follows:
$ python main.py
Traceback (most recent call last):
File "main.py", line 3, in <module>
compiled_sol = compile_files(["FixedSupplyToken.sol"])
File "/Users/Ls/.pyenv/versions/3.6.4rc1/lib/python3.6/site-packages/solc/main.py", line 133, in compile_files
stdoutdata, stderrdata, command, proc = solc_wrapper(**compiler_kwargs)
File "/Users/Ls/.pyenv/versions/3.6.4rc1/lib/python3.6/site-packages/solc/utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/Users/Ls/.pyenv/versions/3.6.4rc1/lib/python3.6/site-packages/solc/wrapper.py", line 165, in solc_wrapper
stderr_data=stderrdata,
solc.exceptions.SolcError: An error occurred during execution
> command: `solc --combined-json abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,userdoc FixedSupplyToken.sol`
> return code: `1`
> stderr:
> stdout:
Invalid option selected, must specify either --bin or --abi
$ python main.py
Traceback (most recent call last):
File "main.py", line 10, in <module>
}, allow_paths="./contracts/")
File "/Users/Ls/.pyenv/versions/3.6.4rc1/lib/python3.6/site-packages/solc/main.py", line 161, in compile_standard
**kwargs
File "/Users/Ls/.pyenv/versions/3.6.4rc1/lib/python3.6/site-packages/solc/utils/string.py", line 85, in inner
return force_obj_to_text(fn(*args, **kwargs))
File "/Users/Ls/.pyenv/versions/3.6.4rc1/lib/python3.6/site-packages/solc/wrapper.py", line 165, in solc_wrapper
stderr_data=stderrdata,
solc.exceptions.SolcError: An error occurred during execution
> command: `solc --allow-paths file:///Users/Ls/code/blockchain/geth-node/contracts/ --standard-json`
> return code: `1`
> stderr:
> stdout:
/Users/Ls/.nvm/versions/node/v8.7.0/lib/node_modules/solc/node_modules/graceful-fs/polyfills.js:144
throw er
^
TypeError: Second argument needs to be a buffer
at Object.fs.readSync (fs.js:682:18)
at Object.readSync (/Users/Ls/.nvm/versions/node/v8.7.0/lib/node_modules/solc/node_modules/graceful-fs/polyfills.js:138:28)
at Object.<anonymous> (/Users/Ls/.nvm/versions/node/v8.7.0/lib/node_modules/solc/solcjs:65:18)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
It highlighted that that object we are passing to compile_standard is an Input JSON Description, which the compiler API expects to be in JSON format, and it outputs the compilation result in a JSON formatted output.
When looked more closely at the error, which says solc --allow-paths file:///Users/Ls/code/blockchain/geth-node/contracts/ --standard-json, it's clearly missing a JSON file as an input argument at the end.
Is this something that the compiler is supposed to automatically generate? A similar error was raised in the solc-js repo issues here ethereum/solc-js#126
I tried experimenting a bit more trying to find an alternative and found that I'm able to manually created ABI files in Bash terminal with the command: solc --abi FixedSupplyToken.sol --output-dir ./build, which generates the following in the ./build/ folder:
__FixedSupplyToken_sol_ERC20Interface.abi
__FixedSupplyToken_sol_FixedSupplyToken.abi
But I don't know how to load these generated ABI files into the variable contract_interface in main.py. Currently my code is contract_interface = compiled_sol['<stdin>:FixedSupplyToken'],
I then tried copying the JSON argument into a file called test.json. test.json
...
if abi:
command.append('--abi')
if source_files is not None:
# command.extend(source_files)
command.append(source_files['sources']['FixedSupplyToken.sol']['urls'][0])
...
py-solc
Version: 2.1.0 (shown when runningpip list
)solc
Version: 0.4.18+commit.9cf6e910.Emscripten.clang (shown when runningsolc --version
)python --version
)What was wrong?
I used PyEnv to install and switch to the latest Python version 3.6.4rc1 https://github.com/pyenv/pyenv. I then installed the following Python packages:
I then created and executed a Python file i.e. main.py with
python main.py
:main.py
Note that the Solidity file I am using is in my repo here https://github.com/ltfschoen/geth-node/blob/master/contracts/FixedSupplyToken.sol, and it compiles successfully with solc v0.4.18, as I've done so in MIST and deployed it to a Private Network previously already.
I'm trying to replicate using Web3.py and py-solc the same functionality that worked when I used Web3.js and solc-js here: https://github.com/ltfschoen/geth-node/blob/master/scripts/main.js
In the file I use py-solc to compile Solidity source code from a file using the function
compile_files
, but I get a full output error in Bash terminal as follows:I then looked closer at the Py-Solc documentation here: https://github.com/ethereum/py-solc#standard-json-compilation, and changed my code to use the same syntax as the second example under the heading "Standard JSON Compilation":
main.py
But when I run this it gives another error in the Bash terminal, which is because the example is missing a
{
just before'urls'
:So I added the missing
{
, and I used a JSON Validator to make sure the argument was valid json format:main.py
But then it gave me error:
So then I clicked the link that says "Solidity Documentation for Standard JSON input and ouptup format" (FYI, note the typo here in the word "output") http://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description, specifically the section http://solidity.readthedocs.io/en/develop/using-the-compiler.html#input-description.
It highlighted that that object we are passing to
compile_standard
is an Input JSON Description, which the compiler API expects to be in JSON format, and it outputs the compilation result in a JSON formatted output.When looked more closely at the error, which says
solc --allow-paths file:///Users/Ls/code/blockchain/geth-node/contracts/ --standard-json
, it's clearly missing a JSON file as an input argument at the end.Is this something that the compiler is supposed to automatically generate? A similar error was raised in the solc-js repo issues here ethereum/solc-js#126
I tried experimenting a bit more trying to find an alternative and found that I'm able to manually created ABI files in Bash terminal with the command:
solc --abi FixedSupplyToken.sol --output-dir ./build
, which generates the following in the ./build/ folder:But I don't know how to load these generated ABI files into the variable
contract_interface
in main.py. Currently my code iscontract_interface = compiled_sol['<stdin>:FixedSupplyToken']
,I then tried copying the JSON argument into a file called test.json.
test.json
I then ran the following:
But it just returned the following;
So I don't even understand how to use the CLI.
Any help greatly appreciated
I've pushed my latest code here: https://github.com/ltfschoen/geth-node/blob/master/scripts/main.py
Cute Animal Picture
The text was updated successfully, but these errors were encountered: