Environment, Ubuntu 18.04:

bs@dharma ~/Schau $ geth version
Version: 1.9.3-stable
Git Commit: cfbb969da803d4cc92e1a64fc1b3c06db299b564
Architecture: amd64
Protocol Versions: [63]
Network Id: 1
Go Version: go1.11.5
Operating System: linux

I am running on a private chain (I'm just experimenting :-). I'm testing this smart contract:

pragma solidity ^0.5.0;

contract Doubler {
    function execute(int a) public pure returns(int) {
        return a + a;

I compile with:

solc -o target --bin --abi Doubler.sol

I embed the Doubler.bin and Doubler.abi in a javascript:

var doublerFactory = web3.eth.contract([{"constant":true,"inputs":[{"internalType":"int256","name":"a","type":"int256"}],"name":"execute","outputs":[{"internalType":"int256","name":"ok","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"}]);
var doublerCompiled = "0x6080604052348015600f57600080fd5b5060ad8061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063a04d2faf14602d575b600080fd5b605660048036036020811015604157600080fd5b8101908080359060200190929190505050606c565b6040518082815260200191505060405180910390f35b6000818201905091905056fea265627a7a72315820e98e8a5d85a2c5f21ce56899d6eadc9b93fadf694dba07ba2efbd43c8735b94664736f6c634300050b0032";

var doubler = doublerFactory.new({from:web3.eth.accounts[0],data:doublerCompiled,gas:200000}, function(e, contract) {
    if (e) {

    if (!contract.address) {
        console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
    } else {
        console.log("Contract mined! Address: " + contract.address);

I run geth, and in the console I unlock my account and start the miner:

personal.unlockAccount("account", "password", 0)

Then I paste the above javascript into the console and after a while I see the messages:

Contract transaction send: TransactionHash: 0x7c24585dbd5d2c9757ad5b40cf0180a699dc52563b86c2a8a74db27cc84bb507 waiting to be mined...
Contract mined! Address: 0x04e44901ff037a2d859ca9bbaa05595cec611daa

Now, if I run my method:


... in this case I'd expect the return value to be 8. But I get -- a red 0. No matter the arguments, the return is always a red 0.

I also tried calls such as:


Still, a big red 0 back.

I suppose that the color (red) denotes some kind of error. But what kind of error. I don't know what I am doing wrong. Is it the invocation of the method? Or is the method wrong / flawed?

  • Upgradet to geth-1.9.5-stable. Enabled debugging - now I see this in the logs: DEBUG[09-23|21:58:41.306] VM returned with error err="invalid opcode 0x1c" – bschau Sep 23 '19 at 20:00

Yay! Solved - I had to add

"constantinopleBlock": 0

to my genesis.json in the

"config": {


It now works - my contract is doubling the input :-)

(See: invalid opcode "0x1c" during smart contract method execution)

|improve this answer|||||

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.