Empty Json File #1484
Answered
by
cromewar
praxis-dev
asked this question in
Q&A
Empty Json File
#1484
-
Hi! At 3:46:56 Patrick is creating a json file with a compiled code inside. My file is empty. What do yo suggest? from solcx import compile_standard, install_solc
import json
with open("./SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()
print(simple_storage_file)
install_solc("0.6.0")
compiled_sol = compile_standard(
{
"language": "Solidity",
"sources": {"SimpleStorage.sol": {"content": simple_storage_file}},
"settings": {
"outputSelection": {
"*": {"*": ["abi", "metadata", "evm.bytecode", "evm.sourceMap"]}
}
},
},
)
with open("compiled_code.json", "w") as files:
json.dump(compiled_sol, file) There is also a "ValueError: I/O operation on closed file." message in the Terminal. |
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
May 16, 2022
Replies: 1 comment 1 reply
-
Hello @vaporm with open("compiled_code.json", "w") as files:
json.dump(compiled_sol, file) You are opening the file as "files" and then you use Cheers. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
cromewar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @vaporm
you have a typo here:
You are opening the file as "files" and then you use
json.dump
to "file" without "s" so the name have a mismatch.Cheers.