Skip to main content

Quick Start

The following is a subset of the supported blockchain explorers:

Network Name Explorer Link
Arbitrum Arbiscan
Avalanche Snowtrace
Base Basescan
Binance Smart Chain Bscscan
Bittorrent BTTCscan
Blast Blastscan
Celo Celoscan
Ethereum Etherscan
Fantom Ftmscan
Fraxtal Fraxscan
Gnosis Gnosisscan
Kroma Kromascan
Monad Monadscan
Moonbeam Moonscan
Optimism Optimistic Etherscan
Polygon Polygonscan
Polygon ZkEVM Polygonscan ZkEVM
Scroll Scrollscan
Sonic Sonicscan
Unichain Uniscan

To see the full list of networks supported by Etherscan, see Etherscan's Supported Chains guide.

Dependencies

Installation

via pip

You can install the latest release via pip:

pip install ape-etherscan

via setuptools

You can clone the repository and use setuptools for the most up-to-date version:

git clone https://github.com/ApeWorX/ape-etherscan.git
cd ape-etherscan
python3 setup.py install

Quick Usage

Set up the environment

Specify API keys as environment variables. You could put them in your shell's config like ~/.profile or use a tool like direnv and store them locally in .envrc.

You can also specify multiple comma-separated keys, a random key will be chosen for each request. This could be useful if you hit API rate limits.

You can obtain an API key by registering with Etherscan and visiting this page.

export ETHERSCAN_API_KEY=SAMPLE_KEY
export FTMSCAN_API_KEY=SAMPLE_KEY
export ARBISCAN_API_KEY=SAMPLE_KEY
export POLYGON_ZKEVM_ETHERSCAN_API_KEY=SAMPLE_KEY
export BASESCAN_API_KEY=SAMPLE_KEY

Transaction URLs

When you have this plugin installed, Etherscan explorer URLs appear in CLI output.

INFO: Submitted 0x123321123321123321123321123aaaadaaaee4b2aaa07901b80716cc357a9646
etherscan URL: https://rinkeby.etherscan.io/tx/0x123321123321123321123321123aaaadaaaee4b2aaa07901b80716cc357a9646

Contract Types

The ape-etherscan plugin also assists in fetching contract_types. Use the Contract top-level construct to create contract instances. When the explorer plugin locates a contract type for a given address, the Contract return-value uses that contract type.

from ape import accounts, Contract

contract = Contract("0x55a8a39bc9694714e2874c1ce77aa1e599461e18")
receipt = contract.call_mutable_method("arg0", sender=accounts.load("acct"))

The first line contract = Contract("0x55a8a39bc9694714e2874c1ce77aa1e599461e18") checks if ape has a cached contract-type for the address 0x55a8a39bc9694714e2874c1ce77aa1e599461e18. If it does not find a cached contract type, it uses an explorer plugin to attempt to find one. If found, the contract type is then cached to disk and in memory for the active session so that subsequent invocations don't require HTTP calls. The return value from Contract is a ContractInstance, so it is connected to your active provider and ready for transactions.

NOTE: Vyper contracts from Etherscan always return the name Vyper_contract. However, if the plugin detects that the contract type has a method named symbol, it will use the return value from that call instead.

Contract Verification

Use the ape-etherscan plugin to publish and verify your contracts. Contract verification associates a contract type from Ape with an Ethereum address on Etherscan. Learn more about Etherscan verification here.

To verify contract in Ape, you can set the publish key to True when deploying:

from ape import accounts, project

account = accounts.load("testnetacct")
account.deploy(project.MyContract, publish=True)

You can also use the explorer class directly to publish at a later time:

from ape import networks

etherscan = networks.provider.network.explorer
etherscan.publish_contract("0x55a8a39bc9694714e2874c1ce77aa1e599461e18")

Not every network's explorer supports multi-file verification. For those networks, the corresponding compiler plugin's flatten functionality is invoked, in order to verify the contract as a single file.

NOTE: You must set an Etherscan API key environment variable to use the publishing feature.

Custom Networks

If you would like to use ape-etherscan with your custom network configuration, you can use the same network identifier you used to configure it. For instance, with a custom Ethereum network called "apechain" your configuration might look something like this:

networks:
  custom:
    - name: apechain
      chain_id: 31337

node:
  ethereum:
    apechain:
      uri: http://localhost:8545

etherscan:
  ethereum:
    rate_limit: 15
    apechain:
      uri: https://custom.scan
      api_uri: https://api.custom.scan/api

Dependencies

You can use dependencies from Etherscan in your projects. Configure them like this:

dependencies:
  - name: Spork
    etherscan: "0xb624FdE1a972B1C89eC1dAD691442d5E8E891469"
    ecosystem: ethereum
    network: mainnet

Then, access contract types from the dependency in your code:

from ape import project

spork_contract_type = project.dependencies["Spork"]["etherscan"].Spork

Querying Accounts

Etherscan offers a query-provider plugin for account data. Query account transactions from Etherscan using the following syntax:

from ape import chain

history = chain.history["vitalik.eth"]

# NOTE: Also showing how you can use `start_nonce=` and `stop_nonce=`
#   to limit the history.
result = history.query("*", start_nonce=1000, stop_nonce=1001, engine_to_use="etherscan")

Metadata

Release files for ape-etherscan 0.8.8

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

Source distribution (sdist)

Source distribution for ape-etherscan 0.8.8
File Size Uploaded Provenance Actions
ape_etherscan-0.8.8.tar.gz 106.7 kB With provenance Details for ape_etherscan-0.8.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ape-etherscan 0.8.8
File Interpreter ABI Platform Actions
ape_etherscan-0.8.8-py3-none-any.whl Python 3 none any Details for ape_etherscan-0.8.8-py3-none-any.whl

Total release size: 136.2 kB

Release files / ape_etherscan-0.8.8.tar.gz

Download URL ape_etherscan-0.8.8.tar.gz
Size 106.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da44d544ce8b945929b16ec2a5d0f9e1be4f7b88706a218b8a0a167332567e85
BLAKE2b-256 checksum
How to use checksums
edfe0314b5f24b79e7b05fdc7bbfd02b255bf62be1a255f90daac3248ff4e657
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / ape_etherscan-0.8.8-py3-none-any.whl

Download URL ape_etherscan-0.8.8-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e0ba23a74e4e3aa675dfdcb6678de4ca42c74760b2e7a89057ac8e259fa7100
BLAKE2b-256 checksum
How to use checksums
609d6d30142099153e1f289c24432cc00b96fc4c643f21bd53c53c77e73174fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for ape-etherscan 0.8.8

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ape_etherscan-0.8.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.8.8 This release

2 release files Full provenance

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