Skip to main content

ape-etherscan: Etherscan Explorer Plugin for Ethereum-based networks

Project description

Quick Start

The following blockchain explorers are supported in this plugin:

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.

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

ape-etherscan-0.6.10.tar.gz (88.2 kB view details)

Uploaded Source

Built Distribution

ape_etherscan-0.6.10-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file ape-etherscan-0.6.10.tar.gz.

File metadata

  • Download URL: ape-etherscan-0.6.10.tar.gz
  • Upload date:
  • Size: 88.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ape-etherscan-0.6.10.tar.gz
Algorithm Hash digest
SHA256 398e5f7a1eed82c683498bf432060127b1aa3683566d63e770a13ae79b7af71b
MD5 4b37653cd452d7bfc1a2626679e718a0
BLAKE2b-256 0a02650a87d7330d5bb30e79055af1a641c7ba1dbb3248a2c60bdbb4bb6f0cc0

See more details on using hashes here.

File details

Details for the file ape_etherscan-0.6.10-py3-none-any.whl.

File metadata

File hashes

Hashes for ape_etherscan-0.6.10-py3-none-any.whl
Algorithm Hash digest
SHA256 df6b6ac7f56aed956340c0d783192ba4b4510888defb0e5f4667cc367661c72b
MD5 f8f99e56cc132a2e62250e387585a812
BLAKE2b-256 73bcb67e6609b1177cb03214bccd468fbe4d5501d4a674a6ae779e8a60a10933

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