How to setup WebHooks with QuikNode

Sahil Sen
August 19, 2020

What are WebHooks

In this article, we'll learn about WebHooks and how we can set-up WebHooks with QuikNode.

What are WebHooks?

Everything we do on the internet can be marked/considered as events and as the internet grows, these events grow in numbers. We often require API calls to other apps to get their event's status, which is called polling. In polling we make requests to see if there are any new events. If you do not want to write a script for polling or do not want to run a server 24/7 you can use WebHooks - with WebHooks, we can get notified as soon as a new event is triggered.

WebHook (also known as web callback or HTTP push API) is a way for an application to provide its real-time data to other applications. WebHooks are very efficient as compared to the typical API method where we have to poll frequently.

Example:

Let's say we have a streaming service application and we've set-up Stripe to accept payments. Now whenever a new user makes a payment they need to be added to our user database. So, what we need to do is set-up a WebHook with Stripe, which is configured to send the user information via a WebHook URL as a POST request to our application whenever a user pays via Stripe. Our application after receiving this data adds the user to the user database.

We have made WebHooks available for all QuikNode customers as an Add On.

WebHooks with QuikNode

WebHooks are the best way for server-side apps to send automated messages or information to other server-side apps.

QuikNode WebHooks were created to allow users to bring Web3 smart-contract event listeners to Web2, by handling the discovery and notification of new smart-contract events in real-time. This means users don’t have to run a server 24/7 doing their own polling or WebSocket listening.

How to setup QuikNode WebHooks

Now that we know what WebHooks are and how they can be really helpful, let's set-up one with QuikNode.

  1. Head over to QuikNode.io and make an account.
  2. Click on CREATE NODE.
  3. Choose a plan based on your usage and select your preferred network.
  4. From the "add ons" section add EVENT WEB HOOKS and complete the billing process.
  5. A node with WebHooks add-on will be added to your account under the Nodes tab.

Click on your node and go to WebHooks section from the left menu, you'll see a UI similar to the image below.

Let's set-up a WebHook for a smart-contract event.

The smart-contract we'll use is a URL shortening app deployed on Ethereum Blockchain. We're setting up this WebHook so when someone uses this app to shorten a URL, the WebHook sends the event data. 

  1. The name of our smart-contract is URLShortner which needs to go in the name field.
  2. The address at which our smart-contract is deployed is 0x19624fFa41FE26744E74FDBba77Bef967a222D4c - this needs to go in the contract address field.
  3. The event which we want to watch for is URLShortened, this needs to be entered in the event name field.
  4. Now in the next field, we need to enter the URL to the ABI JSON. 'https://raw.githubusercontent.com/dU4E/0xsu-smart-contracts/master/url_shortener.abi' - this needs to go in the ABI URL field
  5. For the fifth field, we need to enter the URL, where we want our event data to be delivered, 'https://dimaamid.free.beeceptor.com/special-webhook' - this needs to go in the WebHook URL field
  6. After entering all the values click on SAVE WEBHOOK and your WebHook is ready.

Note: Make sure that the ABI file has the event which we want to be notified about configured properly (URLShortened in this example).

After the setup, you must see your WebHook lined up in the WebHooks section



You can check the details by clicking on Details and you'll see the WebHook's details and the attempts, something like this,



You can view the full log of WebHooks sent to you and also the request, response of a particular WebHook attempt by clicking on View details on that particular entry. it'll look something like this:



Conclusion

So, now we know how to set up WebHooks with QuikNode. This WebHooks feature was requested by one of our users and we made it happen, you can always reach out to us if you have a feature request or need any help.

Subscribe to our newsletter for more articles and guide on Ethereum. If you have any feedback, please feel free to reach out to us via Twitter and you can always chat with us if you have a question via our community server on Discord, thanks :)
Sahil Sen
Web developer who believes in power of communities and is passionate about community building. Developer evangelist @ QuikNode.

Related articles

All set for your QuikNode?