Publishing smart-contract packages using Ape is influenced from EIP-2678 and uses the ethpm-types Python package extensively (which is also managed by the ApeWorX organization). This guide exists to walk through the steps of publishing your project.


First, your project must compile.

ape compile

To learn more about project compilation, follow this guide. Once your project has successfully compiled, you will have the start of your PackageManifest generated in your project’s .build/ directory.

Tracking Deployments

If your project contains deployments that you wish to include in its package manifest, use the track_deployment() method. Example:

from ape import accounts, project

account = accounts.load("mainnet-account")

# Assume your project has a contract named 'MyContract' with constructor that accepts argument '123'.
contract = project.MyContract.deploy(123, sender=account)

If the contract is already deployed, you can use Contract to get a contract instance:

from ape import Contract, project

contract = Contract("0x12c17f958d2ee523a2206206994597c13d831e34")

For more information on accessing contract instances, follow this guide.

Publishing to Explorer

If you want to publish your contracts to an explorer, you can use the publish_contract on the ExplorerAPI.

from ape import networks"0x123...")

If you want to automatically publish the source code upon deployment, you can use the publish= kwarg on the deploy methods:

from ape import accounts, project

accounts.deploy(project.MyContract, publish=True)