Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abigen incorrect uint32/big.Int bindings #2802

Closed
rusenask opened this issue Jul 11, 2016 · 5 comments
Closed

abigen incorrect uint32/big.Int bindings #2802

rusenask opened this issue Jul 11, 2016 · 5 comments

Comments

@rusenask
Copy link

System information

Geth version: 1.3.6
OS & Version: OSX
Commit hash : 9e323d6

Expected behaviour

On solidity contract I have "uint32 []" type, when abigen creates Go bindings - they are also "[]uint32" type on Go side. Even though it looks like it should work - the actual type of the data coming from the chain is of type " []*big.Int".

Actual behaviour

When executing contract function from Go side - getting unmarshal error. Once I modify generated code myself (change types from []uint32 to []*big.Int) - everything works fine.
I could look at it myself if someone gave me directions where to look, thanks.

Steps to reproduce the behaviour

  1. Create a contract that returns " returns( uint32 [] yourList) "
  2. Create binding with abigen.
  3. Execute that function.

Backtrace

abi: cannot unmarshal []*big.Int in to []uint32
@karalabe
Copy link
Member

I remember an issue like this being fixed a while ago. I'm guessing it was also merged in on the 1.4.x branches. Perhaps you should update to 1.4.9 and see with that? Although if you're using Native DApps I assume you use some develop sources already as 1.3.6 didn't have them at all. Please update your geth sources and retry.

@rusenask
Copy link
Author

Updated to

Geth
Version: 1.4.9-stable-b7e3dfc5
Protocol Versions: [63 62 61]
Network Id: 1
Go Version: go1.6
OS: darwin

Tried to recreate bindings - still the same problem, maybe it's because of uint32 and not uint? for uint I get correct big.Int

@tbocek
Copy link
Contributor

tbocek commented Oct 30, 2016

I had the same issue (with current master) and I think I fixed it here:

https://github.com/tbocek/go-ethereum/commit/04c5fb69fa8ff9b8d3b898a3aba132e77ea4bee7
https://github.com/tbocek/go-ethereum/commit/04c5fb69fa8ff9b8d3b898a3aba132e77ea4bee7

@karalabe Can you check if that makes sense, and then I can submit a pull request

@tbocek
Copy link
Contributor

tbocek commented Nov 24, 2016

Just upgraded to 1.5.x (current master) and still got the same isssue:

Failed to report temperatures: abi: cannot unmarshal []*big.Int in to []uint32. I'll submit a pull request

karalabe pushed a commit to karalabe/go-ethereum that referenced this issue Jan 9, 2017
On solidity contract I have "uint32 []" type, when abigen creates Go
bindings - they are also "[]uint32" type on Go side. Even though it
looks like it should work - the actual type of the data coming from
the chain is of type " []*big.Int".

When executing contract function from Go side - getting unmarshal error:
abi: cannot unmarshal []*big.Int in to []uint32

The fix is to create array with the correct type

This fixed the issue reported in: ethereum#2802
farazdagi pushed a commit to status-im/go-ethereum that referenced this issue Feb 22, 2017
On solidity contract I have "uint32 []" type, when abigen creates Go
bindings - they are also "[]uint32" type on Go side. Even though it
looks like it should work - the actual type of the data coming from
the chain is of type " []*big.Int".

When executing contract function from Go side - getting unmarshal error:
abi: cannot unmarshal []*big.Int in to []uint32

The fix is to create array with the correct type

This fixed the issue reported in: ethereum#2802
@stale
Copy link

stale bot commented Mar 5, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status:inactive label Mar 5, 2018
@stale stale bot closed this as completed Apr 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants