This tutorial focuses on the implementation of micropayments in games built with Godot. If you have no experience with running a Bitcoin node and/or the Lightning network it is good to know this setup can run extremely stable and cheap on a Raspberry pi with a 500GB external harddrive that has it’s own power source.
You’ll need Bitcoin (the Bitcoin daemon bitcoind) to connect to the Bitcoin network, the c-lightning implementation of the Lightning Network protocol (lightningd) and Lightning Charge, an API daemon (charged) for accepting Lightning payments. So let’s get going.
- For setting up a server, see Bitcoin Pi, Umbrel or raspnode or use a different (linux) setup.
- Install bitcoind, the bitcoin daemon. See: bitcoin.org and bitcoincore. Make sure you set it up with txindex=1 and without pruning. When finished, setup RPC access for the lightning daemon. See: JSON-RPC.
- Install lightningd and test the JSON-RPC Interface. See: ElementsProject
- Setup Lightning Charge and bind it to all interfaces. See: lightning-charge (remember your server ip-address, charge’s port (usually 9112) and your login (api-token) and password, you’ll need it later)
- Run the three services (bitcoind, lightningd and charge) and setup an inbound Lightning channel over the Lightning Network, for example a free one from lnbig.
- Install a Lightning Network wallet on your mobile phone, for example bluewallet and add some funds.
For this project the zint barcode encoding library on Windows is used. The binary (zint.exe) comes with the project if you decide to download it. The tutorial explains where to find the software source. Make sure before you begin the tutorial to obtain a version of zint that works within your development environment and your intended audience. When you deploy a game using this binary you'll have to package and configure the binary in a way that corresponds with the platform of your customers.
For this project Godot Engine 3.1 is used. If you have no experience with the Godot Game Engine that’s fine. It is extremely fast and easy to set up (only one click!).
- Download version 3.1 or higher of this amazing Open Source game engine for free: godot (it’s just over 50 MB in size).
Once your server is up and running, we’re ready for the fun (and easy) stuff.