Skip to main content

Stream Base and Arbitrum events to a webhook

Send one contract event from Base and Arbitrum One to your HTTP endpoint with Goldsky Turbo's webhook sink. Covers retries, batches, and reorgs.

Stream Base and Arbitrum events to a webhook cover image
Written by
image of Elliott Charbonneau
Elliott Charbonneau

Head of Operations

If you want an HTTP POST every time a contract on Base or Arbitrum One emits an event, you don't need a node or a poller. A Turbo pipeline reads each chain's logs, a SQL transform narrows them to the one contract and event you care about, and a webhook sink POSTs the matching rows to your endpoint as JSON. We deliver each row at least once and retry failures with backoff, so your endpoint only has to return a 2xx status to accept a batch. You pick the batch size and the flush interval, and your endpoint handles duplicates, batches, and the occasional reorg correction, which we cover below.

The pipeline

Two chain sources feed one SQL filter, and one webhook sink delivers the result. Turbo's EVM datasets are namespaced by chain slug, and Base and Arbitrum One both have a raw_logs dataset that carries every event log on the chain, with the contract address, topics, and data. The Turbo name for Arbitrum One is arbitrum_one (opens in a new tab), not arbitrum, so the datasets are arbitrum_one.raw_logs and base.raw_logs.

For a worked example, we'll track USDC Transfer events on both chains. Circle lists the native USDC contract for each chain in its contract address reference (opens in a new tab): 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 on Base and 0xaf88d065e77c8cc2239327c5edb3a432268e5831 on Arbitrum One. The Transfer event has the same signature hash on every chain, 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. To track your own contract, swap in its address and its event signature. Our post on contract indexing for data engineers covers decoded events.

The pipeline has one source for each chain, one SQL transform that filters both to the address and the event, and one webhook sink:

yaml
name: base-arbitrum-usdc-webhook
resource_size: m

sources:
  base_logs:
    type: dataset
    dataset_name: base.raw_logs
    version: 1.0.0
    start_at: latest

  arbitrum_one_logs:
    type: dataset
    dataset_name: arbitrum_one.raw_logs
    version: 1.0.0
    start_at: latest

transforms:
  usdc_transfers:
    type: sql
    primary_key: id
    sql: |
      SELECT
        id,
        'base' as chain,
        address,
        topics,
        data,
        block_number,
        block_timestamp,
        transaction_hash,
        _gs_op
      FROM base_logs
      WHERE address = lower('0x833589fcd6edb6e08f4c7c32d4f71b54bda02913')
        AND topics LIKE '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef%'

      UNION ALL

      SELECT
        id,
        'arbitrum_one' as chain,
        address,
        topics,
        data,
        block_number,
        block_timestamp,
        transaction_hash,
        _gs_op
      FROM arbitrum_one_logs
      WHERE address = lower('0xaf88d065e77c8cc2239327c5edb3a432268e5831')
        AND topics LIKE '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef%'

sinks:
  webhook_usdc:
    type: webhook
    from: usdc_transfers
    url: https://api.example.com/webhooks/usdc-transfers
    secret_name: USDC_WEBHOOK_SECRET
    batch_size: 500
    batch_flush_interval: 2s
Event logs from Base (base.raw_logs) and Arbitrum One (arbitrum_one.raw_logs) go into one SQL filter in Goldsky Turbo Pipelines that keeps one contract and one event on each chain. A webhook sink sends batches and retries until your endpoint accepts them. Your HTTP endpoint returns 2xx for a batch and stores each row once by id.

Before you deploy, run goldsky turbo validate on the file. To see the columns of a dataset, run goldsky dataset get base.raw_logs.

The topics column on a raw logs dataset is a comma-separated string, not an array. The event-signature hash is the first value, and the trailing % wildcard has to match the rest of the topic list.

The payload

Your endpoint receives a JSON array, one object per matched row, unless you turn on one_row_per_request. With the default (one_row_per_request: false), we batch rows and send them as one JSON array. Each object has the columns of the transform's SELECT:

json
[
  {
    "id": "...",
    "chain": "base",
    "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
    "topics": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef,...",
    "data": "0x...",
    "block_number": "...",
    "block_timestamp": "...",
    "transaction_hash": "0x...",
    "_gs_op": "..."
  }
]

Set one_row_per_request: true if your endpoint would rather see one request per event, each with a single JSON object body instead of an array.

What your endpoint needs to handle

Four things: duplicates, retries, batches, and reorg corrections, and each one has a defined behavior you can code against.

Turbo pipelines give you at-least-once delivery, not exactly-once. A pipeline crash between a sink's write and the source committing its read position replays the same rows, so your endpoint can see the same event twice. The fix is an idempotency key: use the row's id, the stable primary key that comes from the upstream record, and deduplicate or upsert on it instead of inserting blindly.

Retries follow one rule: network errors, timeouts, 408, 429, and any 5xx response are retried indefinitely with exponential backoff, so a short outage on your side delays data and doesn't lose it. Any other 4xx response fails the pipeline immediately, so a malformed request on your end needs a fast fix. Return 2xx once you've durably stored or processed the batch, not before.

Batches arrive on two controls you set on the sink. batch_size (1,000 rows by default) caps how many rows land in one request, and batch_flush_interval (1 second by default) caps how long Turbo waits before sending a partial batch. Our example above trims both to 500 rows and 2 seconds, a reasonable starting point for a sink that does real work per request. Raise the interval if your endpoint is slow and you'd rather see fewer, larger requests.

A reorg arrives as a correction. A webhook has no table for us to fix, so we can't resolve a reorg for you the way a Postgres or ClickHouse sink with a primary key does. When a chain reorgs, the delete and update records for the replaced blocks flow through the pipeline like any other record, and your endpoint has to apply them. It reads _gs_op, the operation column, and removes or corrects the row it stored for that id. You won't see this often on these two chains: our post on why indexing onchain data is hard counted 1 replaced block on Base and 0 on Arbitrum One in our data.

Auth

Your endpoint checks one header, and Turbo sets it the same way on every request. Create an httpauth secret with goldsky secret create, choosing a header name and value, for example Authorization and Bearer <your-token>. Reference it from the sink with secret_name, and Turbo adds that header to every outgoing request. Check for that header and its exact value on your side before you trust the payload. You can't set the same header name under the sink's headers field and under secret_name at the same time. Pick one.

Three ways to get a webhook from Goldsky

The right one depends on whether you want raw or decoded chain events, entity-level changes from a subgraph, or a dataset we already maintain for you.

ProductWhat you getWhen it fits
Turbo webhook sinkRaw logs or decoded events from any contract, any chain Turbo supports, on your own filterYou know the contract and event, and want control over the SQL filter and batch shape
Subgraph webhooksAn INSERT, UPDATE, or DELETE payload on every entity change in a subgraph, with the entity name and a retry count in delivery_infoYou already run a subgraph and want to react to the entities it tracks, not raw chain logs
Feeds data syncA ready-made feed (wallet balances, transfers, token prices, and more) pushed to your webhook as rows land, no pipeline to writeYou want a dataset we already built, not one you filter yourself. Feeds data sync (opens in a new tab) is in early access. Email [email protected] to turn it on

If you watch for deposits into wallets you control, our post on deposit detection for wallet providers builds that watcher, native transfers included.

Polling an RPC node

The other approach is to poll an RPC node for new logs yourself. Goldsky Edge is our RPC product. It gives you low-latency RPC access over a multi-region CDN, with caching and automatic failover, on both Base and Arbitrum One. A poller on Edge calls eth_newFilter to register an address and topic filter, then calls eth_getFilterChanges on an interval to collect what matched since the last call. With polling, you own the interval and the backoff on a failed call. With the webhook sink, we push each match to you and retry until your endpoint accepts it.

FAQ

Can I get decoded event fields instead of raw topics and data?
Yes. Turbo's _gs_log_decode function takes a contract ABI and the row's topics and data, and returns the decoded event name and parameters. Fetch the ABI with _gs_fetch_abi, either from Etherscan-style explorers or a raw JSON URL, and add a second SQL transform that calls _gs_log_decode before the webhook sink.

What happens if my endpoint is down for an hour?
The webhook sink treats a connection failure the same as a 5xx: it retries with exponential backoff, and backpressure paces the pipeline to your endpoint's responsiveness rather than dropping data. Your events arrive late, not lost, once your endpoint comes back.

Do I need a different pipeline for every contract I watch?
No. Add more OR conditions, or an IN (...) list, to the same SQL filter if you're watching several addresses for the same event, or add a second UNION ALL branch for a different event on the same chains.

How do I start?
Install the Goldsky CLI, log in with goldsky login, add the Turbo extension with goldsky turbo, and validate a pipeline file like the one above with goldsky turbo validate <file>.yaml before you deploy it with goldsky turbo apply <file>.yaml.

© Endless Sky Inc. All rights reserved.

PrivacyTermsSecurity

System status