full-blockchain-solidity-course-py
full-blockchain-solidity-course-py copied to clipboard
Given this code, i get KeyError: 'evm'
Given this code:
from solcx import compile_standard, install_solc
import json
install_solc("0.6.0")
with open("./SimpleStorage.sol", "r") as file:
simple_storage_file = file.read()
# compile our solidity
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.bytecode.sourceMap"]}
}
},
},
)
with open("compiled_code.json", "w") as file:
json.dump(compiled_sol, file)
# get bytecode
bytecode = compiled_sol["contracts"]["SimpleStorage.sol"]["evm"]["bytecode"]["object"]
# get abi
abi = compiled_sol["contracts"]["SimpleStorage.sol"]["SimpleStorage"]["abi"]
print(abi)
Originally posted by @spencergoff in https://github.com/smartcontractkit/full-blockchain-solidity-course-py/discussions/780