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

Block identifier parameter in Contract.call #446

Closed
Eenae opened this issue Nov 20, 2017 · 8 comments
Closed

Block identifier parameter in Contract.call #446

Eenae opened this issue Nov 20, 2017 · 8 comments

Comments

@Eenae
Copy link

Eenae commented Nov 20, 2017

  • Version: 3.16.2
  • Python: 3.5
  • OS: linux

What was wrong?

I'm trying to query a contract state 6 block ago. Unlike web3.js api in Contract.call I can't specify block identifier to run this call against.
What is a correct way of doing this in web3py?
Am I correct in my understanding that as a workaround I can temporarily set Eth.defaultBlock to desired number and I won't run into any internal web3py thread/green thread concurrency issues?

How can it be fixed?

I'm feature-requesting addition of block identifier parameter in Contract.call in accord with web3.js api.

@pipermerriam
Copy link
Member

pipermerriam commented Nov 20, 2017

Yes, this should be added (and should be relatively easy to implement)

@carver
Copy link
Collaborator

carver commented Dec 4, 2017

Interesting that this API is not defined in the web3js v1 docs yet: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#methods-mymethod-call

Should it be an extra parameter to call? It doesn't really fit inside the transaction dict, semantically.

contract.method(...).call({'from': ..., 'gasPrice': ..., 'gas': ...}, at_block=123456)

@pipermerriam
Copy link
Member

I'd say extra optional parameter.

@bweick
Copy link
Contributor

bweick commented Jan 10, 2018

Hey guys...would love to go ahead on this one now...couple things.

  1. Should this just be done for the upcoming v4 call interface or should I also build it out for the v3 interface as well (shouldn't require much additional work)?
  2. Do you think it's worthwhile to throw an error if block number is outside valid range (0, length of chain]?

@carver
Copy link
Collaborator

carver commented Jan 10, 2018

  1. v4-only should be fine. only critical security fixes need to go to v3 now, per Logistics for v4 Development #336
  2. It's absolutely worth throwing validation errors. I would also expect it to accept 'latest' and 'earliest'.

@bweick
Copy link
Contributor

bweick commented Jan 10, 2018

Cool sounds good, I'll get to work!

@mtcz91
Copy link

mtcz91 commented May 20, 2018

hello,I get the web3 of vision4.2.1,but i cannot call my contract method at a block number,such as "detail = info.functions.getInfo().call(block_identifier=3)",I always get the "latest" block's info.Could tell me what's the reason of my problem?

@carver
Copy link
Collaborator

carver commented May 21, 2018

Hi @mtcz91 that looks right. There's not enough info to help you debug.

This issue was left open by mistake, it is only tracking the main feature being added. I'm closing it now.

Can you open a new issue with a minimal, complete, and verifiable example: https://stackoverflow.com/help/mcve ? Specifically, the contract source, the contract deployment, any transactions, and the call.

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

5 participants