[Ethereum] web3py encode method call parameters

encodingweb3.pyweb3js

I want to encode the parameters needed to call a contract method.
In web3js I would use web3.eth.abi.encodeParameters(types, values);
I need to do the same in python I found a function called encodeABI() which takes arguments: fn_name, args=None, kwargs=None, data=None
Unfortunately the documentation for this method is missing. So my question is how to encode these parameters using web3py?

Best Answer

It seems that you should do:

my_contract.encodeABI (fn_name='my_method', args=[arg1, arg2, ...])

This is similar to Web3js:

myContract.methods.myMethod.encodeABI (arg1, arg2, ...)

See details in documentation.

Related Topic