You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extends Web3's native ``Contract`` module, with a few modifications for how you instantiate ``Contract`` factories and instances.
309
+
310
+
All you need is the package name, version and ethPM registry address for the package you wish to use.
311
+
An ethPM registry is essentially an on-chain datastore for the release data associated with an ethPM package. You can find some sample registries to explore in the `ethPM explorer <http://explorer.ethpm.com/>`__. Remember, you should only use packages from registries whose maintainer you trust not to inject malicious code!
312
+
313
+
In this example we will use the ``[email protected]`` package sourced from the ``ens.snakecharmers.eth`` registry.
314
+
315
+
``web3.pm`` uses the ``Package`` class to represent an ethPM package. This object houses all of the contract assets
316
+
within a package, and exposes them via an API. So, before we can interact with our package, we need to generate
317
+
it as a ``Package`` instance.
318
+
319
+
.. code-block:: python3
320
+
321
+
from web3.auto.infura import w3
322
+
323
+
# Note. To use the web3.pm module, you will need to instantiate your w3 instance
324
+
# with a web3 provider connected to the chain on which your registry lives.
325
+
326
+
# The ethPM module is still experimental and subject to change,
327
+
# so for now we need to enable it via a temporary flag.
328
+
w3.enable_unstable_package_management_api()
329
+
330
+
# Then we need to set the registry address that we want to use.
331
+
# This should be an ENS address, but can also be a checksummed contract address.
332
+
w3.pm.set_registry("ens.snakecharmers.eth")
333
+
334
+
# This generates a Package instance of the target ethPM package.
0 commit comments