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...
The creator of the package told me that the reason for this is this issue: https://github.com/regcostajr/go-web3/issues/31
He is trying to solve it.
I think you have to encode it
types.ComplexString("myString")
To convert a string to a bytes32
for solidity all you have to do is create a fixed length byte array in Go and copy the string the value to it.
value := [32]byte{}
copy(key[:], []byte("hello"))
Then you may pass the value to the smart contract function:
hash, err := contract.Send(transaction, "vote", value)