Receiving instant Bitcoin payments with Supabase
Learn how to receive Bitcoin using Supabase Edge Functions.
Prerequisites
To complete this guide, you will need the following:
1. Create a Supabase Function
To create a Supabase Edge Function you must run the following command locally:
This will create a /supabase/functions/zbd-receive
folder structure in your project.
2. Write the Edge Function
Use the code below as a starting point for your handler function. You will need to replace the ZBD_API_KEY
with your own ZBD Project’s API key.
3. Receive payment locally
To run this Supabase Edge Function locally you can spin up your Supabase instance using the following command. You may already have this running at this stage.
Then you can run the following command to start your serverless function:
Note that we add the --no-verify-jwt
flag to the command to disable JWT verification. This is because we are not passing a JWT token to the function when we call it. This is not recommended for production use.
Supabase CLI will output a HTTP URL endpoint that you can use to test your function by issuing a POST request to that resource.
4. Deploying to Supabase Edge
After testing it locally, you can deploy your function to Supabase Edge using the following command. You will need to enter your Supabase project ID to deploy.
Once you deploy you will receive a URL that you can use to view that function in production on Supabase’s Web Dashboard:
Opening your browser (or another HTTP client) to the URL provided by Supabase: https://xxxxxxxxxxxxx.supabase.co/functions/v1/zbd-receive
should return a JSON response with the payment request details.
You can also test this using curl command:
You’re looking for the data.invoice.request
property in the JSON response. It starts with lnbc1
and is the payment request anyone in the Bitcoin Lightning Network can use to pay you.
5. Try it yourself
You can now begin receiving instant Bitcoin payments on the edge with Supabase + ZBD!
Was this page helpful?