Hacker Zaps Coca-Cola VM to Accept Bitcoin via Lightning Network
A Brazillian computer programmer built a Coca-Cola vending machine that accepts bitcoin payments over the Lightning Network (LN).
Bitcoin-Powered Coke Vending Machine
Ricardo Reis described his feat in a Medium post on Oct. 2, in which he also mentioned the accessories that were employed to create the bitcoin-enabled Coke portal. In addition to applied programming techniques and vending machine hardware that could take instructions from the user-interface, Reis also used the Lightning Network to enable faster and cheaper bitcoin transactions.
Unlike a normal bitcoin transaction, which gets recorded and verified on a public blockchain, the LN adds a secondary layer to create a payment channel that does not require transactions to be confirmed by the main blockchain until the users close the channel. Thus, users can make a series of the transactions without needing miners’ confirmation. Once they close the payment channel on the Lightning network, its cumulative output gets recorded and verified on the main bitcoin ledger.
Cryptocurrency developers Joseph Poon and Thaddeus Dryja had introduced Lightning Network as a solution to bitcoin’s slow on-chain transactions that were supposedly hampering its growth among merchants. Reis’ efforts simply illustrated the process with a real-world example as simple as a Coca-Cola vending machine.
How the Coke Vending Machine Works
Reis makes a communicative bridge between the Coke machine’s hardware and software tools. On the hardware side, there is a Raspberry Pi 3 Model B, a Display 7″ Official Touch Screen Para Raspberry Pi, a Water pump RS 385, and a Bridge H L298N. On the software and web solutions’ side, Reis employs Linux Raspbian in Raspberry Pi, Apache Server + PHP in Raspberry Pi, Wiring Pi (interface GPIO), BTCPAY as checkout solution, PUSHER as a web-socket solution, and HTML, PHP, Javascript e jQuery as applied programming languages.
A simpler front-end makes up for a complex backend. The Coke vending machine features a simple interface, with a bitcoin wallet QR code of the receiver. People looking to purchase a beverage must scan the QR via their bitcoin wallet apps, enter the amount, and send it. The machine sends the payment confirmation upon receiving the funds, which should not take more than a minute, and Coke starts to pour in the glass underneath the device.
“In BTCPAY I create the invoice (payment button), so it generates a Lightning Network QR code for payment,” Reis wrote. “I also set up a return URL (notification.php), which is the destination BTCPAY will inform when a purchase order has any changes, such as payment receipt.”