A sCrypt Hackathon 2024 project submission.
We decided to participate in the sCrypt hackathon to learn about bitcoin's script capabilities using the sCrypt Smart Contract library.
For the project scope, we sought to port the existing process of buying gasoline to bitcoin.
The current process consists of:
- a user arriving at a gas station gas pump
- a user swiping a credit card and getting pre-charged for $200 (which covers the cost of filling up)
- a user pumping gas; selecting an octane, pumping the gas, and hanging up the nozzle
- the gas station gas pump reverting the pre-charge amount
- the gas station gas pump charging the credit card for the actual amount of gas purchased.
This scenario (or business process) involves two actors:
- Buyer - the person who's going to be buying gas
- Gas Pump - a single gas pump at a gas station
- clone this repo
- ensure Node 16+ is installed
- run
npm i
from the root of the directory to install the project's dependencies - ensure Yours Wallet is installed in your browser (set it to testnet mode)
- ensure Sensilet Wallet is installed in your browser (set it to testnet mode too)
- export your testnet Sensilet Wallet private key and copy it into
getPubKey.js
- then run
node getPubKey.js
to get a public key (this key will be used as the Public Key for the Gas Pump) - copy the Public Key into the
/src/contracs/GassedUp.ts
Smart Contract - run
npx scrypt-cli compile
to compile the smart contract into the/artifacts
directory
- Finally, run
npm start
to start a web server serving a React App that will use the GassedUp bitcoin smart contract
The app should now be running at http://localhost:3000.
With the app running at http://localhost:3000 and both Yours and Sensilet Wallets running in the browser (and both in testnet
mode):
tip: to fund the wallets for testing, visit https://scrypt.io/faucet
You'll see something like:
- click "bitcoin" to buy some gas; this will open a modal window
- select 100, 200, or enter a number of satoshis to buy gas
- this will open the Buyer's Yours Wallet and prompt the user to sign the transaction
- after clicking 'sign transaction', an alert message will be displayed showing the txid of the deployed contract
- select an octane of gas
- click 'Start' to start pumping gas, and click 'Stop' when done pumping
- click 'Complete' to finalize the transaction and get your change
- Done! You're all gassed up!