Introduction
The Avalanche Chain is much more than an EVM-compatible ecosystem, as it comprises multiple built-in chains. Therefore, to access a particular chain, you must specify the desired chain.
Chain Name | URI |
Platform Chain (P-Chain) | /ext/bc/P |
Contract Chain (C-Chain) HTTPS | /ext/bc/C/rpc |
Contract Chain (C-Chain) WSS | /ext/bc/C/ws |
Exchange Chain (X-Chain) | /ext/bc/X |
Suggested solution
If you would like to call EVM methods, you will need to add the C-Chain URI at the end of your endpoint URL, as follows: https://nd-123-456-789.p2pify.com/AUTH_KEY/ext/bc/C/rpc
Here's a cURL example
curl -X POST \
'https://nd-123-456-789.p2pify.com/AUTH_KEY/ext/bc/C/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}'
If you'd like to connect to the endpoint via WebSocket you'll need to use the following URL: wss://ws-nd-123-456-789.p2pify.com/AUTH_KEY/ext/bc/C/ws
Here's a wscat example with the eth_syncing request:
wscat -c wss://ws-nd-123-456-789.p2pify.com/AUTH_KEY/ext/bc/C/ws
Connected (press CTRL+C to quit)
> {"id": 1, "jsonrpc": "2.0", "method": "eth_syncing"}
< {"jsonrpc":"2.0","id":1,"result":false}
Conclusion
Understanding the C-Chain’s endpoint structure ensures smooth interactions with Avalanche’s EVM. By specifying the correct endpoint and utilizing the appropriate methods, developers can harness the power of smart contracts on the Avalanche network. Happy coding! 🚀
Feel free to contact Chainstack Support with any questions by emailing support@chainstack.com or submitting this form.
Comments
0 comments
Article is closed for comments.