Skip to content

Commit 7a5c216

Browse files
authored
Merge pull request #199 from ChangoMan/with-frames
feat: Adding farcaster frames metadata
2 parents 298682b + 832c15a commit 7a5c216

11 files changed

+89
-2
lines changed

packages/backend/index.js

+77
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,83 @@ app.get("/challenges", withRole("admin"), async (request, response) => {
390390
}
391391
});
392392

393+
app.post("/api/frame", (req, res) => {
394+
const baseUrl = "https://speedrunethereum.com";
395+
const SRE_BACKEND = "https://scaffold-directory-dev.ew.r.appspot.com";
396+
397+
const challengeButtons = {
398+
0: {
399+
label: "🎟 Simple NFT Example",
400+
link: "https://speedrunethereum.com/challenge/simple-nft-example",
401+
},
402+
1: {
403+
label: "🥩 Staking App",
404+
link: "https://speedrunethereum.com/challenge/decentralized-staking",
405+
},
406+
2: {
407+
label: "🏵 Token Vendor",
408+
link: "https://speedrunethereum.com/challenge/token-vendor",
409+
},
410+
3: {
411+
label: "🎲 Dice Game",
412+
link: "https://speedrunethereum.com/challenge/dice-game",
413+
},
414+
4: {
415+
label: "⚖️ Build a DEX",
416+
link: "https://speedrunethereum.com/challenge/minimum-viable-exchange",
417+
},
418+
5: {
419+
label: "📺 State Channel App",
420+
link: "https://speedrunethereum.com/challenge/state-channels",
421+
},
422+
};
423+
424+
try {
425+
const { query } = req;
426+
427+
let idAsNumber = 0;
428+
429+
if (query && query.id) {
430+
idAsNumber = Number(query.id);
431+
}
432+
433+
const nextId = idAsNumber + 1;
434+
435+
if (idAsNumber === 6) {
436+
res.status(200).send(`<!DOCTYPE html><html><head>
437+
<title>Speed Run Ethereum</title>
438+
<meta property="og:image" content="${baseUrl}/frames/buidlguidl.jpg" />
439+
<meta property="fc:frame" content="vNext" />
440+
<meta property="fc:frame:image" content="${baseUrl}/frames/buidlguidl.jpg" />
441+
<meta property="fc:frame:button:1" content="🛠️ GitHub" />
442+
<meta property="fc:frame:button:1:action" content="link" />
443+
<meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/se-2-challenges" />
444+
<meta property="fc:frame:button:2" content="🏰 BuidlGuidl" />
445+
<meta property="fc:frame:button:2:action" content="link" />
446+
<meta property="fc:frame:button:2:target" content="https://buidlguidl.com/" />
447+
<meta property="fc:frame:button:3" content="💬 Telegram" />
448+
<meta property="fc:frame:button:3:action" content="link" />
449+
<meta property="fc:frame:button:3:target" content="https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA" />
450+
</head></html>`);
451+
} else {
452+
res.status(200).send(`<!DOCTYPE html><html><head>
453+
<title>Speed Run Ethereum</title>
454+
<meta property="og:image" content="${baseUrl}/frames/challenge-${idAsNumber}.png" />
455+
<meta property="fc:frame" content="vNext" />
456+
<meta property="fc:frame:image" content="${baseUrl}/frames/challenge-${idAsNumber}.png" />
457+
<meta property="fc:frame:button:1" content="${challengeButtons[idAsNumber].label}" />
458+
<meta property="fc:frame:button:1:action" content="link" />
459+
<meta property="fc:frame:button:1:target" content="${challengeButtons[idAsNumber].link}" />
460+
<meta property="fc:frame:button:2" content="Next →" />
461+
<meta property="fc:frame:post_url" content="${SRE_BACKEND}/api/frame?id=${nextId}" />
462+
</head></html>`);
463+
}
464+
} catch (err) {
465+
console.log("err", err);
466+
res.status(500).send({ error: "failed to load frame" });
467+
}
468+
});
469+
393470
// If nothing processed the request, return 404
394471
app.use((req, res) => {
395472
console.log(`Request to ${req.path} resulted in 404`);
Loading
10.7 KB
Loading
12.9 KB
Loading
17.2 KB
Loading
17.1 KB
Loading
Loading
10.9 KB
Loading
12.4 KB
Loading
11.5 KB
Loading

packages/react-app/public/index.html

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@
88
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
99

1010
<meta property="og:title" content="Speed Run Ethereum" />
11-
<meta name="description" content="Learn how to build on Ethereum; the superpowers and the gotchas.">
11+
<meta name="description" content="Learn how to build on Ethereum; the superpowers and the gotchas." />
1212
<meta property="og:description" content="Learn how to build on Ethereum; the superpowers and the gotchas." />
13-
<meta name="twitter:card" content="summary_large_image">
13+
<meta name="twitter:card" content="summary_large_image" />
1414
<meta property="og:image" content="%PUBLIC_URL%/thumbnail.png" />
1515
<meta property="twitter:image" content="%PUBLIC_URL%/thumbnail.png" />
1616

17+
<meta property="fc:frame" content="vNext" />
18+
<meta property="fc:frame:image" content="%PUBLIC_URL%/thumbnail.png" />
19+
20+
<meta property="fc:frame:button:1" content="🛠️ GitHub" />
21+
<meta property="fc:frame:button:1:action" content="link" />
22+
<meta property="fc:frame:button:1:target" content="https://github.com/scaffold-eth/se-2-challenges" />
23+
24+
<meta property="fc:frame:button:2" content="⚡️ Start" />
25+
<meta property="fc:frame:post_url" content="https://scaffold-directory-dev.ew.r.appspot.com/api/frame?id=0" />
26+
1727
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
1828
<title>Speed Run Ethereum</title>
1929
<script defer data-domain="speedrunethereum.com" src="https://plausible.io/js/plausible.js"></script>

0 commit comments

Comments
 (0)