1

I have written a smart contract to test event from java project using web3j I have prepared the web3j wrapper java class using solc compiler version "0.5.7+commit.6da8b019.Linux.g++"

I am using a private ethereum network to deploy the smart contract and execute method in smart contract.

The smart contract source is

pragma solidity ^0.5.7;

contract TestEvent {

    // Test Event will be received by java application
    event testEvent(string indexed message);


    function emitTestEvent(
        string  calldata message
    ) 
    external
    {
     emit testEvent(message);
    }
}

Java code to execute the method is

// Load broken smart contract build by solc version 0.5.7
        TestEvent contract = TestEvent.load("0x673ccae08d3c3f50f111fb9e5870c76bbbf60938",
                web3, credentials,
                GAS_PRICE, GAS_LIMIT);  // contract instance
        if (contract != null){
            TransactionReceipt transactionReceipt = contract.emitTestEvent("Message").send();
            System.out.println(transactionReceipt.toString());
        }

When executing the emitTestEvent method geth log output shows an error

"err="invalid opcode 0x1c"

enter image description here

What is the problem with my source code?

1

Opcode 0x1c is SHR or right shift, which was introduced in the recent update (more here). It was not available prior to February, 2019.

It is likely that your Java tool (web3j?) is out dated and does not recognize this opcode. You may be able to upgrade to a newer version which has Constantinople/St. Petersburg support.

1

That opcode is a recent addition to geth in the Constantinople release. You need to add the following to your genesis to enable Constantinople:

     "constantinopleBlock":0,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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