<p>I want to trigger a function when someone sent ADA to an address addr1xxxxxx.
I use webhook from Blockfrost. I see this link (<a href="https://blockfrost.dev/docs/start-building/webhooks/using-webhooks" rel="nofollow noreferrer">https://blockfrost.dev/docs/start-building/webhooks/using-webhooks</a>) to describe how to use it.
I works fine if I use public webhook site (<a href="https://webhook.site/" rel="nofollow noreferrer">https://webhook.site/</a>)
but it fails to trigger on my own server.</p>
<p>I set up as follows:</p>
<ol>
<li>I create a webhook on blockfrost website as follows.</li>
</ol>
<ul>
<li>The endpoint URL is set to the static address of my server, at port 6666.</li>
<li>Trigger condition is set when someone sends ADA to the address addr1xxxx</li>
</ul>
<p>After creating this, Blockfrost will generate an Auth token.</p>
<ol start="2">
<li>I replace SECRET_AUTH_TOKEN in the following script by the above Auth token.</li>
</ol>
<pre><code># Example of Python Flask app with /webhook endpoint
# for processing events sent by Blockfrost Secure Webhooks
from flask import Flask, request, json
from blockfrost import verify_webhook_signature

# You will find your webhook secret auth token in your webhook settings in the Blockfrost Dashboard
SECRET_AUTH_TOKEN = &quot;SECRET-WEBHOOK-AUTH-TOKEN&quot;

app = Flask(__name__)

# Define endpoint /webhook that accepts POST requests
@app.route('/webhook', methods=['POST'])
def webhook():
    if request.method == 'POST':
        # Validate webhook signature
        request_bytes = request.get_data()
        try:
            verify_webhook_signature(
                request_bytes, request.headers['Blockfrost-Signature'], SECRET_AUTH_TOKEN)
        except SignatureVerificationError as e:
            # In case of invalid signature verify_webhook_signature will raise SignatureVerificationError
            # for easier debugging you can access passed header and request_body values (e.header, e.request_body)
            print('Webhook signature is invalid.', e)
            return 'Invalid signature', 403

        # Get the payload as JSON
        event = request.json

        print('Received request id {}, webhook_id: {}'.format(
            event['id'], event['webhook_id']))

        if event['type'] == &quot;transaction&quot;:
            # process Transaction event
            print('Received {} transactions'.format(len(event['payload'])))
            # loop through the payload (payload is an array of Transaction events)
            for transaction in event['payload']:
                print('Transaction id: {}, block: {} ({})'.format(
                    transaction['tx']['hash'], transaction['tx']['block'], transaction['tx']['block_height']))

        elif event['type'] == &quot;block&quot;:
            # process Block event
            print('Received block hash {}'.format(event['payload']['hash']))

        elif event['type'] == &quot;delegation&quot;:
            # process Delegation event
            print('Received {} delegations'.format(len(event['payload'])))
            # loop through the payload, payload is an array of objects with fields: &quot;tx&quot; (an object) and &quot;delegations&quot; (an array)
            for transaction in event['payload']:
                for delegation in transaction['delegations']:
                    print('Delegation from an address {} included in tx {}'.format(
                        delegation['address'], transaction['tx']['hash'])
                    )

        elif event['type'] == &quot;epoch&quot;:
            # process Epoch event
            print('Epoch switch from {} to {}'.format(
                event['payload']['previous_epoch']['epoch'], event['payload']['current_epoch']['epoch']))

        else:
            # Unexpected event type
            print('Unexpected event type {}'.format(event['type']))

        return 'Webhook received', 200
    else:
        return 'POST Method not supported', 405



if __name__ == &quot;__main__&quot;:
    app.run(host='0.0.0.0', port=6666)
</code></pre>
<ol start="3">
<li>I run the script on my own server. My server has static as same as set in Endpoint URL
<a href="https://i.sstatic.net/HMKoG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HMKoG.png" alt="enter image description here" /></a></li>
</ol>
<p>But when addr1xxx received ADA, the script was not trigger. I do not know where I am wrong.</p>
<p>I am new to webhook. Your help would help me a lot.Thanks</p>

CC BY-SA 4.0
2022-12-26T09:44:05.883Z
If it works on the public side, it probably a problem with your script. When you go to the Blockfrost dashboard and click on your webhook, what do you see in `Failed requests`?
Marek Mahut - StakeNuts
CC BY-SA 4.0
2022-12-26T09:50:19.223Z
The script is copied from here ( https://blockfrost.dev/docs/start-building/webhooks/using-webhooks.) with no change except the "SECRET-WEBHOOK-AUTH-TOKEN".
In "Failed request" of the dashboard, It says "Timeout awaiting 'request' for 5000ms". I think it could not reach my public website. But I dont know how to set it.
cdt
CC BY-SA 4.0
2022-12-26T09:51:12.567Z
Yeah, it appears your website is not public. Firewall? Not listening on correct interface? Can you reach it from outside of your server?
Marek Mahut - StakeNuts
CC BY-SA 4.0
2022-12-26T09:52:41.197Z
yes. My site has public IP and domain. I can access it through Internet through port 80.
cdt
CC BY-SA 4.0
2022-12-26T09:54:40.280Z
What do you mean on different port? If you go to https://portchecker.co/, put in the same IP and port you have put in your webhook, is it open?
Marek Mahut - StakeNuts
CC BY-SA 4.0
2022-12-26T09:54:48.100Z
Should I config URL endpoint in the dashboard is http://xxxxx:6060/webhook or just http://xxxxx:6060. I actually do not fully understand the script.
cdt
CC BY-SA 4.0
2022-12-26T09:55:27.447Z
Definitely /webhook, as it says in the comment `Define endpoint /webhook that accepts POST requests`.
Marek Mahut - StakeNuts
CC BY-SA 4.0
2022-12-26T09:57:14.190Z
Thanks. One more question. Should I set the endpoint by the domain or IP address (of my server), or either of them is fine?
cdt
CC BY-SA 4.0
2022-12-26T09:57:36.493Z
Ether is fine, it just needs to resolve correctly.
Marek Mahut - StakeNuts
CC BY-SA 4.0
2022-12-26T09:58:50.953Z
Thanks for quick guide. I will check the port and report later.
cdt
CC BY-SA 4.0
2022-12-26T13:14:11.110Z
It works. Thanks for your support
cdt
CC BY-SA 4.0
2022-12-29T17:40:45.253Z
I’m voting to close this question because the problem has been on end-user's network configuration and not related to Blockfrost.
Marek Mahut - StakeNuts
<blockfrost><cardano-address>
How to use webhook on Blockfrost?
# How to use webhook on Blockfrost?

(Asked by: username_0 on 2022-12-26)

I want to trigger a function when someone sent ADA to an address addr1xxxxxx.
I use webhook from Blockfrost. I see this link (https://blockfrost.dev/docs/start-building/webhooks/using-webhooks) to describe how to use it.
I works fine if I use public webhook site (https://webhook.site/)
but it fails to trigger on my own server.
I set up as follows:

I create a webhook on blockfrost website as follows.


The endpoint URL is set to the static address of my server, at port 6666.
Trigger condition is set when someone sends ADA to the address addr1xxxx

After creating this, Blockfrost will generate an Auth token.

I replace SECRET_AUTH_TOKEN in the following script by the above Auth token.

# Example of Python Flask app with /webhook endpoint
# for processing events sent by Blockfrost Secure Webhooks
from flask import Flask, request, json
from blockfrost import verify_webhook_signature

# You will find your webhook secret auth token in your webhook settings in the Blockfrost Dashboard
SECRET_AUTH_TOKEN = "SECRET-WEBHOOK-AUTH-TOKEN"

app = Flask(__name__)

# Define endpoint /webhook that accepts POST requests
@app.route('/webhook', methods=['POST'])
def webhook():
    if request.method == 'POST':
        # Validate webhook signature
        request_bytes = request.get_data()
        try:
            verify_webhook_signature(
                request_bytes, request.headers['Blockfrost-Signature'], SECRET_AUTH_TOKEN)
        except SignatureVerificationError as e:
            # In case of invalid signature verify_webhook_signature will raise SignatureVerificationError
            # for easier debugging you can access passed header and request_body values (e.header, e.request_body)
            print('Webhook signature is invalid.', e)
            return 'Invalid signature', 403

        # Get the payload as JSON
        event = request.json

        print('Received request id {}, webhook_id: {}'.format(
            event['id'], event['webhook_id']))

        if event['type'] == "transaction":
            # process Transaction event
            print('Received {} transactions'.format(len(event['payload'])))
            # loop through the payload (payload is an array of Transaction events)
            for transaction in event['payload']:
                print('Transaction id: {}, block: {} ({})'.format(
                    transaction['tx']['hash'], transaction['tx']['block'], transaction['tx']['block_height']))

        elif event['type'] == "block":
            # process Block event
            print('Received block hash {}'.format(event['payload']['hash']))

        elif event['type'] == "delegation":
            # process Delegation event
            print('Received {} delegations'.format(len(event['payload'])))
            # loop through the payload, payload is an array of objects with fields: "tx" (an object) and "delegations" (an array)
            for transaction in event['payload']:
                for delegation in transaction['delegations']:
                    print('Delegation from an address {} included in tx {}'.format(
                        delegation['address'], transaction['tx']['hash'])
                    )

        elif event['type'] == "epoch":
            # process Epoch event
            print('Epoch switch from {} to {}'.format(
                event['payload']['previous_epoch']['epoch'], event['payload']['current_epoch']['epoch']))

        else:
            # Unexpected event type
            print('Unexpected event type {}'.format(event['type']))

        return 'Webhook received', 200
    else:
        return 'POST Method not supported', 405



if __name__ == "__main__":
    app.run(host='0.0.0.0', port=6666)


I run the script on my own server. My server has static as same as set in Endpoint URL


But when addr1xxx received ADA, the script was not trigger. I do not know where I am wrong.
I am new to webhook. Your help would help me a lot.Thanks

**Tags:** blockfrost, cardano-address
> **Comments:**
> **username_1**: If it works on the public side, it probably a problem with your script. When you go to the Blockfrost dashboard and click on your webhook, what do you see in `Failed requests`?  
> **username_0**: The script is copied from here ( https://blockfrost.dev/docs/start-building/webhooks/using-webhooks.) with no change except the "SECRET-WEBHOOK-AUTH-TOKEN". In "Failed request" of the dashboard, It says "Timeout awaiting 'request' for 5000ms". I think it could not reach my public website. But I dont know how to set it.  
> **username_1**: Yeah, it appears your website is not public. Firewall? Not listening on correct interface? Can you reach it from outside of your server?  
> **username_0**: yes. My site has public IP and domain. I can access it through Internet through port 80.  
> **username_1**: What do you mean on different port? If you go to https://portchecker.co/, put in the same IP and port you have put in your webhook, is it open?  
> **username_0**: Should I config URL endpoint in the dashboard is http://xxxxx:6060/webhook or just http://xxxxx:6060. I actually do not fully understand the script.  
> **username_1**: Definitely /webhook, as it says in the comment `Define endpoint /webhook that accepts POST requests`.  
> **username_0**: Thanks. One more question. Should I set the endpoint by the domain or IP address (of my server), or either of them is fine?  
> **username_1**: Ether is fine, it just needs to resolve correctly.  
> **username_0**: Thanks for quick guide. I will check the port and report later.  
> **username_0**: It works. Thanks for your support  
> **username_1**: I’m voting to close this question because the problem has been on end-user's network configuration and not related to Blockfrost.  

---

## 0 answers

