List of sample GraphQL queries that Alchemy supports
To utilize Alchemy's GraphQL webhook playground, feel free to use Alchemy's handy dashboard tool. Follow along our guide for more information!
To help developers understand the type of queries that Alchemy's Custom Webhooks can support, we've included some key examples that you can run on your own!
NOTE:
When testing Alchemy's Custom Webhooks on different networks and chains, make sure you change the block hash and associated log/transaction information to match each blockchain's on-chain data!
Ethereum Mainnet Examples:
Action:
Whenever an approval event is emitted by the USDC contract, deliver a webhook notification with each event's topics.
GraphQL Query:
{
block(hash: "0xaaf4228db65eab92357c124ff8f8f1c5da72a04da660e147157cd4dfd8eb44d6") {
logs(filter: {addresses: ["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"], topics: ["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"]}) {
topics
}
}
}
Action:
Whenever an approval event is emitted by the USDC contract, deliver a webhook notification with a full transaction receipt.
GraphQL Query:
{
block(hash: "0xaaf4228db65eab92357c124ff8f8f1c5da72a04da660e147157cd4dfd8eb44d6") {
logs(filter: {addresses: ["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"], topics: ["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"]}) {
transaction {
hash
index
from {
address
}
to {
address
}
cumulativeGasUsed
gasPrice
gasUsed
createdContract {
address
}
logs {
topics
}
type
status
}
}
}
}
Action:
Whenever a Bored Ape NFT emits an event, deliver a webhook notification with a full transaction receipt with all associated logs.
GraphQL Query:
{
block(hash: "0x4a4d98f90439daaf082642dfbdd0f7b9a36749484582fb3d3e03bd4583da337a") {
logs(filter: {addresses: ["0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D"], topics: []}) {
transaction {
hash
index
from {
address
}
to {
address
}
maxFeePerGas
maxPriorityFeePerGas
gasUsed
cumulativeGasUsed
effectiveGasPrice
createdContract {
address
}
logs {
topics
}
type
status
}
}
}
}
Polygon Mainnet Examples:
Action:
Whenever an event is emitted by the USDC contract, deliver a webhook notification with each event's topics.
GraphQL Query:
{
block(hash: "0x9ba0d6c318cbf69c91e65ea596c3c23bf863fb7d14046943bcc781e841b243cd") {
logs(filter: {addresses: ["0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"], topics: []}) {
topics
}
}
}
Action:
Whenever a transfer event is emitted by the USDC contract, deliver a webhook notification with transaction-level data with surrounding log events emitted
GraphQL Query:
{
block(hash: "0x9ba0d6c318cbf69c91e65ea596c3c23bf863fb7d14046943bcc781e841b243cd") {
logs(filter: {addresses: ["0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"], topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}) {
transaction {
hash
index
from {
address
}
to {
address
}
cumulativeGasUsed
gasPrice
gasUsed
createdContract {
address
}
logs {
topics
}
type
status
}
}
}
}