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"
What is the problem with my source code?
Best Answer
That opcode is a recent addition to geth in the Constantinople release. You need to add the following to your genesis to enable Constantinople: