Skip To Content

Blockdaemon Documentation

How to Connect to Avalanche

Connecting to your Avalanche nodes via RPC is easy.

If you haven’t already configured any Avalanche infrastructure, visit the Avalanche marketplace page to learn more about Blockdaemon’s Avalanche options.

Once you have purchased your Blockdaemon Avalanche infrastructure, Your Blockdaemon Technical Account Manager (TAM) will send you the necessary access credentials. There are multiple ways to use these to connect to your node.

In this guide, we will cover the following simple method to connect to and query your Avalanche infrastructure:

Note: Connection to Avalanche is only supported for Avalanche Contract Chain (C-Chain).


Avalanche RPC Connection Using web3.py

Step 1 – Your RM will send you the following access credentials:

  • Your Unique Endpoint URL
  • Your Unique Auth Token

Please Note: These credentials are one-time view, so make sure to copy them.

Step 2 – Hook directly into Avalanche’s EVM compatibility by using geth_poa_middleware and web3.py:

from web3 import Web3
from web3.middleware import geth_poa_middleware

rpc_url = 'https://YOUR_ENDPOINT_URL.net/ext/bc/C/rpc?auth=YOUR_AUTH_TOKEN'

web3 = Web3(Web3.HTTPProvider(rpc_url))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)

result = web3.eth.YOUR_RPC_METHOD
  • Replace YOUR_ENDPOINT_URL with the Endpoint URL sent by your Blockdaemon TAM
  • Replace YOUR_AUTH_TOKEN with the Auth Token sent by your Blockdaemon
  • Replace YOUR_RPC_METHOD with your chosen RPC method

 

We don't support Internet Explorer

Please use Chrome, Safari, Firefox, or Edge to view this site.