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.
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.
The name of our smart-contract is URLShortner which needs to go in the name field.
The address at which our smart-contract is deployed is 0x19624fFa41FE26744E74FDBba77Bef967a222D4c - this needs to go in the contract address field.
The event which we want to watch for is URLShortened, this needs to be entered in the event name field.
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
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
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:
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 :)
If you're running your own bitcoin node (such as bitcoind or bcoin) there is a chance you will want the ability to look up the balance of an address that you do not own. The first time this happens, you might create a