Express
Learn how to send and receive instant Bitcoin payments with Express and ZBD.
Prerequisites
To complete this guide, you will need the following:
1. Create a Node.js project
Start with a brand new empty directory called express-example
and run the following command to initiate a Node.js project:
2. Install Express.js
Inside your project directory, run the following command to install Express.js:
3. Install @zbd/node Node.js SDK
Inside your Express.js
4. Send and receive Bitcoin
Create a new file called index.js
and add the following code:
Run the following command to start your Express.js server:
Opening your browser to the following URL: http://localhost:3000/request
should return a JSON response with a payment request.
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.
Opening your browser to the following URL: http://localhost:3000/send
should return a JSON response with the payment sent message.
You can also test this using curl command:
You’re looking for the status
of completed
to know that the payment settled successfully.
processing
. This is expected — use the callbackUrl
property to receive updates about your payments.3. Try it yourself
You can now send and receive instant Bitcoin payments using Express.js + ZBD!
Was this page helpful?