1

I had a working Solidity contract, made a change to its function signature (to take in an array of addresses, instead of a single address), I compiled it, ran abigen and generated Go bindings. Below is the code that calls that contract:

gethClient, err := ethclient.Dial(gethRPCURL)
if err != nil {
    log.Fatalf("failed to connect to the Ethereum client: %v", err)
}

contractBinding, err := NewMyContract(common.HexToAddress(contractAddress), gethClient)
if err != nil {
    log.Fatalf("failed to instantiate contract: %v", err)
}

var addrList := make([]common.Address, 0)
_, methodErr := contractBinding.MyMethod(addrList);
if methodErr != nil {
    log.Fatalf("my contract encountered error during MyMethod: %s", methodErr)
}

I've looked on Github and found this issue, which suggests its a type issue, I've looked on Gitter and found a suggestion about the chain not being in sync, which doesn't make intuitive sense to me. Has anyone ran into this issue before or able to provide some insight on it?

  • 1
    unmarshalling is like decrypting of condensed data into a much more usable format or version. Thinking about it, it can happen because of the chain being not in sync where you may have pushed new transactions into your chain and then tried to synchronize it with an other chain and your transactions were not taken into consideration yet you still asked for their data so you get the empty output. This is honestly not the most logical explanation but it's what I think is happening here. – Kaki Master Of Time Mar 29 '19 at 21:25
  • @KakiMasterOfTime that description makes sense from what I've read. It seems that error is output from abi.Unpack, which is called here in the contract call github.com/ethereum/go-ethereum/blob/… in my specific case, I'm polling Geth for the contract code before binding (to ensure it exists)... going to look into this more, thanks for the insight – delos Mar 29 '19 at 21:56
0

Did you get any further with this analysis. I'm getting the same issue when using geth as a local node (trying various versions). I have a Smart Contract example in Go(using the Go example book) so a very simple example.

pragma solidity ^0.5.10;

contract Store {
  event ItemSet(bytes32 key, bytes32 value);

  string public version;
  mapping (bytes32 => bytes32) public items;

  constructor(string memory _version) public {
    version = _version;
  }

  function setItem(bytes32 key, bytes32 value) external {
    items[key] = value;
    emit ItemSet(key, value);
  }
}

This deploys fine and I receive and Address and a Transaction Address. But when I try to read from it I get the error "ABI Marshalling empty output" and looking at the returned value , it is empty.

The Read is again very simple.

I've run the exact same Sol , Deploy and Read against Ganache and it worked fine and as expected. I've also used the exact same Sol , Deploy , Read against Rinkerby and again it all worked as expected , so it can't be anything to do with the Sol or the Deploy or read logic. I've tried various versions of Geth , 8 , 9 and the latest build, but all with the same results. I've also tried various versions of Solidity but again with no difference when running against a local Geth node.

I've also checked and the transaction is mined as expected.

I guess having tried so many things , my main questions is , has anyone got a local running Geth Node (1 node) working with a Smart Contract and reading data from the Contract.

My Genesis.json contents are

{
"config": {
"chainId": 1,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0xdeadbeefdeadbeef",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x686f727365",
"gasLimit": "0x8000000",
"difficulty": "0x0400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {
}
}
}
  • After doing some further debugging it seemed the Issue was that the Smart Contract execution was failing with a Opcode error , which had already been raised ethereum.stackexchange.com/questions/69530/… I edit my Genesis file and added "constantinopleBlock": 1 and everything works as expected now – Mike Jul 27 '19 at 11:23

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.