Skip to main content

A Python library to retrieve smart contract function metadata and data from EVM-compatible blockchains

Project description

🦉 Owl - Smart Contract Data Retrieval

A Python library to easily retrieve function metadata and data from any smart contract on EVM-compatible blockchains.

Installation

pip install -e .

Or install with dependencies:

pip install web3 requests

Quick Start

import owl

# Configure the library
owl.configure(
    etherscan_api_key="YOUR_ETHERSCAN_API_KEY",
    rpc_url="https://eth.public-rpc.com",  # or your preferred RPC
    chain="ethereum"  # ethereum, polygon, bsc, arbitrum, etc.
)

# Get all functions from a contract (USDT example)
functions = owl.get_functions("0xdAC17F958D2ee523a2206206994597C13D831ec7")
for fn in functions:
    print(f"📌 {fn['name']}")
    print(f"   Inputs: {fn['inputs']}")
    print(f"   Outputs: {fn['outputs']}")

# Call a function and get data
result = owl.get_data(
    "0xdAC17F958D2ee523a2206206994597C13D831ec7",
    "totalSupply",
    []
)
print(f"Total Supply: {result['result']}")

Environment Variables

Instead of calling configure(), you can set these environment variables:

export OWL_ETHERSCAN_API_KEY="your_key"
export OWL_RPC_URL="https://eth.public-rpc.com"
export OWL_CHAIN="ethereum"

API Reference

owl.get_functions(contract_address, abi=None, include_events=False, only_view=False)

Get all functions from a smart contract.

Parameters:

  • contract_address (str): The contract address
  • abi (list, optional): Provide custom ABI instead of fetching
  • include_events (bool): Include contract events (default: False)
  • only_view (bool): Only return view/pure functions (default: False)

Returns: List of function definitions with signatures, inputs, and outputs.


owl.get_data(contract_address, function_name, inputs=None, start_date=None, end_date=None)

Call a contract function and get the result.

Parameters:

  • contract_address (str): The contract address
  • function_name (str): Name of the function to call
  • inputs (list, optional): Input arguments for the function
  • start_date (str, optional): Start date for historical data ("YYYY-MM-DD")
  • end_date (str, optional): End date for historical data ("YYYY-MM-DD")

Returns:

  • Without date range: {"result": ..., "block": 12345, "timestamp": "..."}
  • With date range: List of results at sampled blocks

Supported Chains

Chain Explorer API
Ethereum Etherscan
Polygon Polygonscan
BSC BscScan
Arbitrum Arbiscan
Optimism OP Etherscan
Avalanche Snowtrace
Fantom FTMScan
Base BaseScan

Error Handling

from owl.exceptions import (
    OwlConfigurationError,    # Missing API key or RPC
    ContractNotFoundError,    # Invalid contract address
    ABINotFoundError,         # Contract not verified
    FunctionNotFoundError,    # Function doesn't exist
    InvalidInputError,        # Wrong input parameters
    HistoricalDataUnavailableError,  # Archive node required
    DateRangeError,           # Invalid date format
)

try:
    result = owl.get_data("0x...", "unknownFunc", [])
except FunctionNotFoundError as e:
    print(f"Function not found! Available: {e.available_functions}")

License

MIT

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

owl_contracts-0.1.4.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

owl_contracts-0.1.4-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file owl_contracts-0.1.4.tar.gz.

File metadata

  • Download URL: owl_contracts-0.1.4.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for owl_contracts-0.1.4.tar.gz
Algorithm Hash digest
SHA256 48c45c1a76aa0da53c851d1827f9189d0c308a7eacdf023f9afc9ec7703093cc
MD5 5be9c551be43411cc342b451d7048052
BLAKE2b-256 32ea74264f6439c747685562fb8146418540d4a51cf804b256721e49566c67f4

See more details on using hashes here.

File details

Details for the file owl_contracts-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: owl_contracts-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for owl_contracts-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1719a8eb11d59fc0464dd19a1e33e7ec2b0144e9f46247d25007d2d10ac1c2d1
MD5 17178c9bafd7870861c12cb57aa2561d
BLAKE2b-256 03d070b2ff35378b99eb7c770961e3b0d2de7db266d69a4e96ee12c3b6ff37ff

See more details on using hashes here.

Supported by

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