diff --git a/README.md b/README.md index e8fe415..a0c8fac 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,13 @@ However, [multicall.py](https://github.com/banteg/multicall.py) is built on [asy This implementation fixes that. -# Multicall Smart Contract +# W3Multicall + +## Multicall Smart Contract [Multicall](https://github.com/mds1/multicall) smart contract are deployed on numerous chains and can help reduce the strain put on RPC by order of magnitude by *batching* multiple requests into a single one. -# Simple Multicall +## Simple Multicall ``` from web3 import Web3 @@ -49,7 +51,7 @@ print("Vitalik holds {:.2f} USDC".format(results[0]/10**6)) [See full example](/examples/simple_multicall.py) -# Multithread Multicall +## Multithread Multicall ``` w3_pool = W3Pool([ diff --git a/pyproject.toml b/pyproject.toml index fff6869..3110b1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "w3multicall" description = "Python interface and utilities for Solidity multicall contract" authors = [{name = "Ortis", email = "ortis@ortis.io"}] -version = "0.1.1" +version = "0.1.2" readme = "README.md" keywords = ["blockchain", "web3", "etherum", "solidity"] license = {file = "LICENSE"} diff --git a/setup.cfg b/setup.cfg index aa8804a..3fbe52f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = w3multicall -version = 0.1.1 +version = 0.1.2 author = Ortis author_email = ortis@ortis.io description = Python interface and utilities for Solidity multicall contract diff --git a/src/w3multicall/multicall.py b/src/w3multicall/multicall.py index d2f13a7..3d468f1 100644 --- a/src/w3multicall/multicall.py +++ b/src/w3multicall/multicall.py @@ -112,6 +112,11 @@ class W3Multicall: class Call: def __init__(self, address: str, signature: str, args=None): + """ + :param address: address of the contract to call + :param signature: method signature to call (no space. Example: 'balanceOf(address)(uint256)') + :param args: arguments of the contract method to call (use python tuple for solidity struct, python list for solidity arrays and python int for solidity uint/int) + """ self.address = address self.signature = signature.replace(" ", "") diff --git a/src/w3multicall/threading/w3multicall_executor.py b/src/w3multicall/threading/w3multicall_executor.py index 0d31a9f..836aec9 100644 --- a/src/w3multicall/threading/w3multicall_executor.py +++ b/src/w3multicall/threading/w3multicall_executor.py @@ -12,14 +12,15 @@ class W3: - def __init__(self, w3: Web3, delay_between_call: float): + def __init__(self, w3: Web3, delay_between_call: float, label: Union[str, None] = None): self.w3 = w3 self.delay_between_call = delay_between_call self.limit_rate_per_seconds = 1 / self.delay_between_call self.last_call_at = 0 + self.label = str(self) if label is None else label def __repr__(self): - return '{} {:.2f}/s'.format(self.w3, self.limit_rate_per_seconds) + return '{} {:.2f}/s'.format(self.label, self.limit_rate_per_seconds) def use(self) -> Web3: self.last_call_at = time.time()