goethereumsoliditygo-ethereum

Pass parameter as bytes32 to Solidity Smart Contract


I am using this Ethereum Go Client and trying to pass a string / bytes32 to Solidity.

The function in the smart contract is very simple (for testing now):

  function vote(bytes32 id) {
    //id has the value 0x0000000000000000000000000000000000000000000000000000000000000000
  }

calling

hash, err := contract.Send(transaction, "vote", "myString")

will result in 0x0000000000000000000000000000000000000000000000000000000000000000

for the bytes32 param id...

How would I have to pass in the parameter to my Smart Contract from Go so that solidity will have the correct value?

Alternatively I just need to pass a unique identifier for that string that I can easily create in Golang from the string...


Solution

  • The creator of the package told me that the reason for this is this issue:

    https://web.archive.org/web/20201226194418/https://github.com/regcostajr/go-web3/issues/31

    regcostajr commented on June 6, 2018:

    Hi @jeffprestes, thanks for the issue, the arguments encode in the contract struct appears to be completely wrong, we need to re-implement this based on the solidity docs: http://solidity.readthedocs.io/en/develop/abi-spec.html#use-of-dynamic-types

    He is trying to solve it.