How to hit the Alchemy API

Alchemy gives each app an RPC URL like https://eth-mainnet.g.alchemy.com/v2/<key>. Standard Ethereum JSON-RPC works there, plus Alchemy's own methods.

Authentication

Create an app on the Alchemy dashboard; its API key goes at the end of the URL. In the examples it's written {{ALCHEMY_API_KEY}}.

Full reference: https://www.alchemy.com/docs

Latest block number

A hex string.

curl -X POST https://eth-mainnet.g.alchemy.com/v2/{{ALCHEMY_API_KEY}} \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}'
Run in PostTaco

Balance of an address

curl -X POST https://eth-mainnet.g.alchemy.com/v2/{{ALCHEMY_API_KEY}} \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_getBalance", "params": ["0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe", "latest"]}'
Run in PostTaco