2

When working with web3.js, Truffle and Ganache, I can do this:

web3.currentProvider.send({method: "evm_increaseTime", params: [numOfSeconds]});

How can I do the equivalent in web3.py?

When I do:

from web3 import HTTPProvider
for func in dir(HTTPProvider):
    if not func.startswith('_'):
        print(func)

I get:

decode_rpc_response
encode_rpc_request
endpoint_uri
get_request_headers
get_request_kwargs
isConnected
logger
make_request
middlewares
request_func

Is it possibly one of these functions that I need to call?

Thank you!

UPDATE:

I've found that I can encode the request like so:

provider = Web3(HTTPProvider("http://127.0.0.1:8545")).providers[0]
request = encode_rpc_request("evm_increaseTime", [123])

When printing request, I get:

b'{"jsonrpc": "2.0", "method": "evm_increaseTime", "params": [123], "id": 0}'

But how do I send this request?

3

OK, this seems to to the job:

web3 = Web3(HTTPProvider("http://127.0.0.1:8545"))
provider = web3.providers[0]
provider.make_request("evm_increaseTime", [numOfSeconds])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.