Skip to content

quiknode-labs/ape-quicknode

 
 

Repository files navigation

QuickNode Ape Plugin

Use the QuickNode provider plugin to interact with blockchains via QuickNode's APIs.

If you don't have a QuickNode account already, you can create one here.

Supported Networks

The ape-quicknode plugin supports the following ecosystems:

  • Ethereum
  • Arbitrum
  • Base
  • Optimism
  • Polygon
  • Polygon-ZkEVM

Dependencies

Installation

via pip

You can install the latest release via pip:

pip install ape-quicknode

via setuptools

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

git clone https://github.com/your-username/ape-quicknode.git
cd ape-quicknode
python3 setup.py install

Configuration

To use the QuickNode provider, you need to set up your QuickNode credentials. You can do this by setting environment variables.

Environment Variables

Set the following environment variables:

export QUICKNODE_SUBDOMAIN=your-quicknode-subdomain
export QUICKNODE_AUTH_TOKEN=your-quicknode-auth-token

Usage

Command Line

To use the QuickNode provider plugin in most commands, set it via the --network option:

ape console --network ethereum:mainnet:quicknode

Python Script

To connect to QuickNode from a Python script, use the networks top-level manager:

from ape import networks

with networks.ethereum.mainnet.use_provider("quicknode") as provider:
    # Your code here
    ...

Transaction Traces

You can access transaction traces using the QuickNode provider:

from ape import networks

quicknode = networks.provider  # Assuming connected to QuickNode
txn_hash = "0x45a8ab098ef27f028afe532f3ca241a3425725093f1302c9bf14a03993891b70"  # Replace the hash with another hash if needed or using another network
trace = quicknode.get_transaction_trace(txn_hash)
print(f"Raw call tree: {trace.get_raw_calltree()}")

Testing

CLI Testing

You can test the QuickNode provider functionality directly from the Ape console. Here's a step-by-step guide:

  1. Initialize the Ape console with QuickNode provider:
ape console --network ethereum:mainnet:quicknode
  1. Once in the console, you can make various calls to test the functionality:
# Get the latest block number
networks.provider.get_block('latest').number

# Get the current network gas price
networks.provider.gas_price

# Get a transaction by its hash
tx_hash = "0x45a8ab098ef27f028afe532f3ca241a3425725093f1302c9bf14a03993891b70" # Replace the hash with another hash if needed or using another network
networks.provider.get_transaction(tx_hash)

# Get a transaction receipt
networks.provider.get_receipt(tx_hash)

# Get a transaction trace
networks.provider.get_transaction_trace(tx_hash).get_raw_calltree()

Unit Tests

To run the unit tests for the QuickNode plugin:

pytest tests/

Development

To set up the development environment:

  1. Clone the repository
  2. Install the development dependencies:
pip install -e ".[dev]"
  1. Install the pre-commit hooks:
pre-commit install

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the Apache 2.0 License.

About

Plugin project template for the Ape Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%