1.2 KiB
1.2 KiB
Here's a simple JavaScript code snippet that creates a referral link that asks for a Bitcoin Lightning address:
function createReferralLink() {
// Get the user's Bitcoin Lightning address
const lightningAddress = prompt("Please enter your Bitcoin Lightning address:");
// Construct the referral link
const referralLink = `https://example.com/referral?lightning_address=${encodeURIComponent(lightningAddress)}`;
// Return the referral link
return referralLink;
}
// Example usage
const myReferralLink = createReferralLink();
console.log("Your referral link:", myReferralLink);
In this code, the createReferralLink()
function prompts the user to enter their Bitcoin Lightning address, and then constructs a referral link that includes the entered address as a query parameter. The encodeURIComponent()
function is used to properly encode the Lightning address in the URL6.
The resulting referral link can then be used to share with others, and when they click on it, the Lightning address will be passed along as a parameter.
Please note that this is a basic example, and you may want to add additional functionality or error handling as needed for your specific use case.