Skip to content

0xsequence-demos/demo-webhook-endpoint-for-factory-deployments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo: Webhooks for ERC-1155 Factory Deploys

This project is a tiny Node HTTP server that listens for Sequence webhooks from an ERC-1155 factory. When an ERC1155ItemsDeployed event is present, it fetches the transaction receipt to show the deployed proxy address and the deployer.

Prerequisites

  • Node 18+ installed
  • pnpm or plain node to run the server

Run the listener locally

  1. Install dependencies:
    pnpm install
  2. Start the server:
    • With pnpm: pnpm start
    • Or directly: PORT=3000 node server.js
  3. Watch the console for incoming webhook logs. Each request returns {"status":"ok","receivedAt":"<timestamp>"}.

You can test locally with curl:

curl -X POST http://localhost:3000/example \
  -H "Content-Type: application/json" \
  -d '{"hello":"webhooks"}'

Expose locally with ngrok

Use ngrok to forward public traffic to your local listener so third-party webhook providers can reach it.

  1. Install and authenticate ngrok (from https://ngrok.com if you do not already have it).
  2. Start the local server (as above) on the port you want to expose, e.g. 3000.
  3. In a new terminal, run:
    ngrok http 3000
    Copy the generated https://...ngrok.io forwarding URL.
  4. Configure your webhook provider to send events to the ngrok URL. The listener accepts any path; you can reuse / or /webhook.
  5. Trigger an event from the provider. You should see the request details printed in the server logs, confirming the webhook was received.

If you change the server port (via the PORT environment variable), update the ngrok command to match: ngrok http $PORT.

Sequence Builder example

Sequence Builder webhook config

  • The included screenshot.png shows Sequence Builder monitoring an ERC-1155 deployment by listening to the factory contract on Sandchain.
  • Factory address: 0x024b9949fed1c8dd7154de653456d64aa1093384.
  • Point webhook listeners at events from this factory to catch new 1155 contract deployments (and then inspect the emitted data in your server logs when the webhook fires).

Resolving factory deploys from the webhook payload

When a webhook body contains an ERC1155ItemsDeployed log emitted by the factory, the server:

  • uses txnHash to fetch the transaction receipt via Sequence RPC (@0xsequence/network), and
  • decodes the ERC1155ItemsDeployed event with ethers to log the deployed proxy address and the deployer (tx.from).

Environment variables:

  • SEQUENCE_NETWORK (optional): defaults to sandbox-testnet to match the sample factory. Set this to the chain your factory is on (e.g. sand, polygon, arbitrum, mainnet, etc.).
  • PORT (optional): port for the webhook listener.
  • VERBOSE (optional): defaults to false. Set to true to print full receipts.

If the webhook payload matches the shape shown below, you should see logs like:

Wallet 0x927eAA289559ecc0Ee859d833003C756731c9B43 used Factory 0x024b9949fed1c8dd7154de653456d64aa1093384 to deploy items proxy 0x45e21cb37441234976A30214E042e03dC466a35b (txn: 0x05825d7c664037d295b5f36a539d2b0d63a6a4f28c33b0181c03a6c3f7d900a0)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published