Skip to main content

multicall3.py

Python 3 interface for Multicall3.

Installation

Install via pip:

pip install multicall3

Install via pdm:

pdm add multicall3

Example

from multicall3 import Multicall3
from web3 import Web3, AsyncWeb3, AsyncHTTPProvider
import asyncio

ERC20_ABI = [
    {
        "constant": True,
        "inputs": [],
        "name": "name",
        "outputs": [{"name": "", "type": "string"}],
        "payable": False,
        "stateMutability": "view",
        "type": "function",
    },
    {
        "constant": True,
        "inputs": [],
        "name": "decimals",
        "outputs": [{"name": "", "type": "uint8"}],
        "payable": False,
        "stateMutability": "view",
        "type": "function",
    },
    {
        "constant": True,
        "inputs": [],
        "name": "symbol",
        "outputs": [{"name": "", "type": "string"}],
        "payable": False,
        "stateMutability": "view",
        "type": "function",
    }
]

async def main():
  w3 = AsyncWeb3(AsyncHTTPProvider("https://ethereum.publicnode.com"))
  multicall3 = Multicall3(w3=w3)
  usdc_contract = w3.eth.contract(
      address=Web3.to_checksum_address("0xA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48"),
      abi=ERC20_ABI,
  )

  results = await multicall3.aggregate3(
      usdc_contract.functions.name(),
      usdc_contract.functions.symbol(),
      usdc_contract.functions.decimals(),
  )
  assert results[0] == "USD Coin"
  assert results[1] == "USDC"
  assert results[2] == 6

asyncio.run(main())

Contributing

Install pdm using pipx:

pipx install pdm --python $(which python)

Install dependencies:

pdm install

Activate the virtualenv:

$(pdm venv activate)

Run the test:

pytest

Metadata

Release files for multicall3 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multicall3 0.1.4
File Size Uploaded Provenance Actions
multicall3-0.1.4.tar.gz 4.7 kB Without provenance Details for multicall3-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multicall3 0.1.4
File Interpreter ABI Platform Actions
multicall3-0.1.4-py3-none-any.whl Python 3 none any Details for multicall3-0.1.4-py3-none-any.whl

Total release size: 8.3 kB

Release files / multicall3-0.1.4.tar.gz

Download URL multicall3-0.1.4.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26563b9296b913ba6122517ee45f8d1bf7ab15c3325f87f2f479610e51c5733b
BLAKE2b-256 checksum
How to use checksums
f91b4304546a8f3560e217c939c2cf1d4e0ec86d1748b5ff12220e1ce73d4a5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.11.2 CPython/3.11.6

Release files / multicall3-0.1.4-py3-none-any.whl

Download URL multicall3-0.1.4-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d30fdc7f6a08774c45033408b5bd406f0ad489625d79764014194cf8abd616b4
BLAKE2b-256 checksum
How to use checksums
444db6927631de3f73e62e34fa7dc0a5626d13f9e93eab829c529fce875c29d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.11.2 CPython/3.11.6

Security for multicall3 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page