I am getting error while deploying smart contracts with web3.py. The error says "web3.exceptions.ContractLogicError: execution reverted: VM Exception while processing transaction: invalid opcode". I have included the solidity contract along with web3.py code and error logs. Am i doing the correct way or there is some other issues? Thanks in advance.

web3.py code to interact with smart contract solidity contract error message

1 Answer 1


It's possible your blockchain doesn't support the Shanghai update. Since solidity v 0.8.20, the compiler implements the new opcode PUSH0, which your blockchain might think it's invalid.

So, change the solidity version from:

pragma solidity >=0.7.0 <0.9.0;


pragma solidity >=0.7.0 <0.8.20;
  • i changed to version and got the following error "web3.exceptions.ContractLogicError: execution reverted: VM Exception while processing transaction: revert". Thanks. Oct 13, 2023 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.