What can you really do with a memecoin? Now, with Moondong, you can read Moon Man Mark Bailey's science fiction novels for free. Just go to rstory.io, scroll down to the bottom of the page, and click the Moondong link. A window will open up and you can click the link there to connect your Phantom wallet. If there's more than 100k Moondong in your wallet, the book links on the site will become active. Note that this only works on desktop for now, with mobile app support coming soon.
Integrating Moondong into a page is easy. First, there's the script import:
Then comes the Phantom wallet connection and token check:
// Phantom integration and Moondong balance check
// Helper to compute the associated token address (ATA)
async function getAssociatedTokenAddress(mint, owner) {
return (
await solanaWeb3.PublicKey.findProgramAddress(
[
owner.toBuffer(),
new solanaWeb3.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").toBuffer(),
mint.toBuffer()
],
new solanaWeb3.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")
)
)[0];
}
async function connectPhantomAndCheckMoondong() {
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
const provider = window.solana;
// If no provider is detected
if (!provider) {
if (isMobile) {
// Use deep linking for mobile devices
const appUrl = encodeURIComponent(window.location.href);
const deepLink = `https://phantom.app/ul/v1/connect?app_url=${appUrl}&redirect_url=${appUrl}`;
window.location.href = deepLink;
return;
} else {
alert("Phantom Wallet not found.");
return;
}
}
// Connect using the available provider (desktop or Phantom's in-app browser)
try {
const resp = await provider.connect();
const publicKey = resp.publicKey;
// Establish a connection to the Solana network and query Moondong token balance
const connection = new solanaWeb3.Connection(
"https://YOUR FAVORITE ENDPOINT",
"confirmed"
);
const mint = new solanaWeb3.PublicKey("DthcPtviaaVasr6GTjRLoRcJSysSqGsZR61LArghpump");
const ata = await getAssociatedTokenAddress(mint, publicKey);
const result = await connection.getTokenAccountBalance(ata);
const balance = result.value.uiAmount;
console.log("Moondong balance:", balance);
if (balance >= 100000) {
updateLoadingDiv(`You hold ${balance} Moondong tokens. Nice! Book links activated`);
if (typeof reveal === "function") reveal();
} else {
updateLoadingDiv(`You hold only ${balance} Moondong tokens. 100,000 required.`);
}
} catch (err) {
console.error("Phantom or Moondong balance error:", err);
updateLoadingDiv("Could not read Moondong balance.");
}
}
// Bind the Phantom button click event
document.addEventListener("DOMContentLoaded", () => {
const phantomLink = document.getElementById("phantom-check");
if (phantomLink) {
console.log("Phantom link found");
phantomLink.addEventListener("click", (e) => {
e.preventDefault();
console.log("Phantom link clicked");
// Close the Moondong modal if open
closeModal("moondong");
// Optionally, smoothly scroll to the loading div
const loadingDiv = document.getElementById("loading");
if (loadingDiv) {
setTimeout(() => {
loadingDiv.scrollIntoView({ behavior: "smooth", block: "start" });
}, 100);
}
// Connect Phantom and check the token balance
connectPhantomAndCheckMoondong();
});
} else {
console.warn("Phantom link not found");
}
});
When the user has more than 100k Moondong tokens, this code triggers a function called reveal()
which decrypts encrypted hashes to construct valid book links on this page. But this function could have any purpose. Beyond revealing media products, it could be used to grant entry into a private chatroom, to whitelist an address for a token drop, or to perform some action on social media.
Solana Contract Address: DthcPtviaaVasr6GTjRLoRcJSysSqGsZR61LArghpump
Linktree
Telegram
Twitter