Skip to content

Generated contract bindings don't allow specifying call block number. #16838

New issue

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

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

Already on GitHub? # to your account

Closed
nostdm opened this issue May 30, 2018 · 3 comments
Closed

Generated contract bindings don't allow specifying call block number. #16838

nostdm opened this issue May 30, 2018 · 3 comments
Assignees

Comments

@nostdm
Copy link

nostdm commented May 30, 2018

System information

Geth version: 1.8.9

Desired behaviour

The ability to call a contract method for a specific block number:

balance, err := token.BalanceOf(&bind.CallOpts{}, account, big.NewInt(25402))

Actual behaviour

The bound contract Call method always sets the block number to nil (i.e. latest) and the generated bindings don't allow you to specify the block number.

balance, err := token.BalanceOf(&bind.CallOpts{}, account)

Notes

I'm currently forced to use the CallContract method directly on the Ethereum client by manually encoding the contract method signature:

packed, err := tokenABI.Pack("balanceOf", address)
rsp, err := client.CallContract(ctx, ethereum.CallMsg{
    To:   token,
    Data: packed,
}, big.NewInt(25402))

But this is a very manual process which defeats the purpose of generating Go bindings in the first place.

Are there any plans to add this functionality to the abigen generated code?

@favadi
Copy link
Contributor

favadi commented Sep 27, 2018

I'm taking a look if this feature can be added without breaking current generated codes.

@favadi
Copy link
Contributor

favadi commented Sep 27, 2018

I created #17770 to allow passing block number when using abigen generated codes.

@gballet gballet self-assigned this Jun 18, 2019
@gballet
Copy link
Member

gballet commented Jun 18, 2019

This should have been fixed with #17942. Please check with a more recent version of geth and reopen if the issue is still present.

@gballet gballet closed this as completed Jun 18, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants