-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to load Solidity contract using compile_standard
function due to error Second argument needs to be a buffer
#42
Comments
I tried changing to the following in https://github.com/ltfschoen/geth-node/blob/master/scripts/main.py and passed additional arguments defined in https://github.com/ethereum/py-solc/blob/master/solc/wrapper.py to the Changes to https://github.com/ethereum/py-solc/blob/master/solc/wrapper.py
Changes to https://github.com/ltfschoen/geth-node/blob/master/scripts/main.py
But it just outputs binary files in the current directory instead of assigning to the variable |
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: