Skip to content

Watch every new launch

Example

This is an example. Every value in it (names, amounts, addresses) is there to show you how; change any of them to suit you. It’s watch-new-coins.mjs from developers/examples, as it is. Anything that sends waits for SEND=1: there is no testnet, so a sent transaction spends real ETH.

watch-new-coins.mjs
// Every new launch on Robinhood Chain as it lands, polled every 3 seconds. Prints each with its launchpad.
// SECONDS=60 node watch-new-coins.mjs
const API = process.env.UPRALLY_API ?? 'https://uprally.co/api/v1';
const stopAt = Date.now() + Number(process.env.SECONDS ?? 60) * 1000;
// Start from the newest launch; then ask only for what came after it.
let since = (await (await fetch(`${API}/coins/new?limit=1`)).json()).coins[0]?.createdAt ?? new Date().toISOString();
let seen = 0;
while (Date.now() < stopAt) {
const res = await fetch(`${API}/coins/new?since=${encodeURIComponent(since)}&limit=60`);
if (res.ok) {
const { coins } = await res.json();
for (const c of [...coins].reverse()) console.log(c.createdAt, c.launchpad, c.ticker, c.address, c.page);
if (coins.length) since = coins[0].createdAt;
seen += coins.length;
}
await new Promise((r) => { setTimeout(r, 3000); });
}
console.log(`RESULT ${seen}`);