Skip to main content

dpack is an evm artifact package format

Project description

dpack-py ☀️

a python port of dpack evm packaging format.

dpack allows you to share the entire deployment with all the appropriate addresses and artifacts needed to interact with evm contracts.

the library provides a low-level implementation, as well as bindings for ape.

install

pip install dpack-py

since dpack uses ipfs pointers, it requires you running an ipfs daemon. see ipfs docs for how to install it.

you can set an IPFS_RPC_URL environment variable if you use a remote ipfs node.

developing

to set up the extra libraries useful for development:

uv venv
make dev

load a dpack

use dpack.load to load a dpack from a local file. it will lazily fetch the needed artifacts from ipfs when you access the corresponding contract types and objects.

both types and objects expose a contract_type property decoded by ethpm-types into a python model. it allows easy abi lookups like shown below.

import dpack

pack = dpack.load("examples/uniswap-v3.dpack.json")

pack.types['UniswapV3Factory'].contract_type.selector_identifiers

objects also expose a contract_instance property (not the same as in ape) that allows looking up contract typename and address.

pack.objects['factory'].address
# or use a shorthand attribute access
pack.factory.address

make a dpack

to make a dpack, use pack_type and pack_object methods. packing types is optional as you can just pack your named objects and the library will take care of packing unique contract types automatically.

import dpack

pack = (
    dpack.Dpack(network="sepolia")
    .pack_object(
        path="tests/weth-ropsten-artifact.json",
        typename="WETH9",
        objectname="weth",
        address="0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
    )
)

to save a dpack to a json file, simply call save with a file path.

pack.save('weth.sepolia.dpack.json')

you may pack as many objects and types as you wish, but note that the current version of the format (dpack-1) specifies the network at top level, so you cannot make multichain dpacks yet.

use with ape

this library also provides an easy wrapper that loads up objects as ape contract instances, so you can interact with them right away.

$ ape console --netwowrk ethereum:mainnet

from ape_tokens import tokens
import dpack.ape

uniswap = dpack.ape.load("examples/uniswap-v3.dpack.json")

uniswap.quoter.quoteExactInputSingle.call((tokens["WETH"], tokens["YFI"], '1 ether', 10000, 0))

make a dpack with ape

ape also makes it easier to author dpacks, since you an leverage its capabilities to fetch the needed abis from an explorer.

see this example to learn how it's done.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dpack_py-0.1.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

dpack_py-0.1.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file dpack_py-0.1.1.tar.gz.

File metadata

  • Download URL: dpack_py-0.1.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for dpack_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 50a470c43ca1005cd1d32ece850917ffe08ecf0204be7e7cfe47e117993c600b
MD5 c636139be7290dd454868657bc0a726b
BLAKE2b-256 14ca5aa840aa4faa2d8522485e79e5d84f6bdb6ad79255f8b0c2bf7b28fee6f2

See more details on using hashes here.

File details

Details for the file dpack_py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dpack_py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for dpack_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5eed37a87aa9a067be993fde00e2cccd81b10ec4978c4944e4f099bac57c22e
MD5 6653007f65916cf1322dd6d9749dc762
BLAKE2b-256 ddb63746a5f04f48266bdc34872b6e0a395ab31d27061e8dee31fff907b71a33

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page