Skip to content

Instantly share code, notes, and snippets.

@thebells1111
Created June 7, 2023 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebells1111/cdd732a52cb5314a0434efd61391f5a0 to your computer and use it in GitHub Desktop.
Save thebells1111/cdd732a52cb5314a0434efd61391f5a0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script
src="https://unpkg.com/webln@0.3.2/dist/webln.min.js"
integrity="sha384-MpjpvOQqXz9nCoLUS/sR0bhLwGYuNPMOBN50jsqhnqAzDq0GiOI0u6oC5fHitzI2"
crossorigin="anonymous"
></script>
<style>
#boost,
#install-alby {
display: none;
}
</style>
</head>
<body>
<div id="content">
<button id="boost">Boost</button>
<p id="install-alby">Install Alby to Support</p>
</div>
<script>
const boostButton = document.getElementById("boost");
const installParagraph = document.getElementById("install-alby");
if (typeof window.WebLN !== "undefined") {
boostButton.style.display = "block";
boostButton.addEventListener("click", handleBoost);
} else {
installParagraph.style.display = "block";
}
async function handleBoost() {
try {
const webln = await WebLN.requestProvider();
await webln.keysend({
destination:
"030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3",
amount: 100,
customRecords: { 696969: "2yjUCncyVMyWY31einuk" },
});
} catch (err) {
installParagraph.style.display = "block";
boostButton.style.display = "none";
alert(err.message);
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment